← All changes
|
jetpack_vendor/automattic/jetpack-masterbar/src/admin-menu/class-atomic-admin-menu.php
+22
-315
13.6.2
→
16.3-beta
View file →
| @@ -7,13 +7,10 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace Automattic\Jetpack\Masterbar; |
| 9 | 9 | |
| 10 | 10 | use Automattic\Jetpack\Connection\Client; |
| 11 | -use Automattic\Jetpack\Current_Plan as Jetpack_Plan; | |
| 12 | 11 | use Automattic\Jetpack\JITMS\JITM; |
| 13 | 12 | use Automattic\Jetpack\Modules; |
| 14 | -use Automattic\Jetpack\Redirect; | |
| 15 | -use Automattic\Jetpack\Status; | |
| 16 | 13 | |
| 17 | 14 | require_once __DIR__ . '/class-admin-menu.php'; |
| 18 | 15 | |
| 19 | 16 | /** |
| @@ -30,9 +27,9 @@ | ||
| 30 | 27 | add_action( 'wp_enqueue_scripts', array( $this, 'dequeue_scripts' ), 20 ); |
| 31 | 28 | add_action( 'admin_enqueue_scripts', array( $this, 'dequeue_scripts' ), 20 ); |
| 32 | 29 | add_action( 'wp_ajax_sidebar_state', array( $this, 'ajax_sidebar_state' ) ); |
| 33 | 30 | add_action( 'wp_ajax_jitm_dismiss', array( $this, 'wp_ajax_jitm_dismiss' ) ); |
| 34 | - add_action( 'wp_ajax_upsell_nudge_jitm', array( $this, 'wp_ajax_upsell_nudge_jitm' ) ); | |
| 31 | + add_action( 'adminmenu', array( $this, 'render_upsell_nudge' ), 100 ); | |
| 35 | 32 | |
| 36 | 33 | if ( ! $this->is_api_request ) { |
| 37 | 34 | add_filter( 'submenu_file', array( $this, 'override_the_theme_installer' ), 10, 2 ); |
| 38 | 35 | } |
| @@ -39,18 +36,12 @@ | ||
| 39 | 36 | |
| 40 | 37 | add_action( |
| 41 | 38 | 'admin_menu', |
| 42 | 39 | function () { |
| 43 | - // @phan-suppress-next-line PhanUndeclaredFunctionInCallable -- Not worth bringing in a stub just for a callback in a remove_action call. | |
| 44 | 40 | remove_action( 'admin_menu', 'gutenberg_menu', 9 ); |
| 45 | 41 | }, |
| 46 | 42 | 0 |
| 47 | 43 | ); |
| 48 | - | |
| 49 | - // Add notices to the settings pages when there is a Calypso page available. | |
| 50 | - if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) { | |
| 51 | - add_action( 'current_screen', array( $this, 'add_settings_page_notice' ) ); | |
| 52 | - } | |
| 53 | 44 | } |
| 54 | 45 | |
| 55 | 46 | /** |
| 56 | 47 | * Dequeues unnecessary scripts. |
| @@ -74,24 +65,15 @@ | ||
| 74 | 65 | */ |
| 75 | 66 | public function reregister_menu_items() { |
| 76 | 67 | parent::reregister_menu_items(); |
| 77 | 68 | |
| 78 | - $this->add_my_home_menu(); | |
| 79 | 69 | $this->remove_gutenberg_menu(); |
| 80 | 70 | |
| 81 | - // We don't need the `My Mailboxes` when the interface is set to wp-admin or the site is a staging site, | |
| 82 | - if ( get_option( 'wpcom_admin_interface' ) !== 'wp-admin' && ! get_option( 'wpcom_is_staging_site' ) ) { | |
| 83 | - $this->add_my_mailboxes_menu(); | |
| 84 | - } | |
| 85 | - | |
| 86 | 71 | // Not needed outside of wp-admin. |
| 87 | 72 | if ( ! $this->is_api_request ) { |
| 88 | - $this->add_browse_sites_link(); | |
| 89 | - $this->add_site_card_menu(); | |
| 90 | 73 | $this->add_new_site_link(); |
| 91 | 74 | } |
| 92 | 75 | |
| 93 | - $this->add_woocommerce_installation_menu(); | |
| 94 | 76 | ksort( $GLOBALS['menu'] ); |
| 95 | 77 | } |
| 96 | 78 | |
| 97 | 79 | /** |
| @@ -121,8 +103,28 @@ | ||
| 121 | 103 | return parent::get_preferred_view( $screen, $fallback_global_preference ); |
| 122 | 104 | } |
| 123 | 105 | |
| 124 | 106 | /** |
| 107 | + * Add the appearance menu. | |
| 108 | + * | |
| 109 | + * @return string | |
| 110 | + */ | |
| 111 | + public function add_appearance_menu() { | |
| 112 | + $customize_url = parent::add_appearance_menu(); | |
| 113 | + $should_display_additional_css = current_user_can( 'customize' ) && ! wp_is_block_theme(); | |
| 114 | + | |
| 115 | + if ( ! $should_display_additional_css ) { | |
| 116 | + return $customize_url; | |
| 117 | + } | |
| 118 | + | |
| 119 | + $customize_custom_css_url = add_query_arg( array( 'autofocus' => array( 'section' => 'custom_css' ) ), $customize_url ); | |
| 120 | + // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 121 | + add_submenu_page( 'themes.php', esc_attr__( 'Additional CSS', 'jetpack-masterbar' ), __( 'Additional CSS', 'jetpack-masterbar' ), 'customize', esc_url( $customize_custom_css_url ), null, 20 ); | |
| 122 | + | |
| 123 | + return $customize_url; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 125 | 127 | * Adds Users menu. |
| 126 | 128 | */ |
| 127 | 129 | public function add_users_menu() { |
| 128 | 130 | $slug = current_user_can( 'list_users' ) ? 'users.php' : 'profile.php'; |
| @@ -131,22 +133,8 @@ | ||
| 131 | 133 | 'users.php' => 'https://wordpress.com/people/team/' . $this->domain, |
| 132 | 134 | ); |
| 133 | 135 | $this->update_submenus( $slug, $submenus_to_update ); |
| 134 | 136 | } |
| 135 | - | |
| 136 | - if ( ! $this->use_wp_admin_interface() ) { | |
| 137 | - // The 'Subscribers' menu exists in the Jetpack menu for Classic wp-admin interface, so only add it for non-wp-admin interfaces. | |
| 138 | - // // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 139 | - add_submenu_page( 'users.php', esc_attr__( 'Subscribers', 'jetpack-masterbar' ), __( 'Subscribers', 'jetpack-masterbar' ), 'list_users', 'https://wordpress.com/subscribers/' . $this->domain, null ); | |
| 140 | - | |
| 141 | - // When the interface is not set to wp-admin, we replace the Profile submenu. | |
| 142 | - remove_submenu_page( 'users.php', 'profile.php' ); | |
| 143 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 144 | - add_submenu_page( 'users.php', esc_attr__( 'My Profile', 'jetpack-masterbar' ), __( 'My Profile', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/me/', null ); | |
| 145 | - } | |
| 146 | - | |
| 147 | - // Users who can't 'list_users' will see "Profile" menu & "Profile > Account Settings" as submenu. | |
| 148 | - add_submenu_page( $slug, esc_attr__( 'Account Settings', 'jetpack-masterbar' ), __( 'Account Settings', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/me/account' ); | |
| 149 | 137 | } |
| 150 | 138 | |
| 151 | 139 | /** |
| 152 | 140 | * Adds Plugins menu. |
| @@ -194,23 +182,8 @@ | ||
| 194 | 182 | $this->update_submenus( 'plugins.php', $submenus_to_update ); |
| 195 | 183 | } |
| 196 | 184 | |
| 197 | 185 | /** |
| 198 | - * Adds the site switcher link if user has more than one site. | |
| 199 | - */ | |
| 200 | - public function add_browse_sites_link() { | |
| 201 | - $site_count = get_user_option( 'wpcom_site_count' ); | |
| 202 | - if ( ! $site_count || $site_count < 2 ) { | |
| 203 | - return; | |
| 204 | - } | |
| 205 | - | |
| 206 | - // Add the menu item. | |
| 207 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 208 | - add_menu_page( __( 'site-switcher', 'jetpack-masterbar' ), __( 'Browse sites', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/sites', null, 'dashicons-arrow-left-alt2', 0 ); | |
| 209 | - add_filter( 'add_menu_classes', array( $this, 'set_browse_sites_link_class' ) ); | |
| 210 | - } | |
| 211 | - | |
| 212 | - /** | |
| 213 | 186 | * Adds a custom element class for Site Switcher menu item. |
| 214 | 187 | * |
| 215 | 188 | * @param array $menu Associative array of administration menu items. |
| 216 | 189 | * |
| @@ -242,77 +215,8 @@ | ||
| 242 | 215 | add_menu_page( __( 'Add New Site', 'jetpack-masterbar' ), __( 'Add New Site', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/start?ref=calypso-sidebar', null, 'dashicons-plus-alt' ); |
| 243 | 216 | } |
| 244 | 217 | |
| 245 | 218 | /** |
| 246 | - * Adds site card component. | |
| 247 | - */ | |
| 248 | - public function add_site_card_menu() { | |
| 249 | - $default = plugins_url( 'globe-icon.svg', __FILE__ ); | |
| 250 | - $icon = get_site_icon_url( 32, $default ); | |
| 251 | - $blog_name = get_option( 'blogname' ) !== '' ? get_option( 'blogname' ) : $this->domain; | |
| 252 | - $is_coming_soon = ( new Status() )->is_coming_soon(); | |
| 253 | - | |
| 254 | - $badge = ''; | |
| 255 | - | |
| 256 | - if ( get_option( 'wpcom_is_staging_site' ) ) { | |
| 257 | - $badge .= '<span class="site__badge site__badge-staging">' . esc_html__( 'Staging', 'jetpack-masterbar' ) . '</span>'; | |
| 258 | - } | |
| 259 | - | |
| 260 | - if ( ( function_exists( '\Private_Site\site_is_private' ) && \Private_Site\site_is_private() ) || $is_coming_soon ) { | |
| 261 | - $badge .= sprintf( | |
| 262 | - '<span class="site__badge site__badge-private">%s</span>', | |
| 263 | - $is_coming_soon ? esc_html__( 'Coming Soon', 'jetpack-masterbar' ) : esc_html__( 'Private', 'jetpack-masterbar' ) | |
| 264 | - ); | |
| 265 | - } | |
| 266 | - | |
| 267 | - $site_card = ' | |
| 268 | -<div class="site__info"> | |
| 269 | - <div class="site__title">%1$s</div> | |
| 270 | - <div class="site__domain">%2$s</div> | |
| 271 | - %3$s | |
| 272 | -</div>'; | |
| 273 | - | |
| 274 | - $site_card = sprintf( | |
| 275 | - $site_card, | |
| 276 | - $blog_name, | |
| 277 | - $this->domain, | |
| 278 | - $badge | |
| 279 | - ); | |
| 280 | - | |
| 281 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 282 | - add_menu_page( 'site-card', $site_card, 'read', get_home_url(), null, $icon, 1 ); | |
| 283 | - add_filter( 'add_menu_classes', array( $this, 'set_site_card_menu_class' ) ); | |
| 284 | - } | |
| 285 | - | |
| 286 | - /** | |
| 287 | - * Adds a custom element class and id for Site Card's menu item. | |
| 288 | - * | |
| 289 | - * @param array $menu Associative array of administration menu items. | |
| 290 | - * | |
| 291 | - * @return array | |
| 292 | - */ | |
| 293 | - public function set_site_card_menu_class( array $menu ) { | |
| 294 | - foreach ( $menu as $key => $menu_item ) { | |
| 295 | - if ( 'site-card' !== $menu_item[3] ) { | |
| 296 | - continue; | |
| 297 | - } | |
| 298 | - | |
| 299 | - $classes = ' toplevel_page_site-card'; | |
| 300 | - | |
| 301 | - // webclip.png is the default on WoA sites. Anything other than that means we have a custom site icon. | |
| 302 | - if ( has_site_icon() && 'https://s0.wp.com/i/webclip.png' !== get_site_icon_url( 512 ) ) { | |
| 303 | - $classes .= ' has-site-icon'; | |
| 304 | - } | |
| 305 | - | |
| 306 | - $menu[ $key ][4] = $menu_item[4] . $classes; | |
| 307 | - $menu[ $key ][5] = 'toplevel_page_site_card'; | |
| 308 | - break; | |
| 309 | - } | |
| 310 | - | |
| 311 | - return $menu; | |
| 312 | - } | |
| 313 | - | |
| 314 | - /** | |
| 315 | 219 | * Returns the first available upsell nudge. |
| 316 | 220 | * |
| 317 | 221 | * @return array |
| 318 | 222 | */ |
| @@ -318,9 +222,9 @@ | ||
| 318 | 222 | */ |
| 319 | 223 | public function get_upsell_nudge() { |
| 320 | 224 | $jitm = JITM::get_instance(); |
| 321 | 225 | $message_path = 'calypso:sites:sidebar_notice'; |
| 322 | - $message = $jitm->get_messages( $message_path, wp_json_encode( array( 'message_path' => $message_path ) ), false ); | |
| 226 | + $message = $jitm->get_messages( $message_path, array( 'message_path' => $message_path ), false ); | |
| 323 | 227 | |
| 324 | 228 | if ( isset( $message[0] ) ) { |
| 325 | 229 | $message = $message[0]; |
| 326 | 230 | return array( |
| @@ -338,154 +242,8 @@ | ||
| 338 | 242 | } |
| 339 | 243 | } |
| 340 | 244 | |
| 341 | 245 | /** |
| 342 | - * Adds Jetpack menu. | |
| 343 | - */ | |
| 344 | - public function add_jetpack_menu() { | |
| 345 | - // This is supposed to be the same as class-admin-menu but with a different position specified for the Jetpack menu. | |
| 346 | - if ( 'wp-admin' === get_option( 'wpcom_admin_interface' ) ) { | |
| 347 | - parent::create_jetpack_menu( 2, false ); | |
| 348 | - } else { | |
| 349 | - parent::add_jetpack_menu(); | |
| 350 | - } | |
| 351 | - | |
| 352 | - global $submenu; | |
| 353 | - $backup_submenu_label = __( 'Backup', 'jetpack-masterbar' ); | |
| 354 | - $submenu_labels = array_column( $submenu['jetpack'], 3 ); | |
| 355 | - $backup_position = array_search( $backup_submenu_label, $submenu_labels, true ); | |
| 356 | - $scan_position = $backup_position !== false ? $backup_position + 1 : $this->get_submenu_item_count( 'jetpack' ) - 1; | |
| 357 | - | |
| 358 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 359 | - add_submenu_page( 'jetpack', esc_attr__( 'Scan', 'jetpack-masterbar' ), __( 'Scan', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/scan/history/' . $this->domain, null, $scan_position ); | |
| 360 | - | |
| 361 | - /** | |
| 362 | - * Prevent duplicate menu items that link to Jetpack Backup. | |
| 363 | - * Hide the one that's shown when the standalone backup plugin is not installed, since Jetpack Backup is already included in Atomic sites. | |
| 364 | - * | |
| 365 | - * @see https://github.com/Automattic/jetpack/pull/33955 | |
| 366 | - */ | |
| 367 | - $this->hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) ); | |
| 368 | - } | |
| 369 | - | |
| 370 | - /** | |
| 371 | - * Adds Stats menu. | |
| 372 | - */ | |
| 373 | - public function add_stats_menu() { | |
| 374 | - $menu_title = __( 'Stats', 'jetpack-masterbar' ); | |
| 375 | - if ( | |
| 376 | - ! $this->is_api_request && | |
| 377 | - ( new Modules() )->is_active( 'stats' ) && | |
| 378 | - function_exists( 'stats_get_image_chart_src' ) | |
| 379 | - ) { | |
| 380 | - $img_src = esc_attr( | |
| 381 | - stats_get_image_chart_src( 'admin-bar-hours-scale-2x', array( 'masterbar' => '' ) ) | |
| 382 | - ); | |
| 383 | - $alt = esc_attr__( 'Hourly views', 'jetpack-masterbar' ); | |
| 384 | - | |
| 385 | - $menu_title .= "<img class='sidebar-unified__sparkline' src='$img_src' width='80' height='20' alt='$alt'>"; | |
| 386 | - } | |
| 387 | - | |
| 388 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 389 | - add_menu_page( __( 'Stats', 'jetpack-masterbar' ), $menu_title, 'view_stats', 'https://wordpress.com/stats/day/' . $this->domain, null, 'dashicons-chart-bar', 3 ); | |
| 390 | - } | |
| 391 | - | |
| 392 | - /** | |
| 393 | - * Adds Upgrades menu. | |
| 394 | - * | |
| 395 | - * @param string $plan The current WPCOM plan of the blog. | |
| 396 | - */ | |
| 397 | - public function add_upgrades_menu( $plan = null ) { | |
| 398 | - | |
| 399 | - if ( get_option( 'wpcom_is_staging_site' ) ) { | |
| 400 | - return; | |
| 401 | - } | |
| 402 | - $products = Jetpack_Plan::get(); | |
| 403 | - if ( array_key_exists( 'product_name_short', $products ) ) { | |
| 404 | - $plan = $products['product_name_short']; | |
| 405 | - } | |
| 406 | - parent::add_upgrades_menu( $plan ); | |
| 407 | - | |
| 408 | - $last_upgrade_submenu_position = $this->get_submenu_item_count( 'paid-upgrades.php' ); | |
| 409 | - | |
| 410 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 411 | - add_submenu_page( 'paid-upgrades.php', __( 'Domains', 'jetpack-masterbar' ), __( 'Domains', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/domains/manage/' . $this->domain, null, $last_upgrade_submenu_position - 1 ); | |
| 412 | - | |
| 413 | - /** | |
| 414 | - * Whether to show the WordPress.com Emails submenu under the main Upgrades menu. | |
| 415 | - * | |
| 416 | - * @use add_filter( 'jetpack_show_wpcom_upgrades_email_menu', '__return_true' ); | |
| 417 | - * @module masterbar | |
| 418 | - * | |
| 419 | - * @since jetpack-9.7.0 | |
| 420 | - * | |
| 421 | - * @param bool $show_wpcom_upgrades_email_menu Load the WordPress.com Emails submenu item. Default to false. | |
| 422 | - */ | |
| 423 | - if ( apply_filters( 'jetpack_show_wpcom_upgrades_email_menu', false ) ) { | |
| 424 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 425 | - add_submenu_page( 'paid-upgrades.php', __( 'Emails', 'jetpack-masterbar' ), __( 'Emails', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/email/' . $this->domain, null, $last_upgrade_submenu_position ); | |
| 426 | - } | |
| 427 | - } | |
| 428 | - | |
| 429 | - /** | |
| 430 | - * Adds Settings menu. | |
| 431 | - */ | |
| 432 | - public function add_options_menu() { | |
| 433 | - parent::add_options_menu(); | |
| 434 | - | |
| 435 | - if ( Jetpack_Plan::supports( 'security-settings' ) ) { | |
| 436 | - add_submenu_page( | |
| 437 | - 'options-general.php', | |
| 438 | - esc_attr__( 'Security', 'jetpack-masterbar' ), | |
| 439 | - __( 'Security', 'jetpack-masterbar' ), | |
| 440 | - 'manage_options', | |
| 441 | - 'https://wordpress.com/settings/security/' . $this->domain, | |
| 442 | - null, // @phan-suppress-current-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 443 | - 2 | |
| 444 | - ); | |
| 445 | - } | |
| 446 | - | |
| 447 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 448 | - add_submenu_page( 'options-general.php', esc_attr__( 'Hosting Configuration', 'jetpack-masterbar' ), __( 'Hosting Configuration', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/hosting-config/' . $this->domain, null, 11 ); | |
| 449 | - | |
| 450 | - // Page Optimize is active by default on all Atomic sites and registers a Settings > Performance submenu which | |
| 451 | - // would conflict with our own Settings > Performance that links to Calypso, so we hide it it since the Calypso | |
| 452 | - // performance settings already have a link to Page Optimize settings page. | |
| 453 | - $this->hide_submenu_page( 'options-general.php', 'page-optimize' ); | |
| 454 | - | |
| 455 | - // Hide Settings > Performance when the interface is set to wp-admin. | |
| 456 | - // This is due to these settings are mostly also available in Jetpack > Settings, in the Performance tab. | |
| 457 | - if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) { | |
| 458 | - $this->hide_submenu_page( 'options-general.php', 'https://wordpress.com/settings/performance/' . $this->domain ); | |
| 459 | - } | |
| 460 | - } | |
| 461 | - | |
| 462 | - /** | |
| 463 | - * Adds Tools menu entries. | |
| 464 | - */ | |
| 465 | - public function add_tools_menu() { | |
| 466 | - parent::add_tools_menu(); | |
| 467 | - | |
| 468 | - // Link the Tools menu to Available Tools when the interface is set to wp-admin. | |
| 469 | - if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) { | |
| 470 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 471 | - add_submenu_page( 'tools.php', esc_attr__( 'Available Tools', 'jetpack-masterbar' ), __( 'Available Tools', 'jetpack-masterbar' ), 'edit_posts', 'tools.php', null, 0 ); | |
| 472 | - } | |
| 473 | - | |
| 474 | - /** | |
| 475 | - * Adds the WordPress.com Site Monitoring submenu under the main Tools menu. | |
| 476 | - */ | |
| 477 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 478 | - add_submenu_page( 'tools.php', esc_attr__( 'Site Monitoring', 'jetpack-masterbar' ), __( 'Site Monitoring', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/site-monitoring/' . $this->domain, null, 7 ); | |
| 479 | - | |
| 480 | - /** | |
| 481 | - * Adds the WordPress.com GitHub Deployments submenu under the main Tools menu. | |
| 482 | - */ | |
| 483 | - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539. | |
| 484 | - add_submenu_page( 'tools.php', esc_attr__( 'GitHub Deployments', 'jetpack-masterbar' ), __( 'GitHub Deployments', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/github-deployments/' . $this->domain, null, 8 ); | |
| 485 | - } | |
| 486 | - | |
| 487 | - /** | |
| 488 | 246 | * Override the global submenu_file for theme-install.php page so the WP Admin menu item gets highlighted correctly. |
| 489 | 247 | * |
| 490 | 248 | * @param string $submenu_file The current pages $submenu_file global variable value. |
| 491 | 249 | * @return string | null |
| @@ -534,57 +292,6 @@ | ||
| 534 | 292 | if ( isset( $_REQUEST['id'] ) && isset( $_REQUEST['feature_class'] ) ) { |
| 535 | 293 | $jitm->dismiss( sanitize_text_field( wp_unslash( $_REQUEST['id'] ) ), sanitize_text_field( wp_unslash( $_REQUEST['feature_class'] ) ) ); |
| 536 | 294 | } |
| 537 | 295 | wp_die(); |
| 538 | - } | |
| 539 | - | |
| 540 | - /** | |
| 541 | - * Adds a notice above each settings page while using the Classic view to indicate | |
| 542 | - * that the Default view offers more features. Links to the default view. | |
| 543 | - * | |
| 544 | - * @return void | |
| 545 | - */ | |
| 546 | - public function add_settings_page_notice() { | |
| 547 | - if ( ! is_admin() ) { | |
| 548 | - return; | |
| 549 | - } | |
| 550 | - | |
| 551 | - $current_screen = get_current_screen(); | |
| 552 | - | |
| 553 | - if ( ! $current_screen instanceof \WP_Screen ) { | |
| 554 | - return; | |
| 555 | - } | |
| 556 | - | |
| 557 | - // Show the notice for the following screens and map them to the Calypso page. | |
| 558 | - $screen_map = array( | |
| 559 | - 'options-general' => 'general', | |
| 560 | - 'options-reading' => 'reading', | |
| 561 | - ); | |
| 562 | - | |
| 563 | - $mapped_screen = $screen_map[ $current_screen->id ] ?? false; | |
| 564 | - | |
| 565 | - if ( ! $mapped_screen ) { | |
| 566 | - return; | |
| 567 | - } | |
| 568 | - | |
| 569 | - $switch_url = sprintf( 'https://wordpress.com/settings/%s/%s', $mapped_screen, $this->domain ); | |
| 570 | - | |
| 571 | - // Close over the $switch_url variable. | |
| 572 | - $admin_notices = function () use ( $switch_url ) { | |
| 573 | - wp_admin_notice( | |
| 574 | - wp_kses( | |
| 575 | - sprintf( | |
| 576 | - // translators: %s is a link to the Calypso settings page. | |
| 577 | - __( 'You are currently using the Classic view, which doesn’t offer the same set of features as the Default view. To access additional settings and features, <a href="%s">switch to the Default view</a>. ', 'jetpack-masterbar' ), | |
| 578 | - esc_url( $switch_url ) | |
| 579 | - ), | |
| 580 | - array( 'a' => array( 'href' => array() ) ) | |
| 581 | - ), | |
| 582 | - array( | |
| 583 | - 'type' => 'warning', | |
| 584 | - ) | |
| 585 | - ); | |
| 586 | - }; | |
| 587 | - | |
| 588 | - add_action( 'admin_notices', $admin_notices ); | |
| 589 | 296 | } |
| 590 | 297 | } |