admin-menu-nav-unification-rtl.css
2 years ago
admin-menu-nav-unification-rtl.min.css
2 years ago
admin-menu-nav-unification.css
2 years ago
admin-menu-nav-unification.min.css
2 years ago
admin-menu-rtl.css
2 years ago
admin-menu-rtl.min.css
2 years ago
admin-menu.css
2 years ago
admin-menu.js
2 years ago
admin-menu.min.css
2 years ago
class-admin-menu.php
2 years ago
class-atomic-admin-menu.php
2 years ago
class-dashboard-switcher-tracking.php
2 years ago
class-domain-only-admin-menu.php
2 years ago
class-jetpack-admin-menu.php
2 years ago
class-p2-admin-menu.php
2 years ago
class-wpcom-admin-menu.php
2 years ago
class-wpcom-email-subscription-checker.php
2 years ago
dashicon-set.php
2 years ago
globe-icon.svg
2 years ago
load.php
2 years ago
menu-mappings.php
2 years ago
load.php
191 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin Menu loader. |
| 4 | * |
| 5 | * @deprecated 13.7 |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | * |
| 9 | * @phan-file-suppress PhanDeprecatedFunction -- Ok for deprecated code to call other deprecated code. |
| 10 | */ |
| 11 | |
| 12 | namespace Automattic\Jetpack\Dashboard_Customizations; |
| 13 | |
| 14 | _deprecated_file( __FILE__, 'jetpack-13.7' ); |
| 15 | |
| 16 | use Automattic\Jetpack\Masterbar\Base_Admin_Menu; |
| 17 | use Automattic\Jetpack\Status\Host; |
| 18 | use Automattic\Jetpack\Tracking; |
| 19 | |
| 20 | /** |
| 21 | * Checks whether the navigation customizations should be performed for the given class. |
| 22 | * |
| 23 | * @deprecated 13.7 |
| 24 | * |
| 25 | * @param string $admin_menu_class Class name. |
| 26 | * |
| 27 | * @return bool |
| 28 | */ |
| 29 | function should_customize_nav( $admin_menu_class ) { |
| 30 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\should_customize_nav' ); |
| 31 | // Make sure the class extends the base admin menu class. |
| 32 | if ( ! is_subclass_of( $admin_menu_class, Base_Admin_Menu::class ) ) { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | $is_api_request = defined( 'REST_REQUEST' ) && REST_REQUEST || isset( $_SERVER['REQUEST_URI'] ) && str_starts_with( filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/?rest_route=%2Fwpcom%2Fv2%2Fadmin-menu' ); |
| 37 | |
| 38 | // No nav customizations on WP Admin of Atomic sites when SSO is disabled. |
| 39 | if ( is_a( $admin_menu_class, Atomic_Admin_Menu::class, true ) && ! $is_api_request && ! \Jetpack::is_module_active( 'sso' ) ) { |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | // No nav customizations on WP Admin of Jetpack sites. |
| 44 | if ( is_a( $admin_menu_class, Jetpack_Admin_Menu::class, true ) && ! $is_api_request ) { |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Hides the Customizer menu items when the block theme is active by removing the dotcom-specific actions. |
| 53 | * They are not needed for block themes. |
| 54 | * |
| 55 | * @deprecated 13.7 |
| 56 | * |
| 57 | * @see https://github.com/Automattic/jetpack/pull/36017 |
| 58 | */ |
| 59 | function hide_customizer_menu_on_block_theme() { |
| 60 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\hide_customizer_menu_on_block_theme' ); |
| 61 | add_action( |
| 62 | 'init', |
| 63 | function () { |
| 64 | if ( wp_is_block_theme() && ! is_customize_preview() ) { |
| 65 | remove_action( 'customize_register', 'add_logotool_button', 20 ); |
| 66 | remove_action( 'customize_register', 'footercredits_register', 99 ); |
| 67 | remove_action( 'customize_register', 'wpcom_disable_customizer_site_icon', 20 ); |
| 68 | |
| 69 | if ( class_exists( '\Jetpack_Fonts' ) ) { |
| 70 | $jetpack_fonts_instance = \Jetpack_Fonts::get_instance(); |
| 71 | remove_action( 'customize_register', array( $jetpack_fonts_instance, 'register_controls' ) ); |
| 72 | remove_action( 'customize_register', array( $jetpack_fonts_instance, 'maybe_prepopulate_option' ), 0 ); |
| 73 | } |
| 74 | |
| 75 | remove_action( 'customize_register', array( 'Jetpack_Fonts_Typekit', 'maybe_override_for_advanced_mode' ), 20 ); |
| 76 | |
| 77 | remove_action( 'customize_register', 'Automattic\Jetpack\Dashboard_Customizations\register_css_nudge_control' ); |
| 78 | |
| 79 | // @phan-suppress-next-line PhanUndeclaredClassInCallable |
| 80 | remove_action( 'customize_register', array( 'Jetpack_Custom_CSS_Enhancements', 'customize_register' ) ); |
| 81 | } |
| 82 | } |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Gets the name of the class that customizes the admin menu. |
| 88 | * |
| 89 | * @deprecated 13.7 |
| 90 | * |
| 91 | * @return string Class name. |
| 92 | */ |
| 93 | function get_admin_menu_class() { |
| 94 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\get_admin_menu_class' ); |
| 95 | hide_customizer_menu_on_block_theme(); |
| 96 | |
| 97 | // WordPress.com Atomic sites. |
| 98 | if ( ( new Host() )->is_woa_site() ) { |
| 99 | |
| 100 | // DIFM Lite In Progress Atomic Sites. Uses the same menu used for domain-only sites. |
| 101 | // Ignore this check if we are in a support session. |
| 102 | $is_difm_lite_in_progress = wpcomsh_is_site_sticker_active( 'difm-lite-in-progress' ); |
| 103 | $is_support_session = defined( 'WPCOM_SUPPORT_SESSION' ) && WPCOM_SUPPORT_SESSION; |
| 104 | if ( $is_difm_lite_in_progress && ! $is_support_session ) { |
| 105 | require_once __DIR__ . '/class-domain-only-admin-menu.php'; |
| 106 | return Domain_Only_Admin_Menu::class; |
| 107 | } |
| 108 | |
| 109 | require_once __DIR__ . '/class-atomic-admin-menu.php'; |
| 110 | return Atomic_Admin_Menu::class; |
| 111 | } |
| 112 | |
| 113 | // WordPress.com Simple sites. |
| 114 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
| 115 | $blog_id = get_current_blog_id(); |
| 116 | |
| 117 | // Domain-only sites. |
| 118 | $blog_options = get_blog_option( $blog_id, 'options' ); |
| 119 | $is_domain_only = ! empty( $blog_options['is_domain_only'] ); |
| 120 | if ( $is_domain_only ) { |
| 121 | require_once __DIR__ . '/class-domain-only-admin-menu.php'; |
| 122 | return Domain_Only_Admin_Menu::class; |
| 123 | } |
| 124 | |
| 125 | // DIFM Lite In Progress Sites. Uses the same menu used for domain-only sites. |
| 126 | // Ignore this check if we are in a support session. |
| 127 | $is_difm_lite_in_progress = has_blog_sticker( 'difm-lite-in-progress' ); |
| 128 | $is_support_session = defined( 'WPCOM_SUPPORT_SESSION' ) && WPCOM_SUPPORT_SESSION; |
| 129 | if ( $is_difm_lite_in_progress && ! $is_support_session ) { |
| 130 | require_once __DIR__ . '/class-domain-only-admin-menu.php'; |
| 131 | return Domain_Only_Admin_Menu::class; |
| 132 | } |
| 133 | |
| 134 | // P2 sites. |
| 135 | require_once WP_CONTENT_DIR . '/lib/wpforteams/functions.php'; |
| 136 | if ( \WPForTeams\is_wpforteams_site( $blog_id ) ) { |
| 137 | require_once __DIR__ . '/class-p2-admin-menu.php'; |
| 138 | return P2_Admin_Menu::class; |
| 139 | } |
| 140 | |
| 141 | // Rest of simple sites. |
| 142 | require_once __DIR__ . '/class-wpcom-admin-menu.php'; |
| 143 | return WPcom_Admin_Menu::class; |
| 144 | } |
| 145 | |
| 146 | // Jetpack sites. |
| 147 | require_once __DIR__ . '/class-jetpack-admin-menu.php'; |
| 148 | return Jetpack_Admin_Menu::class; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Filters the name of the class that customizes the admin menu. It should extends the `Base_Admin_Menu` class. |
| 153 | * |
| 154 | * @module masterbar |
| 155 | * |
| 156 | * @since 9.6.0 |
| 157 | * |
| 158 | * @param string $admin_menu_class Class name. |
| 159 | */ |
| 160 | $admin_menu_class = apply_filters( 'jetpack_admin_menu_class', get_admin_menu_class() ); |
| 161 | if ( should_customize_nav( $admin_menu_class ) ) { |
| 162 | /** The admin menu singleton instance. @var Base_Admin_Menu $instance */ |
| 163 | $admin_menu_class::get_instance(); |
| 164 | |
| 165 | /** |
| 166 | * Trigger an event when the user uses the dashboard quick switcher. |
| 167 | * |
| 168 | * @deprecated 13.7 |
| 169 | * |
| 170 | * @param string $screen The current screen. |
| 171 | * @param string $view The view the user choosed to go to. |
| 172 | */ |
| 173 | function dashboard_quick_switcher_record_usage( $screen, $view ) { |
| 174 | _deprecated_function( __FUNCTION__, 'jetpack-13.7', 'Automattic\\Jetpack\\Masterbar\\dashboard_quick_switcher_record_usage' ); |
| 175 | |
| 176 | require_once __DIR__ . '/class-dashboard-switcher-tracking.php'; |
| 177 | |
| 178 | $tracking = new Dashboard_Switcher_Tracking( |
| 179 | new Tracking( Dashboard_Switcher_Tracking::get_jetpack_tracking_product() ), |
| 180 | array( Dashboard_Switcher_Tracking::class, 'wpcom_tracks_record_event' ), |
| 181 | Dashboard_Switcher_Tracking::get_plan() |
| 182 | ); |
| 183 | |
| 184 | $tracking->record_switch_event( $screen, $view ); |
| 185 | } |
| 186 | |
| 187 | \add_action( 'jetpack_dashboard_switcher_changed_view', __NAMESPACE__ . '\dashboard_quick_switcher_record_usage', 10, 2 ); |
| 188 | } else { |
| 189 | \add_filter( 'jetpack_load_admin_menu_class', '__return_false' ); |
| 190 | } |
| 191 |