New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AMP Support For Polls & Surveys #41
base: master
Are you sure you want to change the base?
Conversation
2e7152b
to
85f1946
Compare
polldaddy-shortcode.php
Outdated
@@ -178,6 +178,10 @@ function polldaddy_shortcode( $atts ) { | |||
} | |||
} elseif ( intval( $poll ) > 0 ) { //poll embed | |||
|
|||
if ( cs_is_amp_page() ) { | |||
return sprintf( '<amp-iframe src="https://poll.fm/%d/embed" frameborder="0" height="400" layout="fixed-height" width="auto" sandbox="allow-scripts allow-same-origin" style="height: 400px; --loader-delay-offset:406ms !important;" i-amphtml-layout="fixed-height"></amp-iframe>', $poll ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is support for resizing... involves changes to the amp-iframe
and the content it is loading.
https://amp.dev/documentation/examples/components/amp-iframe/#resizable-iframe
I'll give this a try and see how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roundhill thanks for asking about this again. I was able to add support to the poll iframe.
Might be able to do the same with our surveys. Just want to get you to test it on polls to make sure I'm on the right track 😄
See testing instructions for the Crowdsignal side changes that are required.
Ah thanks for finding that! I was looking in the console but didn't notice anything, but maybe because its in an iframe theres a separate console (I feel like FF and Chrome expose those in different ways). I can take it from there. |
Form submission is now working, but the survey resize doesn't seem 100% reliable. Works well on a standard survey, but not working for the Start page... even though the js is executing (confirmed by putting in some console.log statements) but the amp-iframe seems to be ignoring the resize requests. |
This PR replaces poll js embed rendering with an amp-iframe when the page is being served via AMP.
Changes proposed in this Pull Request:
amp-iframe
instead of a poll js embed (markup taken from what WordPress renders by default, with some changes to support iframe resizing)Testing instructions:
The Official AMP plugin needs to be installed on your site (or test on WPCOM) OR
AMP for WP – Accelerated Mobile Pages
plugin/embed
block, or just in a new line on the page)[crowdsignal poll=10603231]
/amp
endpoint and the poll should render correctly (as an iframe)/amp
endpoint and the poll should render correctly (as a js embed)Known issues
Proposed changelog entry for your changes: