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

Include opengraph/twitter metadata on AMP Story posts #13416

Merged

Conversation

westonruter
Copy link
Contributor

See #9730.

Changes proposed in this Pull Request:

  • In Allow plugins to add metadata to AMP Stories ampproject/amp-wp#2968 a new amp_story_head action was introduced for plugins to output additional page metadata on AMP Story posts. This action is functionally the same as wp_head and is analogous to the core embed_head action. This PR adds outputting of the jetpack_og_tags() on the amp_story post type which has a template which does the amp_story_head.
  • Additionally, on any AMP response this PR suppresses the HTML comments added before/after the metadata tags since the AMP plugin will re-order the nodes in the head for optimal performance, thus the comments would no longer appear before/after the tags.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • Existing part of Jetpack: opengraph.

Testing instructions:

  1. Do a build of the AMP plugin on the develop branch.
  2. Activate the AMP plugin and enable the Stories experience
  3. Enable the sharing module in Jetpack.
  4. Try publishing a Story.
  5. Verify that the expected meta tags are present:
7a8,23
> 	<meta property="og:type" content="article">
> 	<meta property="og:title" content="Bison">
> 	<meta property="og:url" content="https://wordpressdev.lndo.site/stories/bison-2/">
> 	<meta property="og:description" content="Bison">
> 	<meta property="article:published_time" content="2019-08-28T00:00:11+00:00">
> 	<meta property="article:modified_time" content="2019-09-03T18:01:03+00:00">
> 	<meta property="og:site_name" content="WordPressDevs">
> 	<meta property="og:image" content="https://wordpressdev.lndo.site/content/uploads/2019/08/American_bison_k5680-1-4.jpg">
> 	<meta property="og:image:width" content="1200">
> 	<meta property="og:image:height" content="783">
> 	<meta property="og:image:alt" content="Bizon!!">
> 	<meta property="og:locale" content="en_US">
> 	<meta name="twitter:text:title" content="Bison">
> 	<meta name="twitter:image" content="https://wordpressdev.lndo.site/content/uploads/2019/08/American_bison_k5680-1-4.jpg?w=640">
> 	<meta name="twitter:image:alt" content="Bizon!!">
> 	<meta name="twitter:card" content="summary_large_image">

Proposed changelog entry for your changes:

  • Include opengraph metadata to AMP Story posts.

@jetpackbot
Copy link

jetpackbot commented Sep 3, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: October 1, 2019.
Scheduled code freeze: September 24, 2019

Generated by 🚫 dangerJS against 248914d

@jeherve jeherve added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it AMP [Feature] Sharing Post sharing, sharing buttons labels Sep 4, 2019
@@ -657,6 +657,7 @@ private function __construct() {
* They check for external files or plugins, so they need to run as late as possible.
*/
add_action( 'wp_head', array( $this, 'check_open_graph' ), 1 );
add_action( 'amp_story_head', array( $this, 'check_open_graph' ),1 );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
add_action( 'amp_story_head', array( $this, 'check_open_graph' ),1 );
add_action( 'amp_story_head', array( $this, 'check_open_graph' ), 1 );

Copy link
Contributor Author

@westonruter westonruter Sep 4, 2019

Choose a reason for hiding this comment

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

Oops.

But I just realized that if this is applied, then the result would not be aligned:

		add_action( 'wp_head', array( $this, 'check_open_graph' ),       1 );
		add_action( 'amp_story_head', array( $this, 'check_open_graph' ), 1 );
		add_action( 'plugins_loaded', array( $this, 'check_twitter_tags' ),     999 );
		add_action( 'plugins_loaded', array( $this, 'check_rest_api_compat' ), 1000 );

So I just went ahead and removed the alignment: 2351a5a

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Sep 4, 2019
@jeherve
Copy link
Member

jeherve commented Sep 4, 2019

This should be okay short of a minor nitpick.

@jeherve jeherve added this to the 7.8 milestone Sep 4, 2019
@westonruter westonruter force-pushed the add/amp-story-opengraph-support branch from 1ee745d to 2351a5a Compare September 4, 2019 14:18
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Sep 4, 2019
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello westonruter! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D32475-code before merging this PR. Thank you!

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Had to rebase. Still works well. Merging.

jeherve added a commit that referenced this pull request Sep 20, 2019
jeherve added a commit that referenced this pull request Sep 24, 2019
jeherve added a commit that referenced this pull request Sep 24, 2019
* Changelog: initial set of changes for 7.8

* Changelog: add #13310

* Changelog: add #13103

* Changelog: add #13426

* Changelog: add #13389

* Changelog: add #13449

* Changelog: add #13461

* Changelog: add #13460

* Changelog: add #13441

* Changelog: add #13454

* Changelog: add #13457

* Changelog: add #13425

* Changelog: add #13473

* Changelog: add #13355

* Changelog: add #13451

* Changelog: add #13358

* Changelog: add #13464

* Changelog: add #13416

* Changelog: add #13494

* Changelog: add #13465

* Changelog: add #13424

* Changelog: add #13432

* Changelog: add #13471

* Changelog: add 7.7.2 entry

* Changelog: add #13446

* Add more testing elements
jeherve added a commit that referenced this pull request Sep 24, 2019
* Changelog: initial set of changes for 7.8

* Changelog: add #13310

* Changelog: add #13103

* Changelog: add #13426

* Changelog: add #13389

* Changelog: add #13449

* Changelog: add #13461

* Changelog: add #13460

* Changelog: add #13441

* Changelog: add #13454

* Changelog: add #13457

* Changelog: add #13425

* Changelog: add #13473

* Changelog: add #13355

* Changelog: add #13451

* Changelog: add #13358

* Changelog: add #13464

* Changelog: add #13416

* Changelog: add #13494

* Changelog: add #13465

* Changelog: add #13424

* Changelog: add #13432

* Changelog: add #13471

* Changelog: add 7.7.2 entry

* Changelog: add #13446

* Add more testing elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AMP [Feature] Sharing Post sharing, sharing buttons Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants