| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin |
| 6 |
* @since 1.7.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
use Yoast\WP\SEO\Config\Conflicting_Plugins; |
| 10 |
|
| 11 |
/** |
| 12 |
* Contains list of conflicting plugins. |
| 13 |
*/ |
| 14 |
class WPSEO_Plugin_Conflict extends Yoast_Plugin_Conflict { |
| 15 |
|
| 16 |
/** |
| 17 |
* The plugins must be grouped per section. |
| 18 |
* |
| 19 |
* It's possible to check for each section if there are conflicting plugin. |
| 20 |
* |
| 21 |
* NOTE: when changing this array, be sure to update the array in Conflicting_Plugins_Service too. |
| 22 |
* |
| 23 |
* @var array<string, array<string>> |
| 24 |
*/ |
| 25 |
protected $plugins = [ |
| 26 |
// The plugin which are writing OG metadata. |
| 27 |
'open_graph' => Conflicting_Plugins::OPEN_GRAPH_PLUGINS, |
| 28 |
'xml_sitemaps' => Conflicting_Plugins::XML_SITEMAPS_PLUGINS, |
| 29 |
'cloaking' => Conflicting_Plugins::CLOAKING_PLUGINS, |
| 30 |
'seo' => Conflicting_Plugins::SEO_PLUGINS, |
| 31 |
]; |
| 32 |
|
| 33 |
/** |
| 34 |
* Overrides instance to set with this class as class. |
| 35 |
* |
| 36 |
* @param string $class_name Optional class name. |
| 37 |
* |
| 38 |
* @return Yoast_Plugin_Conflict |
| 39 |
*/ |
| 40 |
public static function get_instance( $class_name = self::class ) { |
| 41 |
return parent::get_instance( $class_name ); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* After activating any plugin, this method will be executed by a hook. |
| 46 |
* |
| 47 |
* If the activated plugin is conflicting with ours a notice will be shown. |
| 48 |
* |
| 49 |
* @param string|bool $plugin Optional plugin basename to check. |
| 50 |
* |
| 51 |
* @return void |
| 52 |
*/ |
| 53 |
public static function hook_check_for_plugin_conflicts( $plugin = false ) { |
| 54 |
// The instance of the plugin. |
| 55 |
$instance = self::get_instance(); |
| 56 |
|
| 57 |
// Only add the plugin as an active plugin if $plugin isn't false. |
| 58 |
if ( $plugin && is_string( $plugin ) ) { |
| 59 |
$instance->add_active_plugin( $instance->find_plugin_category( $plugin ), $plugin ); |
| 60 |
} |
| 61 |
|
| 62 |
$plugin_sections = []; |
| 63 |
|
| 64 |
// Only check for open graph problems when they are enabled. |
| 65 |
if ( WPSEO_Options::get( 'opengraph' ) ) { |
| 66 |
/* translators: %1$s expands to Yoast SEO, %2$s: 'Facebook' plugin name of possibly conflicting plugin with regard to creating OpenGraph output. */ |
| 67 |
$plugin_sections['open_graph'] = __( 'Both %1$s and %2$s create Open Graph output, which might make Facebook, X, LinkedIn and other social networks use the wrong texts and images when your pages are being shared.', 'wordpress-seo' ) |
| 68 |
. '<br/><br/>' |
| 69 |
. '<a class="button" href="' . admin_url( 'admin.php?page=wpseo_page_settings#/site-features#card-wpseo_social-opengraph' ) . '">' |
| 70 |
/* translators: %1$s expands to Yoast SEO. */ |
| 71 |
. sprintf( __( 'Configure %1$s\'s Open Graph settings', 'wordpress-seo' ), 'Yoast SEO' ) |
| 72 |
. '</a>'; |
| 73 |
} |
| 74 |
|
| 75 |
// Only check for XML conflicts if sitemaps are enabled. |
| 76 |
if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) { |
| 77 |
/* translators: %1$s expands to Yoast SEO, %2$s: 'Google XML Sitemaps' plugin name of possibly conflicting plugin with regard to the creation of sitemaps. */ |
| 78 |
$plugin_sections['xml_sitemaps'] = __( 'Both %1$s and %2$s can create XML sitemaps. Having two XML sitemaps is not beneficial for search engines and might slow down your site.', 'wordpress-seo' ) |
| 79 |
. '<br/><br/>' |
| 80 |
. '<a class="button" href="' . admin_url( 'admin.php?page=wpseo_page_settings#/site-features#card-wpseo-enable_xml_sitemap' ) . '">' |
| 81 |
/* translators: %1$s expands to Yoast SEO. */ |
| 82 |
. sprintf( __( 'Toggle %1$s\'s XML Sitemap', 'wordpress-seo' ), 'Yoast SEO' ) |
| 83 |
. '</a>'; |
| 84 |
} |
| 85 |
|
| 86 |
/* translators: %2$s expands to 'RS Head Cleaner' plugin name of possibly conflicting plugin with regard to differentiating output between search engines and normal users. */ |
| 87 |
$plugin_sections['cloaking'] = __( 'The plugin %2$s changes your site\'s output and in doing that differentiates between search engines and normal users, a process that\'s called cloaking. We highly recommend that you disable it.', 'wordpress-seo' ); |
| 88 |
|
| 89 |
/* translators: %1$s expands to Yoast SEO, %2$s: 'SEO' plugin name of possibly conflicting plugin with regard to the creation of duplicate SEO meta. */ |
| 90 |
$plugin_sections['seo'] = __( 'Both %1$s and %2$s manage the SEO of your site. Running two SEO plugins at the same time is detrimental.', 'wordpress-seo' ); |
| 91 |
|
| 92 |
$instance->check_plugin_conflicts( $plugin_sections ); |
| 93 |
} |
| 94 |
} |
| 95 |
|