← All changes
|
_inc/lib/admin-pages/class.jetpack-admin-page.php
+128
-130
12.4.2
→
16.3-a.5
View file →
| @@ -6,21 +6,25 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Current_Plan as Jetpack_Plan; |
| 9 | 9 | use Automattic\Jetpack\Identity_Crisis; |
| 10 | +use Automattic\Jetpack\Plugin\Admin_Chrome_Logo; | |
| 11 | +use Automattic\Jetpack\Plugin\Footer_Links; | |
| 10 | 12 | use Automattic\Jetpack\Redirect; |
| 11 | 13 | use Automattic\Jetpack\Status; |
| 14 | +use Automattic\Jetpack\Status\Host; | |
| 12 | 15 | |
| 13 | 16 | /** |
| 14 | 17 | * Shared logic between Jetpack admin pages. |
| 15 | 18 | */ |
| 16 | 19 | abstract class Jetpack_Admin_Page { |
| 20 | + | |
| 17 | 21 | /** |
| 18 | - * Jetpack Object. | |
| 22 | + * Determines whether or not to hide if not active. | |
| 19 | 23 | * |
| 20 | - * @var Jetpack | |
| 24 | + * @var bool | |
| 21 | 25 | */ |
| 22 | - public $jetpack; | |
| 26 | + protected $dont_show_if_not_active; | |
| 23 | 27 | |
| 24 | 28 | /** |
| 25 | 29 | * Add page specific actions given the page hook. |
| 26 | 30 | * |
| @@ -45,15 +49,8 @@ | ||
| 45 | 49 | */ |
| 46 | 50 | abstract public function page_render(); |
| 47 | 51 | |
| 48 | 52 | /** |
| 49 | - * Should we block the page rendering because the site is in IDC? | |
| 50 | - * | |
| 51 | - * @var bool | |
| 52 | - */ | |
| 53 | - public static $block_page_rendering_for_idc; | |
| 54 | - | |
| 55 | - /** | |
| 56 | 53 | * Function called after admin_styles to load any additional needed styles. |
| 57 | 54 | * |
| 58 | 55 | * @since 4.3.0 |
| 59 | 56 | */ |
| @@ -59,28 +56,8 @@ | ||
| 59 | 56 | */ |
| 60 | 57 | public function additional_styles() {} |
| 61 | 58 | |
| 62 | 59 | /** |
| 63 | - * The constructor. | |
| 64 | - */ | |
| 65 | - public function __construct() { | |
| 66 | - add_action( 'jetpack_loaded', array( $this, 'on_jetpack_loaded' ) ); | |
| 67 | - } | |
| 68 | - | |
| 69 | - /** | |
| 70 | - * Runs on Jetpack being ready to load its packages. | |
| 71 | - * | |
| 72 | - * @param Jetpack $jetpack object. | |
| 73 | - */ | |
| 74 | - public function on_jetpack_loaded( $jetpack ) { | |
| 75 | - $this->jetpack = $jetpack; | |
| 76 | - | |
| 77 | - self::$block_page_rendering_for_idc = ( | |
| 78 | - Jetpack::is_connection_ready() && Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' ) | |
| 79 | - ); | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | 60 | * Add common page actions and attach page-specific actions. |
| 84 | 61 | */ |
| 85 | 62 | public function add_actions() { |
| 86 | 63 | $is_offline_mode = ( new Status() )->is_offline_mode(); |
| @@ -103,17 +80,13 @@ | ||
| 103 | 80 | // Initialize menu item for the page in the admin. |
| 104 | 81 | $hook = $this->get_page_hook(); |
| 105 | 82 | |
| 106 | 83 | // Attach hooks common to all Jetpack admin pages based on the created hook. |
| 107 | - add_action( "load-$hook", array( $this, 'admin_help' ) ); | |
| 108 | 84 | add_action( "load-$hook", array( $this, 'admin_page_load' ) ); |
| 109 | 85 | add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) ); |
| 110 | 86 | add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) ); |
| 87 | + add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) ); | |
| 111 | 88 | |
| 112 | - if ( ! self::$block_page_rendering_for_idc ) { | |
| 113 | - add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) ); | |
| 114 | - } | |
| 115 | - | |
| 116 | 89 | // Check if the site plan changed and deactivate modules accordingly. |
| 117 | 90 | add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) ); |
| 118 | 91 | |
| 119 | 92 | // Attach page specific actions in addition to the above. |
| @@ -118,43 +91,26 @@ | ||
| 118 | 91 | |
| 119 | 92 | // Attach page specific actions in addition to the above. |
| 120 | 93 | $this->add_page_actions( $hook ); |
| 121 | 94 | |
| 122 | - // If the current user can connect Jetpack, Jetpack isn't connected, and is not in offline mode, let's prompt! | |
| 123 | - if ( current_user_can( 'jetpack_connect' ) && $connectable ) { | |
| 124 | - $this->add_connection_banner_actions(); | |
| 125 | - } | |
| 95 | + // Override the page title for the module list page and the debugger page. | |
| 96 | + add_action( 'current_screen', array( __CLASS__, 'override_page_title' ) ); | |
| 126 | 97 | } |
| 127 | 98 | |
| 128 | 99 | /** |
| 129 | - * Hooks to add when Jetpack is not active or in offline mode for an user capable of connecting. | |
| 130 | - */ | |
| 131 | - private function add_connection_banner_actions() { | |
| 132 | - global $pagenow; | |
| 133 | - // If someone just activated Jetpack, let's show them a fullscreen connection banner. | |
| 134 | - if ( ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 135 | - add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_banner_scripts' ) ); | |
| 136 | - add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_connect_button_scripts' ) ); | |
| 137 | - delete_transient( 'activated_jetpack' ); | |
| 138 | - } | |
| 139 | - | |
| 140 | - // If Jetpack not yet connected, but user is viewing one of the pages with a Jetpack connection banner. | |
| 141 | - if ( ( 'index.php' === $pagenow || 'plugins.php' === $pagenow ) ) { | |
| 142 | - add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_connect_button_scripts' ) ); | |
| 143 | - } | |
| 144 | - } | |
| 145 | - | |
| 146 | - /** | |
| 147 | 100 | * Render the page with a common top and bottom part, and page specific content. |
| 148 | 101 | */ |
| 149 | 102 | public function render() { |
| 103 | + /** This action is documented in class.jetpack.php */ | |
| 104 | + do_action( 'jetpack_initialize_tracking' ); | |
| 105 | + | |
| 150 | 106 | // We're in an IDC: we need a decision made before we show the UI again. |
| 151 | - if ( self::$block_page_rendering_for_idc ) { | |
| 107 | + if ( $this->block_page_rendering_for_idc() ) { | |
| 152 | 108 | return; |
| 153 | 109 | } |
| 154 | 110 | |
| 155 | - // Check if we are looking at the main dashboard. | |
| 156 | - if ( isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic. | |
| 111 | + // The Settings app draws its own header and footer. | |
| 112 | + if ( isset( $_GET['page'] ) && 'jetpack-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic. | |
| 157 | 113 | $this->page_render(); |
| 158 | 114 | return; |
| 159 | 115 | } |
| 160 | 116 | |
| @@ -161,9 +117,10 @@ | ||
| 161 | 117 | $args = array(); |
| 162 | 118 | |
| 163 | 119 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 164 | 120 | if ( isset( $_GET['page'] ) && 'jetpack_modules' === $_GET['page'] ) { |
| 165 | - $args['is-wide'] = true; | |
| 121 | + $args['is-wide'] = true; | |
| 122 | + $args['show-nav'] = false; | |
| 166 | 123 | } |
| 167 | 124 | |
| 168 | 125 | self::wrap_ui( array( $this, 'page_render' ), $args ); |
| 169 | 126 | } |
| @@ -168,21 +125,12 @@ | ||
| 168 | 125 | self::wrap_ui( array( $this, 'page_render' ), $args ); |
| 169 | 126 | } |
| 170 | 127 | |
| 171 | 128 | /** |
| 172 | - * Load Help tab. | |
| 173 | - * | |
| 174 | - * @todo This may no longer be used. | |
| 175 | - */ | |
| 176 | - public function admin_help() { | |
| 177 | - $this->jetpack->admin_help(); | |
| 178 | - } | |
| 179 | - | |
| 180 | - /** | |
| 181 | 129 | * Call the existing admin page events. |
| 182 | 130 | */ |
| 183 | 131 | public function admin_page_load() { |
| 184 | - $this->jetpack->admin_page_load(); | |
| 132 | + Jetpack::init()->admin_page_load(); | |
| 185 | 133 | } |
| 186 | 134 | |
| 187 | 135 | /** |
| 188 | 136 | * Add page specific scripts and jetpack stats for all menu pages. |
| @@ -188,9 +136,9 @@ | ||
| 188 | 136 | * Add page specific scripts and jetpack stats for all menu pages. |
| 189 | 137 | */ |
| 190 | 138 | public function admin_scripts() { |
| 191 | 139 | $this->page_admin_scripts(); // Delegate to inheriting class. |
| 192 | - add_action( 'admin_footer', array( $this->jetpack, 'do_stats' ) ); | |
| 140 | + add_action( 'admin_footer', array( Jetpack::init(), 'do_stats' ) ); | |
| 193 | 141 | } |
| 194 | 142 | |
| 195 | 143 | /** |
| 196 | 144 | * Enqueue the Jetpack admin stylesheet. |
| @@ -197,9 +145,9 @@ | ||
| 197 | 145 | */ |
| 198 | 146 | public function admin_styles() { |
| 199 | 147 | $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 200 | 148 | |
| 201 | - wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons' ), JETPACK__VERSION . '-20121016' ); | |
| 149 | + wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons', 'jetpack-connection' ), JETPACK__VERSION . '-20121016' ); | |
| 202 | 150 | wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' ); |
| 203 | 151 | wp_style_add_data( 'jetpack-admin', 'suffix', $min ); |
| 204 | 152 | } |
| 205 | 153 | |
| @@ -217,8 +165,28 @@ | ||
| 217 | 165 | apply_filters( 'rest_authentication_errors', true ); |
| 218 | 166 | } |
| 219 | 167 | |
| 220 | 168 | /** |
| 169 | + * Fallback redirect meta tag if the REST API is disabled. | |
| 170 | + * | |
| 171 | + * @return void | |
| 172 | + */ | |
| 173 | + public function add_fallback_head_meta() { | |
| 174 | + echo '<meta http-equiv="refresh" content="0; url=?page=jetpack_modules">'; | |
| 175 | + } | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * Fallback meta tag wrapped in noscript tags for all browsers in case they have JavaScript disabled. | |
| 179 | + * | |
| 180 | + * @return void | |
| 181 | + */ | |
| 182 | + public function add_noscript_head_meta() { | |
| 183 | + echo '<noscript>'; | |
| 184 | + $this->add_fallback_head_meta(); | |
| 185 | + echo '</noscript>'; | |
| 186 | + } | |
| 187 | + | |
| 188 | + /** | |
| 221 | 189 | * Checks the site plan and deactivates modules that were active but are no longer included in the plan. |
| 222 | 190 | * |
| 223 | 191 | * @since 4.4.0 |
| 224 | 192 | * |
| @@ -232,8 +200,9 @@ | ||
| 232 | 200 | || ! in_array( |
| 233 | 201 | $page->base, |
| 234 | 202 | array( |
| 235 | 203 | 'toplevel_page_jetpack', |
| 204 | + 'jetpack_page_jetpack-settings', | |
| 236 | 205 | 'admin_page_jetpack_modules', |
| 237 | 206 | 'jetpack_page_vaultpress', |
| 238 | 207 | 'jetpack_page_stats', |
| 239 | 208 | 'jetpack_page_akismet-key-config', |
| @@ -291,12 +260,12 @@ | ||
| 291 | 260 | |
| 292 | 261 | /** |
| 293 | 262 | * Build header, content, and footer for admin page. |
| 294 | 263 | * |
| 295 | - * @param string $callback Callback to produce the content of the page. The callback is responsible for any needed escaping. | |
| 296 | - * @param array $args Options for the wrapping. Also passed to the `jetpack_admin_pages_wrap_ui_after_callback` action. | |
| 297 | - * - is-wide: (bool) Set the "is-wide" class on the wrapper div, which increases the max width. Default false. | |
| 298 | - * - show-nav: (bool) Whether to show the navigation bar at the top of the page. Default true. | |
| 264 | + * @param callable $callback Callback to produce the content of the page. The callback is responsible for any needed escaping. | |
| 265 | + * @param array $args Options for the wrapping. Also passed to the `jetpack_admin_pages_wrap_ui_after_callback` action. | |
| 266 | + * - is-wide: (bool) Set the "is-wide" class on the wrapper div, which increases the max width. Default false. | |
| 267 | + * - show-nav: (bool) Whether to show the navigation bar at the top of the page. Default true. | |
| 299 | 268 | */ |
| 300 | 269 | public static function wrap_ui( $callback, $args = array() ) { |
| 301 | 270 | $defaults = array( |
| 302 | 271 | 'is-wide' => false, |
| @@ -308,19 +277,16 @@ | ||
| 308 | 277 | // True means that Jetpack is NOT connected and NOT in offline mode. |
| 309 | 278 | // If Jetpack is connected OR in offline mode, this will be false. |
| 310 | 279 | $connectable = ! Jetpack::is_connection_ready() && ! ( new Status() )->is_offline_mode(); |
| 311 | 280 | |
| 312 | - $jetpack_admin_url = admin_url( 'admin.php?page=jetpack' ); | |
| 281 | + $my_jetpack_available = Footer_Links::is_my_jetpack_available(); | |
| 282 | + $my_jetpack_url = admin_url( 'admin.php?page=my-jetpack#/overview' ); | |
| 283 | + $jetpack_logo = Admin_Chrome_Logo::render( 20, '', __( 'Jetpack logo', 'jetpack' ) ); | |
| 284 | + | |
| 313 | 285 | $jetpack_about_url = ! $connectable |
| 314 | 286 | ? admin_url( 'admin.php?page=jetpack_about' ) |
| 315 | 287 | : Redirect::get_url( 'jetpack' ); |
| 316 | 288 | |
| 317 | - $jetpack_privacy_url = ! $connectable | |
| 318 | - ? $jetpack_admin_url . '#/privacy' | |
| 319 | - : Redirect::get_url( 'a8c-privacy' ); | |
| 320 | - | |
| 321 | - $external_link_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" class="jp-footer__menu-item__icon" aria-hidden="true" focusable="false"><path d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"></path></svg>'; | |
| 322 | - | |
| 323 | 289 | ?> |
| 324 | 290 | <div id="jp-plugin-container" class=" |
| 325 | 291 | <?php |
| 326 | 292 | if ( $args['is-wide'] ) { |
| @@ -327,17 +293,51 @@ | ||
| 327 | 293 | echo 'is-wide'; } |
| 328 | 294 | ?> |
| 329 | 295 | "> |
| 330 | 296 | |
| 331 | - <div class="jp-masthead jp-masthead-middle"> | |
| 297 | + <header class="jp-masthead"> | |
| 332 | 298 | <div class="jp-masthead__inside-container"> |
| 333 | - <div class="jp-masthead__logo-container"> | |
| 334 | - <a class="jp-masthead__logo-link" href="<?php echo esc_url( $jetpack_admin_url ); ?>"> | |
| 335 | - <svg class="jetpack-logo__masthead" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="40" viewBox="0 0 118 32"><path fill="#069e08" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"></path><path d="M41.3,26.6c-0.5-0.7-0.9-1.4-1.3-2.1c2.3-1.4,3-2.5,3-4.6V8h-3V6h6v13.4C46,22.8,45,24.8,41.3,26.6z"></path><path d="M65,18.4c0,1.1,0.8,1.3,1.4,1.3c0.5,0,2-0.2,2.6-0.4v2.1c-0.9,0.3-2.5,0.5-3.7,0.5c-1.5,0-3.2-0.5-3.2-3.1V12H60v-2h2.1V7.1 H65V10h4v2h-4V18.4z"></path><path d="M71,10h3v1.3c1.1-0.8,1.9-1.3,3.3-1.3c2.5,0,4.5,1.8,4.5,5.6s-2.2,6.3-5.8,6.3c-0.9,0-1.3-0.1-2-0.3V28h-3V10z M76.5,12.3 c-0.8,0-1.6,0.4-2.5,1.2v5.9c0.6,0.1,0.9,0.2,1.8,0.2c2,0,3.2-1.3,3.2-3.9C79,13.4,78.1,12.3,76.5,12.3z"></path><path d="M93,22h-3v-1.5c-0.9,0.7-1.9,1.5-3.5,1.5c-1.5,0-3.1-1.1-3.1-3.2c0-2.9,2.5-3.4,4.2-3.7l2.4-0.3v-0.3c0-1.5-0.5-2.3-2-2.3 c-0.7,0-2.3,0.5-3.7,1.1L84,11c1.2-0.4,3-1,4.4-1c2.7,0,4.6,1.4,4.6,4.7L93,22z M90,16.4l-2.2,0.4c-0.7,0.1-1.4,0.5-1.4,1.6 c0,0.9,0.5,1.4,1.3,1.4s1.5-0.5,2.3-1V16.4z"></path><path d="M104.5,21.3c-1.1,0.4-2.2,0.6-3.5,0.6c-4.2,0-5.9-2.4-5.9-5.9c0-3.7,2.3-6,6.1-6c1.4,0,2.3,0.2,3.2,0.5V13 c-0.8-0.3-2-0.6-3.2-0.6c-1.7,0-3.2,0.9-3.2,3.6c0,2.9,1.5,3.8,3.3,3.8c0.9,0,1.9-0.2,3.2-0.7V21.3z"></path><path d="M110,15.2c0.2-0.3,0.2-0.8,3.8-5.2h3.7l-4.6,5.7l5,6.3h-3.7l-4.2-5.8V22h-3V6h3V15.2z"></path><path d="M58.5,21.3c-1.5,0.5-2.7,0.6-4.2,0.6c-3.6,0-5.8-1.8-5.8-6c0-3.1,1.9-5.9,5.5-5.9s4.9,2.5,4.9,4.9c0,0.8,0,1.5-0.1,2h-7.3 c0.1,2.5,1.5,2.8,3.6,2.8c1.1,0,2.2-0.3,3.4-0.7C58.5,19,58.5,21.3,58.5,21.3z M56,15c0-1.4-0.5-2.9-2-2.9c-1.4,0-2.3,1.3-2.4,2.9 C51.6,15,56,15,56,15z"></path></svg> | |
| 336 | - </a> | |
| 299 | + <div class="jp-masthead__title-container"> | |
| 300 | + <?php if ( $my_jetpack_available ) : ?> | |
| 301 | + <a class="jp-masthead__logo-link" href="<?php echo esc_url( $my_jetpack_url ); ?>"><?php echo $jetpack_logo; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Static SVG built above. ?></a> | |
| 302 | + <?php else : ?> | |
| 303 | + <span class="jp-masthead__logo-link"><?php echo $jetpack_logo; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Static SVG built above. ?></span> | |
| 304 | + <?php endif; ?> | |
| 305 | + <h2 class="jp-masthead__title"> | |
| 306 | + <?php | |
| 307 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic only. | |
| 308 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; | |
| 309 | + $is_offline_mode = ( new Status() )->is_offline_mode(); | |
| 310 | + $current_label = ''; | |
| 311 | + if ( 'jetpack_modules' === $page ) { | |
| 312 | + $current_label = __( 'Modules', 'jetpack' ); | |
| 313 | + } elseif ( 'jetpack_about' === $page ) { | |
| 314 | + $current_label = __( 'About', 'jetpack' ); | |
| 315 | + } elseif ( 'jetpack-debugger' === $page ) { | |
| 316 | + $current_label = __( 'Debug', 'jetpack' ); | |
| 317 | + } | |
| 318 | + | |
| 319 | + // "Jetpack" is a product name, do not translate. | |
| 320 | + ?> | |
| 321 | + <?php if ( $current_label ) : ?> | |
| 322 | + <?php if ( $my_jetpack_available ) : ?> | |
| 323 | + <a class="jp-masthead__title-link" href="<?php echo esc_url( $my_jetpack_url ); ?>">Jetpack</a> | |
| 324 | + <?php else : ?> | |
| 325 | + Jetpack | |
| 326 | + <?php endif; ?> | |
| 327 | + <span class="jp-masthead__title-separator" aria-hidden="true">/</span> | |
| 328 | + <?php if ( $is_offline_mode ) : ?> | |
| 329 | + <span class="jp-masthead__title-offline"><?php esc_html_e( 'Offline Mode', 'jetpack' ); ?></span> | |
| 330 | + <span class="jp-masthead__title-separator" aria-hidden="true">/</span> | |
| 331 | + <?php endif; ?> | |
| 332 | + <span class="jp-masthead__title-current"><?php echo esc_html( $current_label ); ?></span> | |
| 333 | + <?php else : ?> | |
| 334 | + Jetpack | |
| 335 | + <?php endif; ?> | |
| 336 | + </h2> | |
| 337 | 337 | </div> |
| 338 | 338 | <?php |
| 339 | - if ( $args['show-nav'] ) : | |
| 339 | + if ( $args['show-nav'] && ! ( new Host() )->is_wpcom_platform() ) : | |
| 340 | 340 | ?> |
| 341 | 341 | <div class="jp-masthead__nav"> |
| 342 | 342 | <?php |
| 343 | 343 | if ( is_network_admin() ) { |
| @@ -358,24 +358,17 @@ | ||
| 358 | 358 | <?php |
| 359 | 359 | } |
| 360 | 360 | ?> |
| 361 | 361 | </span> |
| 362 | - <?php } else { ?> | |
| 362 | + <?php } elseif ( current_user_can( 'jetpack_manage_modules' ) ) { ?> | |
| 363 | 363 | <span class="dops-button-group"> |
| 364 | - <a href="<?php echo esc_url( $jetpack_admin_url ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Dashboard', 'jetpack' ); ?></a> | |
| 365 | - <?php | |
| 366 | - if ( current_user_can( 'jetpack_manage_modules' ) ) { | |
| 367 | - ?> | |
| 368 | - <a href="<?php echo esc_url( $jetpack_admin_url . '#/settings' ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a> | |
| 369 | - <?php | |
| 370 | - } | |
| 371 | - ?> | |
| 364 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack-settings#/settings' ) ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a> | |
| 372 | 365 | </span> |
| 373 | 366 | <?php } ?> |
| 374 | 367 | </div> |
| 375 | 368 | <?php endif; ?> |
| 376 | 369 | </div> |
| 377 | - </div> | |
| 370 | + </header> | |
| 378 | 371 | <div class="wrap"><div id="jp-admin-notices" aria-live="polite"></div></div> |
| 379 | 372 | <!-- START OF CALLBACK --> |
| 380 | 373 | <?php |
| 381 | 374 | ob_start(); |
| @@ -410,41 +403,17 @@ | ||
| 410 | 403 | <?php esc_html_e( 'Jetpack Logo', 'jetpack' ); ?> |
| 411 | 404 | </desc> |
| 412 | 405 | <path fill="#000" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"></path> |
| 413 | 406 | </svg> |
| 414 | - <span class="jp-footer__module-name"> | |
| 415 | - <a href="<?php echo esc_url( Redirect::get_url( 'jetpack' ) ); ?>" target="_blank" rel="noopener noreferrer" aria-label="Jetpack 12.2-a.0"> | |
| 416 | - <?php esc_html_e( 'Jetpack', 'jetpack' ); ?> | |
| 417 | - </a> | |
| 418 | - </span> | |
| 407 | + <span class="jp-footer__module-name"><?php esc_html_e( 'Jetpack', 'jetpack' ); ?></span> | |
| 419 | 408 | </div> |
| 409 | + <?php if ( ! ( new Host() )->is_wpcom_platform() && $my_jetpack_available ) : ?> | |
| 410 | + <?php $products_section = Footer_Links::get_my_jetpack_products_section(); ?> | |
| 420 | 411 | <div class="jp-footer__menu"> |
| 421 | - <a href="<?php echo esc_url( $jetpack_about_url ); ?>" title="<?php esc_attr__( 'About Jetpack', 'jetpack' ); ?>" class="jp-footer__menu-item"> | |
| 422 | - <?php echo esc_html__( 'About', 'jetpack' ); ?> | |
| 423 | - </a> | |
| 424 | - <a href="<?php echo esc_url( $jetpack_privacy_url ); ?>" rel="noopener noreferrer" title="<?php esc_html_e( "Automattic's Privacy Policy", 'jetpack' ); ?>" class="jp-footer__menu-item <?php echo ! $connectable ? 'is-external' : ''; ?> ?>" target="<?php echo ! $connectable ? '_blank' : '_self'; ?>"> | |
| 425 | - <?php echo esc_html_x( 'Privacy', 'Navigation item', 'jetpack' ); ?> | |
| 426 | - <?php echo ! $connectable ? $external_link_icon : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> | |
| 427 | - </a> | |
| 428 | - <a href="<?php echo esc_url( Redirect::get_url( 'wpcom-tos' ) ); ?>" target="_blank" rel="noopener noreferrer" title="<?php esc_html__( 'WordPress.com Terms of Service', 'jetpack' ); ?>" class="jp-footer__menu-item is-external"> | |
| 429 | - <?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?> | |
| 430 | - <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> | |
| 431 | - </a> | |
| 432 | - <a href="<?php echo esc_url( Redirect::get_url( 'jetpack' ) ); ?>" target="_blank" rel="noopener noreferrer" aria-label="Jetpack 12.2-a.0" class="jp-footer__menu-item is-external"> | |
| 433 | - Version <?php echo esc_html( JETPACK__VERSION ); ?> | |
| 434 | - <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> | |
| 435 | - </a> | |
| 436 | - <?php if ( is_multisite() && current_user_can( 'jetpack_network_sites_page' ) ) { ?> | |
| 437 | - <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack' ) ); ?>" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Network Sites', 'Navigation item', 'jetpack' ); ?></a> | |
| 438 | - <?php } ?> | |
| 439 | - <?php if ( is_multisite() && current_user_can( 'jetpack_network_settings_page' ) ) { ?> | |
| 440 | - <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack-settings' ) ); ?>" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Network Settings', 'Navigation item', 'jetpack' ); ?></a> | |
| 441 | - <?php } ?> | |
| 442 | - <?php if ( current_user_can( 'manage_options' ) ) { ?> | |
| 443 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack_modules' ) ); ?>" title="<?php esc_html_e( 'Access the full list of Jetpack modules available on your site.', 'jetpack' ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Modules', 'Navigation item', 'jetpack' ); ?></a> | |
| 444 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack-debugger' ) ); ?>" title="<?php esc_html_e( "Test your site's compatibility with Jetpack.", 'jetpack' ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Debug', 'Navigation item', 'jetpack' ); ?></a> | |
| 445 | - <?php } ?> | |
| 412 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=my-jetpack#/' . $products_section['slug'] ) ); ?>" class="jp-footer__menu-item"><?php echo esc_html( $products_section['label'] ); ?></a> | |
| 413 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=my-jetpack#/help' ) ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Help', 'Navigation item', 'jetpack' ); ?></a> | |
| 446 | 414 | </div> |
| 415 | + <?php endif; ?> | |
| 447 | 416 | <a class="jp-footer__a8c-logo" href="<?php echo esc_url( $jetpack_about_url ); ?>" aria-label="<?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?>"> |
| 448 | 417 | <svg role="img" x="0" y="0" viewBox="0 0 935 38.2" enable-background="new 0 0 935 38.2" aria-labelledby="jp-automattic-byline-logo-title" height="7" class="jp-automattic-byline-logo"> |
| 449 | 418 | <desc id="jp-automattic-byline-logo-title"> |
| 450 | 419 | <?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?> |
| @@ -455,6 +424,35 @@ | ||
| 455 | 424 | </div> |
| 456 | 425 | </div> |
| 457 | 426 | </div> |
| 458 | 427 | <?php |
| 428 | + } | |
| 429 | + | |
| 430 | + /** | |
| 431 | + * Should we block the page rendering because the site is in IDC? | |
| 432 | + * | |
| 433 | + * @return bool | |
| 434 | + */ | |
| 435 | + protected function block_page_rendering_for_idc() { | |
| 436 | + return Jetpack::is_connection_ready() && Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' ); | |
| 437 | + } | |
| 438 | + | |
| 439 | + /** | |
| 440 | + * Set a page title for both the module list page and the debugger page. | |
| 441 | + * We set these here because we do not register a page title when we register them, | |
| 442 | + * so they do not appear in the admin navigation. | |
| 443 | + * | |
| 444 | + * @since 15.4 | |
| 445 | + * | |
| 446 | + * @param WP_Screen $screen The screen object. | |
| 447 | + * | |
| 448 | + * @return void | |
| 449 | + */ | |
| 450 | + public static function override_page_title( WP_Screen $screen ) { | |
| 451 | + global $title; | |
| 452 | + if ( 'admin_page_jetpack_modules' === $screen->id ) { | |
| 453 | + $title = __( 'Jetpack Settings', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page. | |
| 454 | + } elseif ( 'admin_page_jetpack-debugger' === $screen->id ) { | |
| 455 | + $title = __( 'Debugging Center', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page. | |
| 456 | + } | |
| 459 | 457 | } |
| 460 | 458 | } |