Skip to content

Commit

Permalink
AMP compat: make sure Jetpack-only functions are ignored on wpcom (#1…
Browse files Browse the repository at this point in the history
…2053)

Merges r190357-wpcom

Update AMP compat file:

- Use correct constant name
- Add additional checks for Jetpack-only functions
  • Loading branch information
jeherve authored Apr 15, 2019
1 parent 2916d6b commit bd96880
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions 3rd-party/class.jetpack-amp-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ class Jetpack_AMP_Support {

static function init() {

// enable stats
if ( Jetpack::is_module_active( 'stats' ) ) {
// Add Stats tracking pixel on Jetpack sites when the Stats module is active.
if (
Jetpack::is_module_active( 'stats' )
&& ! ( defined( 'IS_WPCOM' ) && IS_WPCOM )
) {
add_action( 'amp_post_template_footer', array( 'Jetpack_AMP_Support', 'add_stats_pixel' ) );
}

Expand Down Expand Up @@ -53,7 +56,7 @@ static function is_amp_request() {
}

static function amp_disable_the_content_filters() {
if ( defined( 'WPCOM') && WPCOM ) {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
add_filter( 'videopress_show_2015_player', '__return_true' );
add_filter( 'protected_embeds_use_form_post', '__return_false' );
remove_filter( 'the_title', 'widont' );
Expand Down Expand Up @@ -213,7 +216,7 @@ static function staticize_subdomain( $domain ) {
* @return array Dimensions.
*/
static function extract_image_dimensions_from_getimagesize( $dimensions ) {
if ( ! ( defined('WPCOM') && WPCOM && function_exists( 'require_lib' ) ) ) {
if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'require_lib' ) ) ) {
return $dimensions;
}
require_lib( 'wpcom/imagesize' );
Expand All @@ -235,7 +238,10 @@ static function extract_image_dimensions_from_getimagesize( $dimensions ) {
}

static function amp_post_jetpack_og_tags() {
Jetpack::init()->check_open_graph();
if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
Jetpack::init()->check_open_graph();
}

if ( function_exists( 'jetpack_og_tags' ) ) {
jetpack_og_tags();
}
Expand Down

0 comments on commit bd96880

Please sign in to comment.