| @@ -4,13 +4,18 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -use Automattic\Jetpack\Assets\Logo as Jetpack_Logo; | |
| 8 | +use Automattic\Jetpack\Admin_UI\Admin_Menu; | |
| 9 | +use Automattic\Jetpack\Current_Plan as Jetpack_Plan; | |
| 9 | 10 | use Automattic\Jetpack\Partner_Coupon as Jetpack_Partner_Coupon; |
| 10 | 11 | use Automattic\Jetpack\Status; |
| 11 | 12 | use Automattic\Jetpack\Status\Host; |
| 12 | 13 | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 0 ); | |
| 16 | +} | |
| 17 | + | |
| 13 | 18 | /** |
| 14 | 19 | * Build the Jetpack admin menu as a whole. |
| 15 | 20 | */ |
| 16 | 21 | class Jetpack_Admin { |
| @@ -27,13 +32,8 @@ | ||
| 27 | 32 | * |
| 28 | 33 | * @return self |
| 29 | 34 | */ |
| 30 | 35 | public static function init() { |
| 31 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 32 | - if ( isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) { | |
| 33 | - add_filter( 'nocache_headers', array( 'Jetpack_Admin', 'add_no_store_header' ), 100 ); | |
| 34 | - } | |
| 35 | - | |
| 36 | 36 | if ( self::$instance === null ) { |
| 37 | 37 | self::$instance = new Jetpack_Admin(); |
| 38 | 38 | } |
| 39 | 39 | return self::$instance; |
| @@ -41,12 +41,14 @@ | ||
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Filter callback to add `no-store` to the `Cache-Control` header. |
| 44 | 44 | * |
| 45 | + * @deprecated 14.9 | |
| 45 | 46 | * @param array $headers Headers array. |
| 46 | 47 | * @return array Modified headers array. |
| 47 | 48 | */ |
| 48 | 49 | public static function add_no_store_header( $headers ) { |
| 50 | + _deprecated_function( __METHOD__, '14.9' ); | |
| 49 | 51 | $headers['Cache-Control'] .= ', no-store'; |
| 50 | 52 | return $headers; |
| 51 | 53 | } |
| 52 | 54 | |
| @@ -60,15 +62,19 @@ | ||
| 60 | 62 | |
| 61 | 63 | require_once JETPACK__PLUGIN_DIR . '_inc/lib/admin-pages/class-jetpack-about-page.php'; |
| 62 | 64 | $jetpack_about = new Jetpack_About_Page(); |
| 63 | 65 | |
| 66 | + require_once JETPACK__PLUGIN_DIR . '_inc/lib/admin-pages/class-jetpack-ai-page.php'; | |
| 67 | + $jetpack_ai = new Jetpack_AI_Page(); | |
| 68 | + | |
| 64 | 69 | add_action( 'admin_init', array( $jetpack_react, 'react_redirects' ), 0 ); |
| 65 | 70 | add_action( 'admin_menu', array( $jetpack_react, 'add_actions' ), 998 ); |
| 66 | - add_action( 'jetpack_admin_menu', array( $jetpack_react, 'jetpack_add_dashboard_sub_nav_item' ) ); | |
| 71 | + add_action( 'admin_menu', array( $jetpack_react, 'remove_jetpack_menu' ), 2000 ); | |
| 67 | 72 | add_action( 'jetpack_admin_menu', array( $jetpack_react, 'jetpack_add_settings_sub_nav_item' ) ); |
| 68 | 73 | add_action( 'jetpack_admin_menu', array( $this, 'admin_menu_debugger' ) ); |
| 69 | 74 | add_action( 'jetpack_admin_menu', array( $fallback_page, 'add_actions' ) ); |
| 70 | 75 | add_action( 'jetpack_admin_menu', array( $jetpack_about, 'add_actions' ) ); |
| 76 | + add_action( 'jetpack_admin_menu', array( $jetpack_ai, 'add_actions' ) ); | |
| 71 | 77 | |
| 72 | 78 | // Add redirect to current page for activation/deactivation of modules. |
| 73 | 79 | add_action( 'jetpack_pre_activate_module', array( $this, 'fix_redirect' ), 10, 2 ); |
| 74 | 80 | add_action( 'jetpack_pre_deactivate_module', array( $this, 'fix_redirect' ), 10, 2 ); |
| @@ -76,12 +82,13 @@ | ||
| 76 | 82 | // Add module bulk actions handler. |
| 77 | 83 | add_action( 'jetpack_unrecognized_action', array( $this, 'handle_unrecognized_action' ) ); |
| 78 | 84 | |
| 79 | 85 | if ( class_exists( 'Akismet_Admin' ) ) { |
| 80 | - // If the site has Jetpack Anti-Spam, change the Akismet menu label accordingly. | |
| 81 | - $site_products = Jetpack_Plan::get_products(); | |
| 82 | - $anti_spam_products = array( 'jetpack_anti_spam_monthly', 'jetpack_anti_spam' ); | |
| 83 | - if ( ! empty( array_intersect( $anti_spam_products, array_column( $site_products, 'product_slug' ) ) ) ) { | |
| 86 | + // If the site has Jetpack Anti-spam, change the Akismet menu label and logo accordingly. | |
| 87 | + $site_products = array_column( Jetpack_Plan::get_products(), 'product_slug' ); | |
| 88 | + $has_anti_spam_product = count( array_intersect( array( 'jetpack_anti_spam', 'jetpack_anti_spam_monthly' ), $site_products ) ) > 0; | |
| 89 | + | |
| 90 | + if ( Jetpack_Plan::supports( 'akismet' ) || Jetpack_Plan::supports( 'antispam' ) || $has_anti_spam_product ) { | |
| 84 | 91 | // Prevent Akismet from adding a menu item. |
| 85 | 92 | add_action( |
| 86 | 93 | 'admin_menu', |
| 87 | 94 | function () { |
| @@ -89,17 +96,18 @@ | ||
| 89 | 96 | }, |
| 90 | 97 | 4 |
| 91 | 98 | ); |
| 92 | 99 | |
| 93 | - // Add an Anti-spam menu item for Jetpack. | |
| 94 | - add_action( | |
| 95 | - 'jetpack_admin_menu', | |
| 96 | - function () { | |
| 97 | - add_submenu_page( 'jetpack', __( 'Anti-Spam', 'jetpack' ), __( 'Anti-Spam', 'jetpack' ), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) ); | |
| 98 | - } | |
| 99 | - ); | |
| 100 | - add_action( 'admin_enqueue_scripts', array( $this, 'akismet_logo_replacement_styles' ) ); | |
| 100 | + // Add an Anti-spam menu item for Jetpack. This is handled automatically by the Admin_Menu as long as it has been initialized. | |
| 101 | + Admin_Menu::init(); | |
| 101 | 102 | } |
| 103 | + | |
| 104 | + // Render the unified Jetpack header/footer chrome on Akismet's admin pages by | |
| 105 | + // consuming Akismet's `akismet_header` / `akismet_footer` action hooks. This does | |
| 106 | + // not modify the Akismet plugin; it only registers callbacks on its own hooks. | |
| 107 | + require_once JETPACK__PLUGIN_DIR . '_inc/lib/admin-pages/class-akismet-admin-chrome.php'; | |
| 108 | + $akismet_admin_chrome = new Akismet_Admin_Chrome(); | |
| 109 | + $akismet_admin_chrome->init_hooks(); | |
| 102 | 110 | } |
| 103 | 111 | |
| 104 | 112 | // Ensure an Additional CSS menu item is added to the Appearance menu whenever Jetpack is connected. |
| 105 | 113 | add_action( 'admin_menu', array( $this, 'additional_css_menu' ) ); |
| @@ -107,21 +115,19 @@ | ||
| 107 | 115 | add_filter( 'jetpack_display_jitms_on_screen', array( $this, 'should_display_jitms_on_screen' ), 10, 2 ); |
| 108 | 116 | |
| 109 | 117 | // Register Jetpack partner coupon hooks. |
| 110 | 118 | Jetpack_Partner_Coupon::register_coupon_admin_hooks( 'jetpack', Jetpack::admin_url() ); |
| 111 | - } | |
| 112 | 119 | |
| 113 | - /** | |
| 114 | - * Generate styles to replace Akismet logo for the Jetpack logo. It's a workaround until we create a proper settings page for | |
| 115 | - * Jetpack Anti-Spam. Without this, we would have to change the logo from Akismet codebase and we want to avoid that. | |
| 116 | - */ | |
| 117 | - public function akismet_logo_replacement_styles() { | |
| 118 | - $logo = new Jetpack_Logo(); | |
| 119 | - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode | |
| 120 | - $logo_base64 = base64_encode( $logo->get_jp_emblem_larger() ); | |
| 121 | - $logo_base64_url = "data:image/svg+xml;base64,{$logo_base64}"; | |
| 122 | - $style = ".akismet-masthead__logo-container { background: url({$logo_base64_url}) no-repeat .25rem; height: 1.8125rem; } .akismet-masthead__logo { display: none; }"; | |
| 123 | - wp_add_inline_style( 'admin-bar', $style ); | |
| 120 | + // Remove default WordPress admin footer on Jetpack pages only. | |
| 121 | + add_filter( 'admin_footer_text', array( $this, 'maybe_remove_admin_footer_text' ) ); | |
| 122 | + add_filter( 'update_footer', array( $this, 'maybe_remove_admin_footer_version' ), 11 ); | |
| 123 | + add_filter( 'admin_body_class', array( $this, 'add_jetpack_admin_body_class' ) ); | |
| 124 | + add_action( 'admin_head', array( $this, 'add_footer_removal_styles' ) ); | |
| 125 | + | |
| 126 | + // Make WPDS design tokens resolve at runtime on the legacy/wrap_ui Jetpack | |
| 127 | + // admin pages (Dashboard, Settings, Debugger) that don't ship their own | |
| 128 | + // `:root{--wpds-*}` source. Delegates to Admin_Menu's shared enqueue API. | |
| 129 | + add_action( 'admin_enqueue_scripts', array( $this, 'maybe_enqueue_design_tokens' ) ); | |
| 124 | 130 | } |
| 125 | 131 | |
| 126 | 132 | /** |
| 127 | 133 | * Handle our Additional CSS menu item and legacy page declaration. |
| @@ -128,14 +134,29 @@ | ||
| 128 | 134 | * |
| 129 | 135 | * @since 11.0 . Prior to that, this function was located in custom-css-4.7.php (now custom-css.php). |
| 130 | 136 | */ |
| 131 | 137 | public static function additional_css_menu() { |
| 138 | + /* | |
| 139 | + * Custom CSS for the Customizer is deprecated for block themes as of WP 6.1, so we only expose it with a menu | |
| 140 | + * if the site already has existing CSS code. | |
| 141 | + */ | |
| 142 | + if ( wp_is_block_theme() ) { | |
| 143 | + $styles = wp_get_custom_css(); | |
| 144 | + if ( ! $styles ) { | |
| 145 | + return; | |
| 146 | + } | |
| 147 | + } | |
| 132 | 148 | |
| 133 | 149 | // If the site is a WoA site and the custom-css feature is not available, return. |
| 134 | 150 | // See https://github.com/Automattic/jetpack/pull/19965 for more on how this menu item is dealt with on WoA sites. |
| 135 | 151 | if ( ( new Host() )->is_woa_site() && ! ( in_array( 'custom-css', Jetpack::get_available_modules(), true ) ) ) { |
| 136 | 152 | return; |
| 137 | - } elseif ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'custom-css' ) ) { // If the Custom CSS module is enabled, add the Additional CSS menu item and link to the Customizer. | |
| 153 | + } elseif ( | |
| 154 | + class_exists( 'Jetpack' ) && ( | |
| 155 | + Jetpack::is_module_active( 'custom-css' ) || // If the Custom CSS module is enabled, add the Additional CSS menu item and link to the Customizer. | |
| 156 | + ( wp_is_block_theme() && ! empty( wp_get_custom_css() ) ) // Do the same if the theme is block-based but has existing custom CSS. | |
| 157 | + ) | |
| 158 | + ) { | |
| 138 | 159 | // Add in our legacy page to support old bookmarks and such. |
| 139 | 160 | add_submenu_page( '', __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss', array( __CLASS__, 'customizer_redirect' ) ); |
| 140 | 161 | |
| 141 | 162 | // Add in our new page slug that will redirect to the customizer. |
| @@ -140,13 +161,8 @@ | ||
| 140 | 161 | |
| 141 | 162 | // Add in our new page slug that will redirect to the customizer. |
| 142 | 163 | $hook = add_theme_page( __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss-customizer-redirect', array( __CLASS__, 'customizer_redirect' ) ); |
| 143 | 164 | add_action( "load-{$hook}", array( __CLASS__, 'customizer_redirect' ) ); |
| 144 | - } elseif ( class_exists( 'Jetpack' ) && Jetpack::is_connection_ready() ) { // Link to the Jetpack Settings > Writing page, highlighting the Custom CSS setting. | |
| 145 | - add_submenu_page( '', __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss', array( __CLASS__, 'theme_enhancements_redirect' ) ); | |
| 146 | - | |
| 147 | - $hook = add_theme_page( __( 'CSS', 'jetpack' ), __( 'Additional CSS', 'jetpack' ), 'edit_theme_options', 'editcss-theme-enhancements-redirect', array( __CLASS__, 'theme_enhancements_redirect' ) ); | |
| 148 | - add_action( "load-{$hook}", array( __CLASS__, 'theme_enhancements_redirect' ) ); | |
| 149 | 165 | } |
| 150 | 166 | } |
| 151 | 167 | |
| 152 | 168 | /** |
| @@ -157,8 +173,10 @@ | ||
| 157 | 173 | * |
| 158 | 174 | * There is a core patch in trac that would make this unnecessary. |
| 159 | 175 | * |
| 160 | 176 | * @link https://core.trac.wordpress.org/ticket/39050 |
| 177 | + * | |
| 178 | + * @return never | |
| 161 | 179 | */ |
| 162 | 180 | public static function customizer_redirect() { |
| 163 | 181 | wp_safe_redirect( |
| 164 | 182 | self::customizer_link( |
| @@ -166,24 +184,12 @@ | ||
| 166 | 184 | 'return_url' => wp_get_referer(), |
| 167 | 185 | ) |
| 168 | 186 | ) |
| 169 | 187 | ); |
| 170 | - exit; | |
| 188 | + exit( 0 ); | |
| 171 | 189 | } |
| 172 | 190 | |
| 173 | 191 | /** |
| 174 | - * Handle the Additional CSS redirect to the Jetpack settings Theme Enhancements section. | |
| 175 | - * | |
| 176 | - * @since 11.0 | |
| 177 | - */ | |
| 178 | - public static function theme_enhancements_redirect() { | |
| 179 | - wp_safe_redirect( | |
| 180 | - 'admin.php?page=jetpack#/writing?term=custom-css' | |
| 181 | - ); | |
| 182 | - exit; | |
| 183 | - } | |
| 184 | - | |
| 185 | - /** | |
| 186 | 192 | * Build the URL to deep link to the Customizer. |
| 187 | 193 | * |
| 188 | 194 | * You can modify the return url via $args. |
| 189 | 195 | * |
| @@ -222,17 +228,9 @@ | ||
| 222 | 228 | * @param array $module2 Module data. |
| 223 | 229 | * @return int Indicating the relative ordering of module1 and module2. |
| 224 | 230 | */ |
| 225 | 231 | public static function sort_requires_connection_last( $module1, $module2 ) { |
| 226 | - if ( (bool) $module1['requires_connection'] === (bool) $module2['requires_connection'] ) { | |
| 227 | - return 0; | |
| 228 | - } elseif ( $module1['requires_connection'] ) { | |
| 229 | - return 1; | |
| 230 | - } elseif ( $module2['requires_connection'] ) { | |
| 231 | - return -1; | |
| 232 | - } | |
| 233 | - | |
| 234 | - return 0; | |
| 232 | + return ( (bool) $module1['requires_connection'] ) <=> ( (bool) $module2['requires_connection'] ); | |
| 235 | 233 | } |
| 236 | 234 | |
| 237 | 235 | /** |
| 238 | 236 | * Produce JS understandable objects of modules containing information for |
| @@ -323,9 +321,9 @@ | ||
| 323 | 321 | * add_filter( 'jetpack_search_terms_$module', 'jetpack_$module_search_terms' ); |
| 324 | 322 | * |
| 325 | 323 | * @since 3.5.0 |
| 326 | 324 | * |
| 327 | - * @param string The search terms (comma separated). | |
| 325 | + * @param string The search terms (comma-separated). | |
| 328 | 326 | */ |
| 329 | 327 | echo apply_filters( 'jetpack_search_terms_' . $module, $module_array['additional_search_queries'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 330 | 328 | $module_array['search_terms'] = ob_get_clean(); |
| 331 | 329 | |
| @@ -456,9 +454,9 @@ | ||
| 456 | 454 | * level connection should be unavailable. |
| 457 | 455 | */ |
| 458 | 456 | if ( ( new Status() )->is_offline_mode() ) { |
| 459 | 457 | if ( $module['requires_connection'] || $module['requires_user_connection'] ) { |
| 460 | - return __( 'Offline mode', 'jetpack' ); | |
| 458 | + return __( 'Unavailable in Offline mode', 'jetpack' ); | |
| 461 | 459 | } |
| 462 | 460 | } |
| 463 | 461 | |
| 464 | 462 | /* |
| @@ -504,9 +502,9 @@ | ||
| 504 | 502 | Jetpack::activate_module( $module, false ); |
| 505 | 503 | } |
| 506 | 504 | // The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end. |
| 507 | 505 | wp_safe_redirect( wp_get_referer() ); |
| 508 | - exit; | |
| 506 | + exit( 0 ); | |
| 509 | 507 | case 'bulk-deactivate': |
| 510 | 508 | check_admin_referer( 'bulk-jetpack_page_jetpack_modules' ); |
| 511 | 509 | if ( ! current_user_can( 'jetpack_deactivate_modules' ) ) { |
| 512 | 510 | break; |
| @@ -519,9 +517,9 @@ | ||
| 519 | 517 | Jetpack::state( 'message', 'module_deactivated' ); |
| 520 | 518 | } |
| 521 | 519 | Jetpack::state( 'module', $modules ); |
| 522 | 520 | wp_safe_redirect( wp_get_referer() ); |
| 523 | - exit; | |
| 521 | + exit( 0 ); | |
| 524 | 522 | default: |
| 525 | 523 | return; |
| 526 | 524 | } |
| 527 | 525 | } |
| @@ -568,9 +566,15 @@ | ||
| 568 | 566 | nocache_headers(); |
| 569 | 567 | if ( ! current_user_can( 'manage_options' ) ) { |
| 570 | 568 | die( '-1' ); |
| 571 | 569 | } |
| 572 | - Jetpack_Admin_Page::wrap_ui( array( $this, 'debugger_page' ), array( 'is-wide' => true ) ); | |
| 570 | + Jetpack_Admin_Page::wrap_ui( | |
| 571 | + array( $this, 'debugger_page' ), | |
| 572 | + array( | |
| 573 | + 'is-wide' => true, | |
| 574 | + 'show-nav' => false, | |
| 575 | + ) | |
| 576 | + ); | |
| 573 | 577 | } |
| 574 | 578 | |
| 575 | 579 | /** |
| 576 | 580 | * Display debugger page. |
| @@ -601,24 +605,111 @@ | ||
| 601 | 605 | ) ) { |
| 602 | 606 | return false; |
| 603 | 607 | } |
| 604 | 608 | |
| 605 | - // Disable all JITMs on pages where the recommendations banner is displaying. | |
| 606 | - if ( | |
| 607 | - in_array( | |
| 608 | - $screen_id, | |
| 609 | - array( | |
| 610 | - 'dashboard', | |
| 611 | - 'plugins', | |
| 612 | - 'jetpack_page_stats', | |
| 613 | - ), | |
| 614 | - true | |
| 615 | - ) | |
| 616 | - && \Jetpack_Recommendations_Banner::can_be_displayed() | |
| 617 | - ) { | |
| 609 | + return $value; | |
| 610 | + } | |
| 611 | + | |
| 612 | + /** | |
| 613 | + * Check if we're on a Jetpack admin page. | |
| 614 | + * | |
| 615 | + * Similar to how WooCommerce checks for its admin pages by comparing | |
| 616 | + * against known screen ID patterns. | |
| 617 | + * | |
| 618 | + * @return bool True if on a Jetpack admin page, false otherwise. | |
| 619 | + */ | |
| 620 | + private function is_jetpack_admin_page() { | |
| 621 | + $screen = get_current_screen(); | |
| 622 | + if ( ! $screen ) { | |
| 618 | 623 | return false; |
| 619 | 624 | } |
| 620 | 625 | |
| 621 | - return $value; | |
| 626 | + // Check for Jetpack admin pages: | |
| 627 | + // - toplevel_page_jetpack (main Jetpack menu page) | |
| 628 | + // - toplevel_page_jetpack-network (Jetpack Network Admin menu page) | |
| 629 | + // - jetpack_page_* (Jetpack submenu pages) | |
| 630 | + // - admin_page_jetpack* (legacy/special Jetpack pages) | |
| 631 | + // Or check if parent_base is 'jetpack' or 'jetpack-network' (submenu pages) | |
| 632 | + return ( | |
| 633 | + $screen->id === 'toplevel_page_jetpack' || | |
| 634 | + $screen->id === 'toplevel_page_jetpack-network' || | |
| 635 | + str_starts_with( $screen->id, 'jetpack_page_' ) || | |
| 636 | + str_starts_with( $screen->id, 'admin_page_jetpack' ) || | |
| 637 | + $screen->parent_base === 'jetpack' || | |
| 638 | + $screen->parent_base === 'jetpack-network' | |
| 639 | + ); | |
| 640 | + } | |
| 641 | + | |
| 642 | + /** | |
| 643 | + * Add a body class to Jetpack admin pages. | |
| 644 | + * | |
| 645 | + * @param string $classes Space-separated list of CSS classes. | |
| 646 | + * @return string Modified class list. | |
| 647 | + */ | |
| 648 | + public function add_jetpack_admin_body_class( $classes ) { | |
| 649 | + if ( $this->is_jetpack_admin_page() ) { | |
| 650 | + return ltrim( trim( $classes ) . ' jetpack-admin-page ' ); | |
| 651 | + } | |
| 652 | + return $classes; | |
| 653 | + } | |
| 654 | + | |
| 655 | + /** | |
| 656 | + * Add inline styles to remove footer padding on Jetpack pages. | |
| 657 | + * | |
| 658 | + * This needs to be inline because jetpack-admin.css is not loaded on | |
| 659 | + * React-powered admin pages (they use load_wrapper_styles instead). | |
| 660 | + */ | |
| 661 | + public function add_footer_removal_styles() { | |
| 662 | + if ( ! $this->is_jetpack_admin_page() ) { | |
| 663 | + return; | |
| 664 | + } | |
| 665 | + echo '<style>.jetpack-admin-page #wpbody-content { padding-bottom: 0; } .jetpack-admin-page #wpfooter { display: none; }</style>'; | |
| 666 | + } | |
| 667 | + | |
| 668 | + /** | |
| 669 | + * Enqueues the shared WPDS design-tokens stylesheet on the legacy/wrap_ui pages. | |
| 670 | + * | |
| 671 | + * This is the admin_enqueue_scripts callback for the legacy Jetpack admin | |
| 672 | + * pages. The admin-ui package owns the handle and enqueues it on the | |
| 673 | + * modernized dashboards it registers; the legacy/wrap_ui pages (Dashboard, | |
| 674 | + * Settings, Debugger) aren't registered through Admin_Menu, so we cover them | |
| 675 | + * here via the central is_jetpack_admin_page() gate. The actual enqueue is | |
| 676 | + * delegated to the reusable Admin_Menu::enqueue_design_tokens() API so there | |
| 677 | + * is a single owner of the handle and no duplicated register/enqueue logic. | |
| 678 | + * | |
| 679 | + * @return void | |
| 680 | + */ | |
| 681 | + public function maybe_enqueue_design_tokens() { | |
| 682 | + if ( ! $this->is_jetpack_admin_page() ) { | |
| 683 | + return; | |
| 684 | + } | |
| 685 | + | |
| 686 | + // Guard against an older admin-ui being loaded ahead of this one by the | |
| 687 | + // package autoloader's version-precedence resolution. | |
| 688 | + if ( ! method_exists( Admin_Menu::class, 'enqueue_design_tokens' ) ) { | |
| 689 | + return; | |
| 690 | + } | |
| 691 | + | |
| 692 | + Admin_Menu::enqueue_design_tokens(); | |
| 693 | + } | |
| 694 | + | |
| 695 | + /** | |
| 696 | + * Remove the admin footer text on Jetpack pages. | |
| 697 | + * | |
| 698 | + * @param string $content The default footer text. | |
| 699 | + * @return string Empty string on Jetpack pages, original content otherwise. | |
| 700 | + */ | |
| 701 | + public function maybe_remove_admin_footer_text( $content ) { | |
| 702 | + return $this->is_jetpack_admin_page() ? '' : $content; | |
| 703 | + } | |
| 704 | + | |
| 705 | + /** | |
| 706 | + * Remove the admin footer version on Jetpack pages. | |
| 707 | + * | |
| 708 | + * @param string $content The default footer version text. | |
| 709 | + * @return string Empty string on Jetpack pages, original content otherwise. | |
| 710 | + */ | |
| 711 | + public function maybe_remove_admin_footer_version( $content ) { | |
| 712 | + return $this->is_jetpack_admin_page() ? '' : $content; | |
| 622 | 713 | } |
| 623 | 714 | } |
| 624 | 715 | Jetpack_Admin::init(); |