Skip to content

Commit

Permalink
Add a function that outputs the generated by meta tag at the amp_post…
Browse files Browse the repository at this point in the history
…_template_head action

Issue ampproject#807
  • Loading branch information
vaporwavre committed Nov 23, 2017
1 parent 25508a1 commit 5089b23
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion back-compat/templates-v0-3/single.php
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<meta name="generator" content="<?php echo esc_attr('AMP Plugin v' . AMP__VERSION);?>" />
<?php do_action( 'amp_post_template_head', $this ); ?>

<style amp-custom>
Expand Down
1 change: 1 addition & 0 deletions includes/actions/class-amp-actions.php
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
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 ) {
?>
<meta name="generator" content="<?php echo esc_attr( $amp_template->get( 'generatedby_metadata' ) );?>" />
<?php
}
}
1 change: 1 addition & 0 deletions includes/class-amp-post-template.php
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,

'html_tag_attributes' => array(),
'body_class' => '',
Expand Down
1 change: 0 additions & 1 deletion templates/single.php
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<meta name="generator" content="<?php echo esc_attr('AMP Plugin v' . AMP__VERSION);?>" />
<?php do_action( 'amp_post_template_head', $this ); ?>
<style amp-custom>
<?php $this->load_parts( array( 'style' ) ); ?>
Expand Down

0 comments on commit 5089b23

Please sign in to comment.