Skip to content

Commit 45d7b03

Browse files
committed
Likes: do not load Likes in admin bar on AMP views
1 parent f5333e5 commit 45d7b03

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

3rd-party/class.jetpack-amp-support.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ public static function init() {
4141
// Post rendering changes for legacy AMP.
4242
add_action( 'pre_amp_render_post', array( 'Jetpack_AMP_Support', 'amp_disable_the_content_filters' ) );
4343

44+
// Disable Comment Likes.
45+
add_filter( 'jetpack_comment_likes_enabled', array( 'Jetpack_AMP_Support', 'comment_likes_enabled' ) );
46+
4447
// Transitional mode AMP should not have comment likes.
45-
add_action( 'the_content', array( 'Jetpack_AMP_Support', 'disable_comment_likes_before_the_content' ) );
48+
add_filter( 'the_content', array( 'Jetpack_AMP_Support', 'disable_comment_likes_before_the_content' ) );
49+
50+
// Remove the Likes button from the admin bar.
51+
add_filter( 'jetpack_admin_bar_likes_enabled', array( 'Jetpack_AMP_Support', 'disable_likes_admin_bar' ) );
4652

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

5359
// Sync the amp-options.
5460
add_filter( 'jetpack_options_whitelist', array( 'Jetpack_AMP_Support', 'filter_jetpack_options_whitelist' ) );
55-
56-
// Disable Comment Likes.
57-
add_filter( 'jetpack_comment_likes_enabled', array( 'Jetpack_AMP_Support', 'comment_likes_enabled' ) );
5861
}
5962

6063
/**
@@ -128,6 +131,18 @@ public static function disable_comment_likes_before_the_content( $content ) {
128131
return $content;
129132
}
130133

134+
/**
135+
* Do not display the Likes' Admin bar on AMP requests.
136+
*
137+
* @param bool $is_admin_bar_button_visible Should the Like button be visible in the Admin bar. Default to true.
138+
*/
139+
public static function disable_likes_admin_bar( $is_admin_bar_button_visible ) {
140+
if ( self::is_amp_request() ) {
141+
return false;
142+
}
143+
return $is_admin_bar_button_visible;
144+
}
145+
131146
/**
132147
* Add Jetpack stats pixel.
133148
*

0 commit comments

Comments
 (0)