Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions 3rd-party/class.jetpack-amp-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ 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' ) );

// Disable Comment Likes.
add_filter( 'jetpack_comment_likes_enabled', array( 'Jetpack_AMP_Support', 'comment_likes_enabled' ) );

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

// Remove the Likes button from the admin bar.
add_filter( 'jetpack_admin_bar_likes_enabled', array( 'Jetpack_AMP_Support', 'disable_likes_admin_bar' ) );

// Add post template metadata for legacy AMP.
add_filter( 'amp_post_template_metadata', array( 'Jetpack_AMP_Support', 'amp_post_template_metadata' ), 10, 2 );
Expand All @@ -52,19 +58,6 @@ public static function init() {

// Sync the amp-options.
add_filter( 'jetpack_options_whitelist', array( 'Jetpack_AMP_Support', 'filter_jetpack_options_whitelist' ) );

// 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();
}

/**
Expand Down Expand Up @@ -138,6 +131,18 @@ public static function disable_comment_likes_before_the_content( $content ) {
return $content;
}

/**
* Do not display the Likes' Admin bar on AMP requests.
*
* @param bool $is_admin_bar_button_visible Should the Like button be visible in the Admin bar. Default to true.
*/
public static function disable_likes_admin_bar( $is_admin_bar_button_visible ) {
if ( self::is_amp_request() ) {
return false;
}
return $is_admin_bar_button_visible;
}

/**
* Add Jetpack stats pixel.
*
Expand Down