-
Notifications
You must be signed in to change notification settings - Fork 384
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
List AMP support for all native WordPress widgets #864
Comments
Widget AMP Support Update: this list is now updated, and located in the project wiki
AMP Errors
Categories Widget with "dropdown"
|
The build will fail, as the filtering in widget() isn't present. There isn't yet a way to instantiate or init() class AMP_Widgets(). But it unregisters the 'Archives' and 'Categories' widgets. And registers new widgets that subclass them. @todo: filter the output of widget() in these subclasses. And add support for the remaining widgets.
As Weston mentioned, the plugin already prevents scripts in: 'wp_print_footer_scripts'. Also, move the comment filter to a subclass of WP_Widget_Recent_Comments. Includes PHPUnit tests for all of these changes.
Only implement the render_media() function. @todo: filter the markup in it. This includes a PHPUnit test class for it, which will now fail.
Like the 'Gallery' widget, only implement the render_media(). @todo: filter markup. The test currently fails because of this.
A PHPUnit test fails, as it's not yet sanitized. It needs to have an <amp-video>, and remove the 'style' attribute.
Use AMP_Theme_Support::filter_the_content(). Still, I need to ensure that this is the best way to filter. Add RSS and Audio widget subclasses. And PHPUnit classes for these.
Props @westonruter for the details of how to do this. Mainly copy WP_Widget_Categories::widget() into the subclass widget(). Add an 'id' attribute to the <form>. And use the 'id' in the dropdown <select>. This dropdown now redirects to the category pages, as expected. Also, bootstrap the widget support class.
There was an error from the textdomain not being included. But it's copied from the WordPress widget, So it should use the default textdomain. Use @codingStandardsIgnoreLine in those cases. Also, call wp_maybe_load_widgets() in the test setUp(). This ensures that the core widgets are loaded.
…mains. In phpcs.xml, add 'default' And remove the @codingStandardsIgnoreLine tags.
On Weston's suggestion, simply point to the full documentation. Also, remove widgets from the function if they don't exist. As Weston mentioned, this applies especially to the media-* widgets.
The diff looks much bigger than it is. No change to the classes, they're just wrapped in a conditional. For WP version less than 4.9, The media widgets won't exist. Prevents an error in declaring the AMP widgets that extend them. This is the least inelegant solution I saw. Another option is conditionally loading the files in: widgets/class-amp-widgets.php.
Media widgets won't be declared on WP 4.8 and earlier. So don't test them. Simply mark them as skipped.
Props @westonruter for describing how to do this. Like before, it mainly copies WP_Widget_Archives::widget(). It adds an id to the <form>. And an 'on' attribute to the <select> element.
Before, I had registered this too late. Also, move is_amp_endpoint() conditional to widget(). This isn't ideal. But that function isn't available before 'parse_query.' And that runs after 'widgets_init.' Also, is seems that all but 2 of these subclass widgets will be removed. @todo: Look at a regression, where the 'amp-form' extension isn't included.
The widgets now exit from their methods is is_amp_endpoint(). So set this to true, with amp_theme_support( 'amp' ).
Before, this wasn't included via the sanitizer. The ideal solution would probably involve editing the sanitizer. But this adds a filter to add the 'amp-form.' And it removes the AMP sanitization of 'Categories' and 'Archives' widgets.
There were 2 files with conflicts, Retain both of the edits. They were merely from adding 2 different functions in the same place.
All Widgets Supported, But Gallery Widget Might Benefit From amp-carousel Hi @westonruter, But the 'Gallery' widget might be able to use an AMP_Gallery_Embed looks to convert 'gallery' shortcodes into |
There's an existing handler to create 'amp-carousel' elements: class AMP_Gallery_Embed_Handler. So override the 'Gallery' widget class. And use that in render_media(). Otherwise, that function is copied from the parent. The parent calls gallery_shortcode() at the end of render_media(). And that function doesn't have a filter for the markup.
Before, there was a workaround to ensure these didn't overflow. I added style="max-width:1005" This removes that workaround, And instead sets the layout to 'responsive.' Also, this updates the PHPUnit tests.
I had copied this line into the block above. But it's not needed there.
On Paul Baukus and Weston Ruter's suggestion. The sizes attribute isn't relevant to this WP plugin, as Paul Baukus mentioned.
This could lead to unexpected results. If the intended width or height is less than the container, This will increase it to fill the container. This fixed the issue of overflowing <ampiframe> in widgets. But it could create an issue in other places.
This was present earlier. Weston added this, and it describes where it will appear.
An earlier commit only prevented adding it. This removes the attribute it it's present.
Iframes from WordPress embeds usually have width and height. In AMP, the inferred value layout for this is fixed. This means that even if you apply max-width:100%, The height won't adjust to the new ratio. Setting the 'layout' to 'responsive' seems to be the only way to ensure the same aspect ratio. Of course, this has a risk that iframes will expand to fill their container, where they didn't before.
Request For QA Hi @csossi, The test site might not be the best place for this, as it'll distort the pages when we place 20-30 test widgets in the sidebar. We should run the widget test script on a site, as it will insert all of the needed widgets. As long as the site already has 3 videos and 3 audio files. |
Test Page Hi @csossi, Please verify these widgets:
|
verified in QA |
@kienstra could kindly update the list of widget supported now that the work is done. It would be great to have it in the WIKI and then change all instances of the tables to link to the wiki to avoid confusion. PS: this should apply to embeds too |
In the image preprocessor, Convert a 'data-amp-layout' attribute to 'layout.' As Weston mentioned, this won't change the styling on non-AMP pages, As the preprocessor won't modify them.
Add this attribute to the allowed list for <img>. The sanitizer now converts this to 'layout.'
Per feedback, this should apply to all contexts, As long as they allow <img> with a width and height. Uses Weston's snippet in the filter callback. @todo: move it to AMP_Theme_Support.
Also, remove $context_type parameter. It's no longer used. Otherwise, there's no change to the function.
Awesome, thanks @kienstra |
Acceptance criteria:
AC1: List the AMP support for all native WordPress widgets, as produced by the script in #839.
This from AC5 in #839:
AC5: One story will be created as an outcome of the Discovery to address enhanced/added support for sidebar widgets.
When AMP doesn't support a widget, either describe it in detail here, or open a sub-issue.
There doesn't seem to be an issue for this yet.
The text was updated successfully, but these errors were encountered: