Skip to content

Commit cb229b0

Browse files
authored
SEO: Report which conflicting SEO plugin owns the output (#53872)
* SEO: Report which conflicting SEO plugin owns the output The SEO module now names the plugin it steps aside for through a new jetpack_seo_conflicting_plugin filter, and the dashboard's Overview and Settings payloads carry that name so the screens can say who owns the output. * SEO: Name the conflicting plugin only while Jetpack steps aside Report the name only when jetpack_disable_seo_tools is on, so it can't contradict live output, and list paid editions before the free plugins they run alongside so the first match names the right one.
1 parent 6e23b1f commit cb229b0

13 files changed

Lines changed: 105 additions & 13 deletions

File tree

‎projects/packages/seo/_inc/data/overview-types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export interface OverviewResponse {
3333
plan: {
3434
seo_enabled_for_site: boolean;
3535
};
36+
// See `SettingsResponse['conflicting_seo_plugin']`.
37+
conflicting_seo_plugin: string;
3638
// Whether the site-verification module can be switched on this site. False on
3739
// WordPress.com Simple, which ships no Jetpack modules and reports every one of
3840
// them active, so the Settings tab hides that toggle.

‎projects/packages/seo/_inc/data/settings-types.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export interface SettingsResponse {
2525
// Server-owned conflict state. False keeps saved formats visible but read-only
2626
// and prevents them from being included in a save payload.
2727
title_formats_editable: boolean;
28+
// Name of the SEO plugin Jetpack stepped aside for, or '' when none is active.
29+
// Read-only, never sent back.
30+
conflicting_seo_plugin: string;
2831
verification_tools_active: boolean;
2932
verification: {
3033
google: string;

‎projects/packages/seo/_inc/data/test/build-payload.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const makeSettings = ( overrides: Partial< SettingsResponse > = {} ): SettingsRe
1111
title_formats: { posts: [ { type: 'token', value: 'site_name' } ] },
1212
title_separator: '-',
1313
title_formats_editable: true,
14+
conflicting_seo_plugin: '',
1415
verification_tools_active: true,
1516
verification: { google: '', bing: '', pinterest: '', yandex: '', facebook: '' },
1617
site_is_private: false,

‎projects/packages/seo/_inc/data/test/fixtures/store-fixtures.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const SEEDED_SETTINGS: SettingsResponse = {
2929
title_formats: {},
3030
title_separator: '-',
3131
title_formats_editable: true,
32+
conflicting_seo_plugin: '',
3233
verification_tools_active: true,
3334
verification: { google: '', bing: '', pinterest: '', yandex: '', facebook: '' },
3435
search_engines_visible: true,

‎projects/packages/seo/_inc/data/test/use-settings.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const SEED: SettingsResponse = {
2424
title_formats: { posts: [ { type: 'token', value: 'site_name' } ] },
2525
title_separator: '-',
2626
title_formats_editable: true,
27+
conflicting_seo_plugin: '',
2728
verification_tools_active: true,
2829
verification: { google: '', bing: '', pinterest: '', yandex: '', facebook: '' },
2930
search_engines_visible: true,

‎projects/packages/seo/_inc/screens/overview/test/index.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const buildOverview = (): OverviewResponse => ( {
5656
plan: {
5757
seo_enabled_for_site: true,
5858
},
59+
conflicting_seo_plugin: '',
5960
verification_switchable: true,
6061
} );
6162

‎projects/packages/seo/_inc/screens/settings/test/gated.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const buildForm = ( hasLegacy: boolean ): SettingsForm => {
5656
title_formats: {},
5757
title_separator: '-',
5858
title_formats_editable: true,
59+
conflicting_seo_plugin: '',
5960
verification_tools_active: true,
6061
verification: { google: '', bing: '', pinterest: '', yandex: '', facebook: '' },
6162
search_engines_visible: true,

‎projects/packages/seo/_inc/screens/settings/test/settings-screen.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const buildForm = ( overrides: Partial< SettingsResponse > = {} ): SettingsForm
6464
title_formats: {},
6565
title_separator: '-',
6666
title_formats_editable: true,
67+
conflicting_seo_plugin: '',
6768
verification_tools_active: true,
6869
verification: { ...EMPTY_VERIFICATION },
6970
search_engines_visible: false,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: added
3+
4+
Dashboard: Report which conflicting SEO plugin owns the site's SEO output, via the new `jetpack_seo_conflicting_plugin` filter.

‎projects/packages/seo/src/class-dashboard-data.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,30 @@ private static function is_jetpack_seo_enabled_without_helper() {
564564
return ( new Host() )->is_wpcom_simple() ? ! Initializer::is_gated() : true;
565565
}
566566

567+
/**
568+
* Name of the SEO plugin Jetpack stepped aside for, or '' when Jetpack's SEO output is live.
569+
*
570+
* @return string
571+
*/
572+
private static function get_conflicting_seo_plugin() {
573+
/** This filter is documented in projects/plugins/jetpack/modules/seo-tools/class-jetpack-seo-utils.php */
574+
if ( ! apply_filters( 'jetpack_disable_seo_tools', false ) ) {
575+
return '';
576+
}
577+
578+
/**
579+
* Names the SEO plugin that owns the site's SEO output, so the SEO dashboard can say
580+
* so. Only read while `jetpack_disable_seo_tools` is true.
581+
*
582+
* @since $$next-version$$
583+
*
584+
* @param string $name The plugin's display name, or '' when no plugin owns the output.
585+
*/
586+
$name = apply_filters( 'jetpack_seo_conflicting_plugin', '' );
587+
588+
return is_string( $name ) ? trim( $name ) : '';
589+
}
590+
567591
/**
568592
* Drop the superseded legacy front page description once a modern one is saved.
569593
*
@@ -1005,6 +1029,7 @@ public static function get_overview_data() {
10051029
'plan' => array(
10061030
'seo_enabled_for_site' => $seo_enabled,
10071031
),
1032+
'conflicting_seo_plugin' => self::get_conflicting_seo_plugin(),
10081033
// Whether the site-verification toggle can do anything here. False where
10091034
// that module isn't present — WordPress.com Simple ships no Jetpack modules
10101035
// and reports every one of them active — so the dashboard hides the control
@@ -1106,6 +1131,7 @@ public static function get_settings_data() {
11061131
// Settings tab replays that composition to preview it.
11071132
'title_separator' => self::get_default_title_separator(),
11081133
'title_formats_editable' => $title_formats_editable,
1134+
'conflicting_seo_plugin' => self::get_conflicting_seo_plugin(),
11091135
'front_page_description' => (string) $front_page_desc,
11101136
'has_legacy_front_page_meta' => $has_legacy_front_page_meta,
11111137
'verification_tools_active' => $modules->is_active( 'verification-tools' ),

0 commit comments

Comments
 (0)