Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
95.45% |
21 / 22 |
|
100.00% |
1 / 1 |
CRAP | n/a |
0 / 0 |
|
| jetpack_canonical_urls_check_conflicts | |
100.00% |
19 / 19 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Conflict check for the Canonical URLs module, also loaded while the module is off (see module-extras.php). |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit( 0 ); |
| 10 | } |
| 11 | |
| 12 | // Disable canonical URL output when a conflicting SEO plugin is active. |
| 13 | add_filter( 'jetpack_disable_canonical_urls', 'jetpack_canonical_urls_check_conflicts' ); |
| 14 | |
| 15 | /** |
| 16 | * Check if a conflicting SEO plugin is active and disable canonical URL output. |
| 17 | * |
| 18 | * @since 15.6 |
| 19 | * |
| 20 | * @param bool $disabled Whether canonical URL output is already disabled. |
| 21 | * @return bool Whether canonical URL output should be disabled. |
| 22 | */ |
| 23 | function jetpack_canonical_urls_check_conflicts( $disabled ) { |
| 24 | // WordPress.com Simple's stub Jetpack class lacks this method, and Simple runs no plugins. |
| 25 | if ( $disabled || ! method_exists( 'Jetpack', 'is_plugin_active' ) ) { |
| 26 | return $disabled; |
| 27 | } |
| 28 | |
| 29 | $conflicting_plugins = array( |
| 30 | 'wordpress-seo/wp-seo.php', |
| 31 | 'wordpress-seo-premium/wp-seo-premium.php', |
| 32 | 'all-in-one-seo-pack/all_in_one_seo_pack.php', |
| 33 | 'all-in-one-seo-pack-pro/all_in_one_seo_pack.php', |
| 34 | 'seo-by-rank-math/rank-math.php', |
| 35 | 'autodescription/autodescription.php', |
| 36 | 'slim-seo/slim-seo.php', |
| 37 | 'wp-seopress/seopress.php', |
| 38 | 'wp-seopress-pro/seopress-pro.php', |
| 39 | 'seo-key/seo-key.php', |
| 40 | 'seo-key-pro/seo-key.php', |
| 41 | ); |
| 42 | |
| 43 | foreach ( $conflicting_plugins as $plugin ) { |
| 44 | if ( Jetpack::is_plugin_active( $plugin ) ) { |
| 45 | return true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return $disabled; |
| 50 | } |