Skip to content
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

Improve handling of WordPress post embeds #6665

Merged
merged 41 commits into from
Mar 3, 2022

Conversation

bartoszgadomski
Copy link
Contributor

@bartoszgadomski bartoszgadomski commented Oct 27, 2021

Summary

Fixes #809

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@bartoszgadomski
Copy link
Contributor Author

You can refer to the AMP_Post_Embed_Handler class in this closed PR: #914.

What about the #3465? I used the includes/embeds/class-amp-wordpress-embed-handler.php class from that PR and it suppose to work when the bento-wordpress-embed experiment is enabled.

The only issue I see now is that the <amp-wordpress-embed> element is rendered with default height of 200px - is that expected behaviour? Should this "expand" button persist or instead the element should increase it's height as soon as it receives the message from the origin?

Screen.recording.2021-10-29.at.14.39.57.mov

@westonruter
Copy link
Member

Oh yeah. I forgot about #3465.

it suppose to work when the bento-wordpress-embed experiment is enabled.

Oh, I didn't realize that the experiment was still required to be enabled. That means we'll need to wait on merging this.

The only issue I see now is that the <amp-wordpress-embed> element is rendered with default height of 200px - is that expected behaviour? Should this "expand" button persist or instead the element should increase it's height as soon as it receives the message from the origin?

This is expected, yes. It's to avoid layout shifting. You should see that it expands to its full height if it is below the initial viewport when the page loads. But if it is in the first viewport, then the Expand button is shown to have the user explicitly opt-in to a layout shift. Ideally we would set the height to be as close to what it will end up being, but this is very hard if not impossible to do.

@bartoszgadomski
Copy link
Contributor Author

This is expected, yes. It's to avoid layout shifting.

Great, I tested this and yes indeed the "expand" button is not shown if the <amp-wordpress-embed> element is out of the viewport.

I just added the tests for the AMP_WordPress_Embed_Handler class, so I believe this is ready for review.

Also, tagging this PR as "blocked" due to bento-wordpress-embed experiment requirement.

@bartoszgadomski bartoszgadomski marked this pull request as ready for review November 9, 2021 12:53
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2021

Plugin builds for 73b4305 are ready 🛎️!

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few suggestions.

includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
includes/embeds/class-amp-wordpress-embed-handler.php Outdated Show resolved Hide resolved
@bartoszgadomski
Copy link
Contributor Author

Thanks @westonruter - changes applied 👍

…andle-wp-post-embeds

* 'develop' of github.com:ampproject/amp-wp: (328 commits)
  Set npm to be less than v7 in engines
  Downgrade to lockfileVersion 1
  Update Gutenberg package dependencies
  Revert package-lock.json lockfileVersion to 1
  Update amphtml spec to 2110290545003
  Update Gutenberg package dependencies
  Use method instead of closure
  Add assertions and skip others not supported in WP<5.2
  Polyfill wp_body_open()
  Add test for wp_editor() and translations script attributions
  Remove obsolete Gutenberg test workaround
  Fix use of dependencies arg in find_done_dependent_handles
  Remove extraneous _WP_Editors checks
  Factor out some common logic
  Add indirect sources for inline scripts added by wp_editor()
  Add sourcing for inline scripts which are registered in core but enqueued by themes/plugins
  Add sourcing for script translation scripts
  Remove debug code
  WIP: Obtain sourcing for wp_editor() calls
  Remove obsolete constant check now that PHP 5.6 is minimum
  ...
@westonruter westonruter added this to the v2.2 milestone Nov 13, 2021
@westonruter
Copy link
Member

Opened PR to remove experiment from amp-wordpress-embed: ampproject/amphtml#37237

@westonruter westonruter modified the milestones: v2.3, v2.2.2 Feb 9, 2022
@westonruter westonruter self-assigned this Feb 24, 2022
…andle-wp-post-embeds

* 'develop' of github.com:ampproject/amp-wp: (505 commits)
  Remove duplicated appending of button to body
  Reuse strings from twentytwentyone
  Recognize the default amp-dark-mode class name
  Add test for data-prefers-dark-mode-class
  Bump eslint-plugin-react from 7.28.0 to 7.29.2
  Improve test coverage and account for fact that button is always initially omitted
  Limit selector replacement to when respect_user_color_preference enabled
  Bump eslint from 8.9.0 to 8.10.0
  Utilize node-version-file
  Bump actions/setup-node from 2 to 3.0.0
  Bump postcss from 8.4.6 to 8.4.7
  Bump sirbrillig/phpcs-variable-analysis from 2.11.2 to 2.11.3
  Bump php-stubs/wordpress-stubs from 5.9.0 to 5.9.1
  Update Gutenberg package dependencies
  Update unit test case
  Remove replacing of .is-dark-theme.is-dark-theme with body.is-dark-theme selector
  Bump eslint-plugin-jsdoc from 37.9.1 to 37.9.4
  Bump postcss-preset-env from 7.4.0 to 7.4.1
  Bump @babel/core from 7.17.4 to 7.17.5
  Bump postcss-preset-env from 7.3.3 to 7.4.0
  ...
…andle-wp-post-embeds

* 'develop' of github.com:ampproject/amp-wp:
  Prevent copying PHP files from `src/` into `assets/`
  Bump eslint-plugin-jsdoc from 37.9.4 to 37.9.5
@@ -832,6 +832,9 @@ public function test_process_archives_widgets() {
public function test_process_text_widgets() {
$instance_count = 2;

// Make sure the video shortcode is registered.
add_shortcode( 'video', 'wp_video_shortcode' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this all of a sudden is needed for the tests to pass.

@westonruter westonruter merged commit 6035d35 into develop Mar 3, 2022
@westonruter westonruter deleted the fix/809-handle-wp-post-embeds branch March 3, 2022 01:23
westonruter added a commit that referenced this pull request Mar 3, 2022
Co-authored-by: Bartosz Gadomski <kontakt@bartoszgadomski.pl>
@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. Embeds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handling of WordPress post embeds
2 participants