Closed benlk closed 4 years ago
https://amp-wp.org/documentation/playbooks/custom-shortcodes-and-widgets/ describes the function is_amp_endpoint()
and amp_is_canonical()
which we might use with some of the filters added recently to change the output embed code on the page. However, AMP iframe tags aren't 100% compatible with Pym; they use a different postMessage syntax. We'd need to link out to AMP's docs for how to initialize using the amp iframe code versus Pym.js, and we'd need to make these tests ourselves.
There's some discussion going on about this in the AMP Project
I have a proposed "good-enough" solution for this at https://github.com/Automattic/newspack-plugin/pull/276. Let me know if you want it in this plugin and I'll open a PR here. I'd definitely prefer to contribute it upstream to this plugin instead of maintaining it as a tweak in Newspack.
@claudiulodro Yes, we'd love to have your PR here.
Thanks! We'll take a look as soon as we can.
Fallback cases where Pym.js fails to load in the parent
For shortcodes:
[pym src=""]foo[/pym]
that passes the contents to$content
to be used as the innards of the placeholder div:<div id="pym_1" class="pym ">foo</div>
For blocks:
Specific to AMP
For whatever WordPress AMP plugins we want to support:
amp-iframe
as a pymParent: https://github.com/nprapps/pym.js/issues/182