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
8 changes: 8 additions & 0 deletions includes/actions/class-amp-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ 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 ) {}

/**
* Add AMP generator metadata.
*
* @param object $template AMP_Post_Template object.
* @since 0.6
*/
public static function add_generator_metadata( $template ) {}
}
13 changes: 13 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_generator_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,16 @@ public static function add_analytics_data( $amp_template ) {
echo AMP_HTML_Utils::build_tag( 'amp-analytics', $amp_analytics_attr, $script_element );
}
}

/**
* Add AMP generator metadata.
*
* @param object $amp_template AMP_Post_Template object.
* @since 0.6
*/
public static function add_generator_metadata( $amp_template ) {
?>
<meta name="generator" content="<?php echo esc_attr( $amp_template->get( 'generator_metadata' ) ); ?>" />
<?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' ),
'generator_metadata' => 'AMP Plugin v' . AMP__VERSION,

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