-
Notifications
You must be signed in to change notification settings - Fork 384
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vaporwavre I think it may be better to add a function that outputs the new meta tag at the amp_post_template_head
action. This will “guarantee” that the meta tag will be added to Custom Templates, as they are required to do this action: https://github.com/Automattic/amp-wp#custom-template
The Travis build is failing because the commit lacks spaces around the parameters in the function call, and this is required by WordPress Coding Standards.
…_template_head action Issue ampproject#807
Regarding Travis errors, I've corrected the SpacingBeforeClose error locally, but why am I getting the FunctionComment.Missing errors? I see no function documentation comments for the other functions in those files. |
@vaporwavre the For what to include in phpDoc, see https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vaporwavre I would advise to change all instances of generatedby
with generator
(ex. add_generatedby_metadata
vs add_generator_metadata
).
It seems like you don't have the dev-lib
pre-commit hook installed on your machine, it would be helpful to add in order to validate WPCS before pushing commits to avoid Travis build from failing. More info here.
Thanks,
@@ -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 ) { |
There was a problem hiding this comment.
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
*/
|
||
public static function add_generatedby_metadata( $amp_template ) { | ||
?> | ||
<meta name="generator" content="<?php echo esc_attr( $amp_template->get( 'generatedby_metadata' ) );?>" /> |
There was a problem hiding this comment.
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
).
includes/class-amp-post-template.php
Outdated
@@ -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, |
There was a problem hiding this comment.
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
).
Fix WPCS error (Squiz.PHP.EmbeddedPhp.SpacingBeforeClose) Fix WPCS error (WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned)
…owNotAligned) Fix WPCS error (Squiz.Commenting.FunctionComment.Missing)
Thanks for your contribution @vaporwavre, I see that the build is still failing. For it to pass, you will have to add PHPDoc here and align all array operators here (this will need slight refactoring). Please don't hesitate to ask if you need a hand with that, I am happy to help out with the final touches if you would prefer to 😄 |
Sorry, I couldn't get pre-commit to work locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @vaporwavre, this is good to go.
Fixes #807.