PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-backup/src/abilities/class-backup-abilities.php +13 -14 16.2 → 16.3 View file →
@@ -16,8 +16,12 @@
16 16 use Automattic\Jetpack\WP_Abilities\Registrar;
17 17 use WP_Error;
18 18 use WP_REST_Response;
19 19
20 +if ( ! defined( 'ABSPATH' ) ) {
21 + exit( 0 );
22 +}
23 +
20 24 /**
21 25 * Registers Jetpack Backup abilities with the WordPress Abilities API.
22 26 *
23 27 * Exposes a small, agent-friendly surface for site backups:
@@ -58,10 +62,9 @@
58 62
59 63 /**
60 64 * Override the Registrar lifecycle so the backup abilities only register
61 65 * on sites that actually have a Jetpack Backup product provisioned.
62 - * Mirrors the gating done in the Jetpack dashboard / My Jetpack — there's
63 - * no point exposing tool surfaces an agent can never use, and on free
66 + * There's no point exposing tool surfaces an agent can never use, and on free
64 67 * sites the upstream wpcom endpoints either silently accept writes (e.g.
65 68 * `request-backup` reported `enqueued: true`) or return null payloads
66 69 * that confuse callers.
67 70 *
@@ -92,18 +95,12 @@
92 95
93 96 /**
94 97 * Is the Jetpack Backup product actually loaded on this site?
95 98 *
96 - * Defaults to `My_Jetpack\Products\Backup::is_active()` — the same
97 - * boolean the Jetpack dashboard uses to decide whether the Backup
98 - * product is usable. That returns true when the plugin is active and
99 - * the site has a Backup plan (covering `STATUS_ACTIVE`,
100 - * `STATUS_EXPIRING_SOON`, and the `STATUS_NEEDS_ATTENTION__*` states),
101 - * and false for `STATUS_EXPIRED`, `STATUS_NEEDS_PLAN`,
102 - * `STATUS_MODULE_DISABLED`, and the connection-error states. The plan
103 - * lookup is cached for 15s in `MY_JETPACK_SITE_FEATURES_TRANSIENT_KEY`,
104 - * so the cost on a real wpcom call is paid at most once per 15 seconds
105 - * across the whole My Jetpack surface.
99 + * True when a plugin that ships Backup is active and the site has a Backup plan. Deliberately
100 + * not `My_Jetpack\Products\Backup::is_active()`: that also follows the backup module, which only
101 + * switches the wp-admin dashboard, while backups keep running on WordPress.com. The plan lookup
102 + * is cached in `MY_JETPACK_SITE_FEATURES_TRANSIENT_KEY`.
106 103 *
107 104 * The `jetpack_backup_abilities_should_load` filter lets consumers and
108 105 * tests override the answer without round-tripping through the My
109 106 * Jetpack product class.
@@ -110,13 +107,15 @@
110 107 *
111 108 * @return bool
112 109 */
113 110 private static function backup_is_loaded(): bool {
114 - $default = class_exists( My_Jetpack_Backup::class ) && My_Jetpack_Backup::is_active();
111 + $default = class_exists( My_Jetpack_Backup::class )
112 + && My_Jetpack_Backup::is_plugin_active()
113 + && My_Jetpack_Backup::has_any_plan_for_product();
115 114
116 115 /**
117 116 * Filters whether the Jetpack Backup abilities should register on
118 - * this site. Defaults to `My_Jetpack\Products\Backup::is_active()`.
117 + * this site. Defaults to whether Backup's plugin is active and the site has a Backup plan.
119 118 *
120 119 * @since 0.1.0
121 120 *
122 121 * @param bool $should_load Whether to register the backup abilities.