Skip to content

Commit

Permalink
AMP: fix linting issues introduced in D38340
Browse files Browse the repository at this point in the history
Summary:
The file is synced with Jetpack, and D38340 cannot be merged into Jetpack as is as it introduces changes that will not pass our pre-commit hook.
This diff fixes all PHPCS warnings.
Test Plan: * Not much to test here, this only impacts documentation / comments.
Reviewers: goldsounds
Tags: #touches_jetpack_files

Differential Revision: D39590

This commit syncs r r203555-wpcom.
  • Loading branch information
jeherve committed Feb 28, 2020
1 parent f0c187e commit cc06218
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions 3rd-party/class.jetpack-amp-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function init() {
// Post rendering changes for legacy AMP.
add_action( 'pre_amp_render_post', array( 'Jetpack_AMP_Support', 'amp_disable_the_content_filters' ) );

// Transitional mode AMP should not have comment likes
// Transitional mode AMP should not have comment likes.
add_action( 'the_content', array( 'Jetpack_AMP_Support', 'disable_comment_likes_before_the_content' ) );

// Add post template metadata for legacy AMP.
Expand All @@ -53,15 +53,25 @@ public static function init() {
// Sync the amp-options.
add_filter( 'jetpack_options_whitelist', array( 'Jetpack_AMP_Support', 'filter_jetpack_options_whitelist' ) );

// Show admin bar
// Show admin bar.
add_filter( 'show_admin_bar', array( 'Jetpack_AMP_Support', 'show_admin_bar' ) );
add_filter( 'jetpack_comment_likes_enabled', array( 'Jetpack_AMP_Support', 'comment_likes_enabled' ) );
}

/**
* Disable the admin bar on AMP views.
*
* @param Whether bool $show the admin bar should be shown. Default false.
*/
public static function show_admin_bar( $show ) {
return $show && ! self::is_amp_request();
}

/**
* Disable the Comment Likes feature on AMP views.
*
* @param bool $enabled Should comment likes be enabled.
*/
public static function comment_likes_enabled( $enabled ) {
return $enabled && ! self::is_amp_request();
}
Expand Down Expand Up @@ -116,6 +126,11 @@ public static function amp_disable_the_content_filters() {
remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ), 100 );
}

/**
* Do not add comment likes on AMP requests.
*
* @param string $content Post content.
*/
public static function disable_comment_likes_before_the_content( $content ) {
if ( self::is_amp_request() ) {
remove_filter( 'comment_text', 'comment_like_button', 12, 2 );
Expand Down

0 comments on commit cc06218

Please sign in to comment.