Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 36
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Module Name: SEO Tools
4 * Module Description: Optimize titles, meta descriptions, and social previews for better search results.
5 * Sort Order: 35
6 * Recommendation Order: 15
7 * First Introduced: 4.4
8 * Requires Connection: No
9 * Requires User Connection: No
10 * Auto Activate: No
11 * Module Tags: Social, Appearance
12 * Feature: Traffic
13 * Additional Search Queries: search engine optimization, social preview, meta description, custom title format, seo, sitemap, open graph, search engine, title tag
14 *
15 * @package automattic/jetpack
16 */
17
18if ( ! defined( 'ABSPATH' ) ) {
19    exit( 0 );
20}
21
22// Suppress SEO Tools output if any of the following plugins is active. Paid editions come
23// before the free plugins they run alongside, so the first match names the right one.
24$jetpack_seo_conflicting_plugins = array(
25    'wordpress-seo-premium/wp-seo-premium.php'        => 'Yoast SEO Premium',
26    'wordpress-seo/wp-seo.php'                        => 'Yoast SEO',
27    'all-in-one-seo-pack-pro/all_in_one_seo_pack.php' => 'All in One SEO Pro',
28    'all-in-one-seo-pack/all_in_one_seo_pack.php'     => 'All in One SEO',
29    'seo-by-rank-math/rank-math.php'                  => 'Rank Math SEO',
30    'autodescription/autodescription.php'             => 'The SEO Framework',
31    'slim-seo/slim-seo.php'                           => 'Slim SEO',
32    'wp-seopress-pro/seopress-pro.php'                => 'SEOPress PRO',
33    'wp-seopress/seopress.php'                        => 'SEOPress',
34    'seo-key-pro/seo-key.php'                         => 'SEOKEY Pro',
35    'seo-key/seo-key.php'                             => 'SEOKEY',
36);
37
38foreach ( $jetpack_seo_conflicting_plugins as $seo_plugin => $seo_plugin_name ) {
39    if ( Jetpack::is_plugin_active( $seo_plugin ) ) {
40        // Also disable default meta tags.
41        add_filter( 'jetpack_seo_meta_tags_enabled', '__return_false' );
42
43        // Let the SEO dashboard name the plugin that now owns the output.
44        add_filter(
45            'jetpack_seo_conflicting_plugin',
46            static function () use ( $seo_plugin_name ) {
47                return $seo_plugin_name;
48            }
49        );
50        break;
51    }
52}
53
54// Preserve the general disable switch while deriving plugin conflicts from their own filter.
55add_filter(
56    'jetpack_disable_seo_tools',
57    static function ( $disabled ) {
58        /** This filter is documented in projects/packages/seo/src/class-seo-tools.php */
59        return $disabled || (bool) apply_filters( 'jetpack_seo_conflicting_plugin', null );
60    }
61);
62
63/** This filter is documented in modules/seo-tools/class-jetpack-seo-utils.php */
64if ( ! apply_filters( 'jetpack_disable_seo_tools', false ) ) {
65    require_once __DIR__ . '/seo-tools/class-jetpack-seo.php';
66    new Jetpack_SEO();
67
68    require_once __DIR__ . '/seo-tools/class-jetpack-seo-admin-columns.php';
69    Jetpack_SEO_Admin_Columns::init();
70}