diff --git a/modules/carousel/jetpack-carousel.php b/modules/carousel/jetpack-carousel.php index ea62aa17ec568..1542a2972d1d7 100644 --- a/modules/carousel/jetpack-carousel.php +++ b/modules/carousel/jetpack-carousel.php @@ -153,7 +153,10 @@ function display_bail_message( $output = '' ) { } function check_if_shortcode_processed_and_enqueue_assets( $output ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $output; } @@ -208,7 +211,10 @@ function check_if_shortcode_processed_and_enqueue_assets( $output ) { * @return string $content Post content. */ function check_content_for_blocks( $content ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $content; } @@ -354,7 +360,10 @@ function enqueue_assets() { } function set_in_gallery( $output ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $output; } $this->in_gallery = true; @@ -372,7 +381,10 @@ function set_in_gallery( $output ) { * @return string Modified HTML content of the post */ function add_data_img_tags_and_enqueue_assets( $content ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $content; } @@ -426,7 +438,10 @@ function add_data_img_tags_and_enqueue_assets( $content ) { } function add_data_to_images( $attr, $attachment = null ) { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $attr; } @@ -498,7 +513,10 @@ function add_data_to_images( $attr, $attachment = null ) { function add_data_to_container( $html ) { global $post; - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return $html; } diff --git a/modules/related-posts/jetpack-related-posts.php b/modules/related-posts/jetpack-related-posts.php index 842b6e636d34b..d1d4855f61bbe 100644 --- a/modules/related-posts/jetpack-related-posts.php +++ b/modules/related-posts/jetpack-related-posts.php @@ -1604,12 +1604,15 @@ protected function _log_click( $post_id, $to_post_id, $link_position ) { */ protected function _enabled_for_request() { $enabled = is_single() - && - ! is_admin() - && - ( !$this->_allow_feature_toggle() || $this->get_option( 'enabled' ) ) - && - ! Jetpack_AMP_Support::is_amp_request(); + && ! is_admin() + && ( ! $this->_allow_feature_toggle() || $this->get_option( 'enabled' ) ); + + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { + $enabled = false; + } /** * Filter the Enabled value to allow related posts to be shown on pages as well. diff --git a/modules/sharedaddy/sharing-service.php b/modules/sharedaddy/sharing-service.php index 756fa1d069f5e..7e453262338e3 100644 --- a/modules/sharedaddy/sharing-service.php +++ b/modules/sharedaddy/sharing-service.php @@ -575,7 +575,10 @@ function sharing_maybe_enqueue_scripts() { } function sharing_add_footer() { - if ( Jetpack_AMP_Support::is_amp_request() ) { + if ( + class_exists( 'Jetpack_AMP_Support' ) + && Jetpack_AMP_Support::is_amp_request() + ) { return; }