Skip to content
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

AMP: check if the class exists before to use it #12139

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
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
30 changes: 24 additions & 6 deletions modules/carousel/jetpack-carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
15 changes: 9 additions & 6 deletions modules/related-posts/jetpack-related-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down