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

Added meta tag for identifying AMP pages generated by plugin #810

Merged
merged 7 commits into from
Dec 5, 2017
1 change: 1 addition & 0 deletions includes/actions/class-amp-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public static function add_schemaorg_metadata( $template ) {}
public static function add_analytics_scripts( $template ) {}
public static function add_analytics_data( $template ) {}
public static function add_canonical_link( $template ) {}
public static function add_generatedby_metadata( $template ) {}
}
7 changes: 7 additions & 0 deletions includes/actions/class-amp-paired-post-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class AMP_Paired_Post_Actions extends AMP_Actions {

public static function register_hooks() {
add_action( 'amp_post_template_head', 'AMP_Paired_Post_Actions::add_generatedby_metadata' );
add_action( 'amp_post_template_head', 'AMP_Paired_Post_Actions::add_title' );
add_action( 'amp_post_template_head', 'AMP_Paired_Post_Actions::add_canonical_link' );
add_action( 'amp_post_template_head', 'AMP_Paired_Post_Actions::add_scripts' );
Expand Down Expand Up @@ -104,4 +105,10 @@ public static function add_analytics_data( $amp_template ) {
echo AMP_HTML_Utils::build_tag( 'amp-analytics', $amp_analytics_attr, $script_element );
}
}

public static function add_generatedby_metadata( $amp_template ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix WPCS error (Squiz.Commenting.FunctionComment.Missing). Here is a draft:

/**
 * Add AMP generator metadata.
 *
 * @param object $amp_template AMP_Post_Template object.
 * @since 0.6
 */

?>
<meta name="generator" content="<?php echo esc_attr( $amp_template->get( 'generatedby_metadata' ) );?>" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix WPCS error (Squiz.PHP.EmbeddedPhp.SpacingBeforeClose).

<?php
}
}
1 change: 1 addition & 0 deletions includes/class-amp-post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function __construct( $post_id ) {
'canonical_url' => get_permalink( $post_id ),
'home_url' => home_url(),
'blog_name' => get_bloginfo( 'name' ),
'generatedby_metadata' => 'AMP Plugin v' . AMP__VERSION,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix WPCS error (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned).


'html_tag_attributes' => array(),
'body_class' => '',
Expand Down