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-masterbar/src/admin-menu/class-base-admin-menu.php +11 -52 13.6.2 → 16.3 View file →
@@ -75,18 +75,12 @@
75 75
76 76 if ( ! $this->is_api_request ) {
77 77 add_filter( 'admin_menu', array( $this, 'override_svg_icons' ), 99999 );
78 78 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
79 - add_action( 'admin_head', array( $this, 'set_site_icon_inline_styles' ) );
80 79 add_action( 'in_admin_header', array( $this, 'add_dashboard_switcher' ) );
81 80 add_action( 'admin_footer', array( $this, 'dashboard_switcher_scripts' ) );
82 81 add_action( 'admin_menu', array( $this, 'handle_preferred_view' ), 99997 );
83 82 add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
84 -
85 - // Do not inject core mobile toggle when the user wants to use the WP Admin interface.
86 - if ( ! $this->use_wp_admin_interface() ) {
87 - add_action( 'adminmenu', array( $this, 'inject_core_mobile_toggle' ) );
88 - }
89 83 }
90 84 }
91 85
92 86 /**
@@ -156,9 +150,8 @@
156 150 $menu_item[4] = 'menu-top';
157 151 $menu_item[6] = $icon;
158 152 }
159 153
160 - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
161 154 unset( $menu[ $menu_position ] );
162 155 if ( $position ) {
163 156 $menu_position = $position;
164 157 }
@@ -270,26 +263,12 @@
270 263 wp_localize_script(
271 264 'jetpack-admin-menu',
272 265 'jetpackAdminMenu',
273 266 array(
274 - 'upsellNudgeJitm' => wp_create_nonce( 'upsell_nudge_jitm' ),
275 267 'jitmDismissNonce' => wp_create_nonce( 'jitm_dismiss' ),
276 268 )
277 269 );
278 270
279 - // Load nav unification styles when the user isn't using wp-admin interface style.
280 - if ( ! $this->use_wp_admin_interface() ) {
281 - Assets::register_script(
282 - 'jetpack-admin-nav-unification',
283 - $assets_base_path . 'admin-menu-nav-unification.js',
284 - __FILE__,
285 - array(
286 - 'enqueue' => true,
287 - 'css_path' => $assets_base_path . 'admin-menu-nav-unification.css',
288 - )
289 - );
290 - }
291 -
292 271 $this->configure_colors_for_rtl_stylesheets();
293 272 }
294 273
295 274 /**
@@ -301,22 +280,8 @@
301 280 wp_style_add_data( 'colors', 'rtl', $this->is_rtl() );
302 281 }
303 282
304 283 /**
305 - * Injects inline-styles for site icon for when third-party plugins remove enqueued stylesheets.
306 - * Unable to use wp_add_inline_style as plugins remove styles from all non-standard handles
307 - */
308 - public function set_site_icon_inline_styles() {
309 - echo '<style>
310 - #adminmenu .toplevel_page_site-card .wp-menu-image,
311 - #adminmenu .toplevel_page_site-card .wp-menu-image img {
312 - height: 32px;
313 - width: 32px;
314 - }
315 - </style>';
316 - }
317 -
318 - /**
319 284 * Hide the submenu page based on slug and return the item that was hidden.
320 285 *
321 286 * Instead of actually removing the submenu item, a safer approach is to hide it and filter it in the API response.
322 287 * In this manner we'll avoid breaking third-party plugins depending on items that no longer exist.
@@ -442,8 +407,10 @@
442 407 if ( str_contains( $menu_item[5], '://' ) ) {
443 408 $menu_item[5] = preg_replace( '![:/.]+!', '_', $menu_item[5] );
444 409 }
445 410
411 + $menu_item[5] = preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $menu_item[5] );
412 +
446 413 if ( str_starts_with( $menu_item[6], 'data:image/svg+xml' ) && 'site-card' !== $menu_item[3] ) {
447 414 $svg_items[] = array(
448 415 'icon' => $menu_item[6],
449 416 'id' => $menu_item[5],
@@ -493,12 +460,10 @@
493 460
494 461 $this->sort_hidden_submenus();
495 462
496 463 foreach ( $menu as $menu_index => $menu_item ) {
497 - $has_submenus = isset( $submenu[ $menu_item[2] ] );
498 -
499 464 // Skip if the menu doesn't have submenus.
500 - if ( ! $has_submenus || ! is_array( $submenu[ $menu_item[2] ] ) ) {
465 + if ( empty( $submenu[ $menu_item[2] ] ) || ! is_array( $submenu[ $menu_item[2] ] ) ) {
501 466 continue;
502 467 }
503 468
504 469 // If the first submenu item is hidden then we should also hide the parent.
@@ -621,9 +586,14 @@
621 586 * @param string $screen Screen identifier.
622 587 * @param string $view Preferred view.
623 588 */
624 589 public function set_preferred_view( $screen, $view ) {
625 - $preferred_views = $this->get_preferred_views();
590 + remove_filter( 'get_user_option_jetpack_admin_menu_preferred_views', 'wpcom_admin_get_user_option_jetpack' );
591 + $preferred_views = $this->get_preferred_views();
592 + if ( function_exists( 'wpcom_admin_get_user_option_jetpack' ) ) {
593 + add_filter( 'get_user_option_jetpack_admin_menu_preferred_views', 'wpcom_admin_get_user_option_jetpack' );
594 + }
595 +
626 596 $screen = str_replace( '?post_type=post', '', $screen );
627 597 $preferred_views[ $screen ] = $view;
628 598 update_user_option( get_current_user_id(), 'jetpack_admin_menu_preferred_views', $preferred_views );
629 599 }
@@ -726,15 +696,15 @@
726 696 $menu_mappings = require __DIR__ . '/menu-mappings.php';
727 697 if ( isset( $menu_mappings[ $current_screen ] ) ) {
728 698 // Using `wp_redirect` intentionally because we're redirecting to Calypso.
729 699 wp_redirect( $menu_mappings[ $current_screen ] . $this->domain ); // phpcs:ignore WordPress.Security.SafeRedirect
730 - exit;
700 + exit( 0 );
731 701 }
732 702 } elseif ( self::CLASSIC_VIEW === $preferred_view ) {
733 703 // Removes the `preferred-view` param from the URL to avoid issues with
734 704 // screens that don't expect this param to be present in the URL.
735 705 wp_safe_redirect( remove_query_arg( 'preferred-view' ) );
736 - exit;
706 + exit( 0 );
737 707 }
738 708 // phpcs:enable WordPress.Security.NonceVerification
739 709 }
740 710
@@ -759,19 +729,8 @@
759 729 * @return bool
760 730 */
761 731 public function should_link_to_wp_admin() {
762 732 return get_user_option( 'jetpack_admin_menu_link_destination' );
763 - }
764 -
765 - /**
766 - * Injects the core's mobile toggle for proper positioning of the submenus.
767 - *
768 - * @see https://core.trac.wordpress.org/ticket/32747
769 - *
770 - * @return void
771 - */
772 - public function inject_core_mobile_toggle() {
773 - echo '<span id="wp-admin-bar-menu-toggle" style="display: none!important">';
774 733 }
775 734
776 735 /**
777 736 * Whether the current user has indicated they want to use the wp-admin interface for the given screen.