From 2a4a646b7baab327489174fae8fc61341305275f Mon Sep 17 00:00:00 2001 From: Michael Torbert Date: Tue, 11 Oct 2016 11:21:00 -0400 Subject: [PATCH] remove schema if AMP plugin is detected #575 --- modules/aioseop_opengraph.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/aioseop_opengraph.php b/modules/aioseop_opengraph.php index 942048a19..aa091ff6f 100644 --- a/modules/aioseop_opengraph.php +++ b/modules/aioseop_opengraph.php @@ -132,7 +132,7 @@ function __construct() { $this->help_anchors = Array( 'title_shortcodes' => '#run-shortcodes-in-title', - 'description_shortcodes' => '#run-shortcodes-in-description', + 'description_shortcodes' => '#run-shortcodes-in-description', 'generate_descriptions' => '#auto-generate-og-descriptions', 'setmeta' => '#use-aioseo-title-and-description', 'sitename' => '#site-name', @@ -179,7 +179,7 @@ function __construct() { 'section' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#article-section', 'tag' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#article-tags', 'setcard' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#twitter-card-type', - 'customimg_twitter' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#custom-twitter-image', + 'customimg_twitter' => 'https://semperplugins.com/documentation/social-meta-settings-individual-pagepost-settings/#custom-twitter-image', ); $count_desc = __( " characters. Open Graph allows up to a maximum of %s chars for the %s.", 'all-in-one-seo-pack' ); @@ -797,11 +797,17 @@ function add_attributes( $output ) { // avoid having duplicate meta tags $type = 'WebSite'; } - $attributes = apply_filters( $this->prefix . 'attributes', Array( - 'itemscope', - 'itemtype="http://schema.org/' . ucfirst( $type ) . '"', - 'prefix="og: http://ogp.me/ns#"', - ) ); + $attr_array = Array(); + + // Don't show this schema.org if the AMP plugin is active. + if ( ! function_exists( 'amp_init' ) ) { + $attr_array[] = 'itemscope'; + $attr_array[] = 'itemtype="http://schema.org/' . ucfirst( $type ) . '"'; + } + + $attr_array[] = 'prefix="og: http://ogp.me/ns#"'; + + $attributes = apply_filters( $this->prefix . 'attributes', $attr_array ); foreach ( $attributes as $attr ) { if ( strpos( $output, $attr ) === false ) { $output .= "\n\t$attr ";