A plugin adding a [pym src=""] shortcode to simplify the process of using http://blog.apps.npr.org/pym.js/
JavaScript Shell PHP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
js
.gitignore
README.md
contributing.md
license.txt
pym-shortcode.php
readme.txt
release.sh

README.md

Pym shortcode

Sample usage:

[pym src="/old?u=http%3A%2F%2Fblog.apps.npr.org%2Fpym.js%2Fexamples%2Ftable%2Fchild.html&y=1999"]

All options:

[pym src="" pymsrc="" pymoptions="" id="" class="" ]

src is the URL of the page that is to be embedded.

pymsrc is optional; only set this if you need to specify a different source than the default. The default pym source is js/pym.v1.min.js in this plugin.

pymoptions is optional; this should be a javascript object without the surrounding {}, and is given in the event that options need to be passed to the pymParent. NPR gives this example javascript:

pym.Parent('example', 'child.html', { xdomain: '*\.npr\.org' });

To do the same thing with this Pym shortcode, you would write:

[pym src="/old?u=https%3A%2F%2Fgithub.com%2FINN%2Fchild.html&y=1999" pymoptions=" xdomain: '\\*\.npr\.org' "]

id is optional; this should be a valid HTML element ID name. It will be used as the ID of your pymParent iframe on the parent page. You would want to use this if, for example, your embedded page contained navigation to another page, requiring the second page to know the pymParent element ID.

For example, the shortcode [pym src="/old?u=http%3A%2F%2Fblog.apps.npr.org%2Fpym.js%2Fexamples%2Fgraphic%2Fchild.html&y=1999" id="extremely_specific_id"] results in the following output:

<div id="extremely_specific_example" class="pym"></div><script src="http://example.org/wp-content/plugins/pym-shortcode/js/pym.v1.min.js"></script><script>var pym_0 = new pym.Parent('extremely_specific_example', 'http://blog.apps.npr.org/pym.js/examples/graphic/child.html', {})</script>

class is optional; this should be a valid HTML class name. It will be added to the element's default class, 'pym'. You would want to use this if, for example, you wanted to use a size-based class name to determine the size of the embed on your site. The class 'pym' will always be output on container elements created by the Pym Shortcode. This class was introduced in version 1.2.2.

For example, the shortcode [pym src="/old?u=http%3A%2F%2Fblog.apps.npr.org%2Fpym.js%2Fexamples%2Fgraphic%2Fchild.html&y=1999" class="one two three four float-left mw_50"] results in the following output:

<div id="pym_0" class="pym one two three four float-left mw_50"></div><script src="http://insideenergy.dev/wp-content/plugins/pym-shortcode/js/pym.v1.min.js"></script><script>var pym_0 = new pym.Parent('pym_0', 'http://blog.apps.npr.org/pym.js/examples/graphic/child.html', {})</script>

If you do not want the class 'pym' output on container elements, add a filter to the hook pym_shortcode_default_class that returns an empty string.