PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
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 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-admin-ui/src/class-admin-menu.php +33 -25 16.3-a.3 → 16.3-beta View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Admin_UI;
9 9
10 +use Automattic\Jetpack\Feature_Policy;
10 11 use Automattic\Jetpack\Tracking;
11 12 use Jetpack_Options;
12 13 use Jetpack_Tracks_Client;
13 14
@@ -16,9 +17,9 @@
16 17 * If the Jetpack top level was not previously registered by other plugin, it will be registered here.
17 18 */
18 19 class Admin_Menu {
19 20
20 - const PACKAGE_VERSION = '0.13.0';
21 + const PACKAGE_VERSION = '0.14.3';
21 22
22 23 /**
23 24 * Slug used for the upgrade menu item and redirect URL.
24 25 *
@@ -96,13 +97,11 @@
96 97 self::POSITION_LAST,
97 98 );
98 99
99 100 /**
100 - * Handle for the shared, token-only WPDS design-tokens stylesheet.
101 + * Handle for the bundled WPDS design-tokens stylesheet.
101 102 *
102 - * Registered once and enqueued on every Jetpack admin page so that
103 - * `var(--wpds-*)` values resolve at runtime instead of falling back to
104 - * their hand-written hex defaults.
103 + * Fallback when Core/Gutenberg has not registered the `wp-theme` style.
105 104 *
106 105 * @var string
107 106 */
108 107 const DESIGN_TOKENS_HANDLE = 'jetpack-admin-ui-design-tokens';
@@ -472,21 +471,24 @@
472 471 self::$menu_items[] = compact( 'page_title', 'menu_title', 'capability', 'menu_slug', 'function', 'position', 'args' );
473 472
474 473 /**
475 474 * Let's return the page hook so consumers can use.
476 - * We know all pages will be under Jetpack top level menu page, so we can hardcode the first part of the string.
475 + * Pages normally sit under the Jetpack top level menu page, so we can hardcode the first part of the string.
477 476 * Using get_plugin_page_hookname here won't work because the top level page is not registered yet.
478 477 */
479 478 $hook = 'jetpack_page_' . $menu_slug;
480 479
481 - // Track the page hook so the design-tokens stylesheet can be scoped to it.
482 - self::$page_hooks[] = $hook;
480 + // Core names the page admin_page_<slug> instead when the user has no Jetpack top-level menu.
481 + foreach ( array( $hook, 'admin_page_' . $menu_slug ) as $page_hook ) {
482 + // Track the page hook so the design-tokens stylesheet can be scoped to it.
483 + self::$page_hooks[] = $page_hook;
483 484
484 - // Hide WordPress core admin notices on this Jetpack page. The load-<hook>
485 - // action only fires when the matching screen is being rendered, so this
486 - // stays scoped to Jetpack pages and reaches every page registered here.
487 - add_action( 'load-' . $hook, array( __CLASS__, 'hide_core_admin_notices' ) );
488 - add_action( 'load-' . $hook . '-network', array( __CLASS__, 'hide_core_admin_notices' ) );
485 + // Hide WordPress core admin notices on this Jetpack page. The load-<hook>
486 + // action only fires when the matching screen is being rendered, so this
487 + // stays scoped to Jetpack pages and reaches every page registered here.
488 + add_action( 'load-' . $page_hook, array( __CLASS__, 'hide_core_admin_notices' ) );
489 + add_action( 'load-' . $page_hook . '-network', array( __CLASS__, 'hide_core_admin_notices' ) );
490 + }
489 491
490 492 return $hook;
491 493 }
492 494
@@ -607,8 +609,13 @@
607 609 *
608 610 * @return array Map of item key to one of the VISIBILITY_* states.
609 611 */
610 612 private static function get_visibility_states() {
613 + // This filter is one a policy feeds, and nothing else need have read the policy this request.
614 + if ( method_exists( Feature_Policy::class, 'ensure_hooks' ) ) {
615 + Feature_Policy::ensure_hooks();
616 + }
617 +
611 618 $states = array();
612 619 $items = array_merge( self::$menu_items, self::$top_level_items );
613 620
614 621 foreach ( $items as $menu_item ) {
@@ -915,31 +922,32 @@
915 922 self::enqueue_upgrade_menu_tracks_script( $asset );
916 923 }
917 924
918 925 /**
919 - * Enqueues the shared, token-only WPDS design-tokens stylesheet.
926 + * Enqueues WPDS design tokens so `var(--wpds-*)` values resolve at runtime.
920 927 *
921 - * Single entry point for any consumer that needs WPDS `var(--wpds-*)` values
922 - * to resolve at runtime on a Jetpack admin page. Registers the handle on
923 - * first use (idempotent) and enqueues it; the caller is responsible for
924 - * scoping the call to the right page(s). Since admin-ui is a dependency of
925 - * the Jetpack plugin and the modernized packages, both the plugin's
926 - * legacy/wrap_ui gate and this package's own dashboards call through here,
927 - * so the handle has a single owner and there is no duplicated enqueue logic.
928 + * Prefer Core/Gutenberg's `wp-theme` style when registered; otherwise ship
929 + * the bundled copy. The caller scopes the call to the right page(s).
928 930 *
929 931 * @return void
930 932 */
931 933 public static function enqueue_design_tokens() {
934 + // Registered since WP 7.1 (and by Gutenberg):
935 + // https://make.wordpress.org/core/2026/07/31/design-system-theming-in-wordpress-7-1/
936 + if ( wp_style_is( 'wp-theme', 'registered' ) ) {
937 + wp_enqueue_style( 'wp-theme' );
938 + return;
939 + }
940 +
941 + // @todo Remove this, the called function, and the webpack entrypoint it registers when WP 7.1 is the minimum version.
932 942 self::register_design_tokens_style();
933 943 wp_enqueue_style( self::DESIGN_TOKENS_HANDLE );
934 944 }
935 945
936 946 /**
937 - * Registers the shared, token-only WPDS design-tokens stylesheet.
947 + * Registers the bundled, token-only WPDS design-tokens stylesheet.
938 948 *
939 - * The stylesheet only defines `:root{--wpds-*}` custom properties (no
940 - * component or class styles), giving every Jetpack admin page a single
941 - * runtime source for design tokens. It is safe to call repeatedly:
949 + * Used only when `wp-theme` is not registered. Safe to call repeatedly:
942 950 * wp_register_style() is a no-op once the handle is registered.
943 951 *
944 952 * @return void
945 953 */