Skip to content

Commit 2a69d65

Browse files
committed
Check dependency_support in is_needed for AmpPlugins, AmpThemes, and PluginActivationSiteScan
1 parent 4cd08b2 commit 2a69d65

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/Admin/AmpPlugins.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use AmpProject\AmpWP\Infrastructure\Delayed;
1212
use AmpProject\AmpWP\Infrastructure\Registerable;
1313
use AmpProject\AmpWP\Infrastructure\Service;
14+
use AmpProject\AmpWP\Services;
1415
use WP_Screen;
1516
use function get_current_screen;
1617
use stdClass;
@@ -61,6 +62,10 @@ public static function get_registration_action() {
6162
*/
6263
public static function is_needed() {
6364

65+
if ( ! Services::get( 'dependency_support' )->has_support() ) {
66+
return false;
67+
}
68+
6469
/** This filter is documented in src/Admin/AmpThemes.php */
6570
return is_admin() && apply_filters( 'amp_compatible_ecosystem_shown', true, 'plugins' );
6671
}

src/Admin/AmpThemes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use AmpProject\AmpWP\Infrastructure\Delayed;
1212
use AmpProject\AmpWP\Infrastructure\Registerable;
1313
use AmpProject\AmpWP\Infrastructure\Service;
14+
use AmpProject\AmpWP\Services;
1415
use WP_Screen;
1516
use stdClass;
1617

@@ -60,6 +61,10 @@ public static function get_registration_action() {
6061
*/
6162
public static function is_needed() {
6263

64+
if ( ! Services::get( 'dependency_support' )->has_support() ) {
65+
return false;
66+
}
67+
6368
/**
6469
* Filters whether to show AMP compatible ecosystem in the admin.
6570
*

src/Admin/PluginActivationSiteScan.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
use AMP_Options_Manager;
1515
use AMP_Validation_Manager;
16-
use AmpProject\AmpWP\DevTools\UserAccess;
1716
use AmpProject\AmpWP\Infrastructure\Conditional;
1817
use AmpProject\AmpWP\Infrastructure\Delayed;
1918
use AmpProject\AmpWP\Infrastructure\Registerable;
2019
use AmpProject\AmpWP\Infrastructure\Service;
20+
use AmpProject\AmpWP\Services;
2121

2222
/**
2323
* Class PluginActivationSiteScan
@@ -67,6 +67,8 @@ public static function is_needed() {
6767
return (
6868
is_admin()
6969
&&
70+
Services::get( 'dependency_support' )->has_support()
71+
&&
7072
! is_network_admin()
7173
&&
7274
'plugins.php' === $pagenow

src/Admin/SupportScreen.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public static function is_needed() {
106106
return (
107107
is_admin()
108108
&&
109+
// Note: The view_site_health_checks capability was introduced in WordPress 5.2, so this will return false in older versions.
109110
self::has_cap()
110111
);
111112
}

0 commit comments

Comments
 (0)