← All changes
|
_inc/lib/admin-pages/class.jetpack-admin-page.php
+458
-0
16.2-beta
→
16.3
View file →
| @@ -1,0 +1,458 @@ | ||
| 1 | +<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName | |
| 2 | +/** | |
| 3 | + * Main class file for Jetpack Admin pages. | |
| 4 | + * | |
| 5 | + * @package automattic/jetpack | |
| 6 | + */ | |
| 7 | + | |
| 8 | +use Automattic\Jetpack\Current_Plan as Jetpack_Plan; | |
| 9 | +use Automattic\Jetpack\Identity_Crisis; | |
| 10 | +use Automattic\Jetpack\Plugin\Admin_Chrome_Logo; | |
| 11 | +use Automattic\Jetpack\Plugin\Footer_Links; | |
| 12 | +use Automattic\Jetpack\Redirect; | |
| 13 | +use Automattic\Jetpack\Status; | |
| 14 | +use Automattic\Jetpack\Status\Host; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Shared logic between Jetpack admin pages. | |
| 18 | + */ | |
| 19 | +abstract class Jetpack_Admin_Page { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Determines whether or not to hide if not active. | |
| 23 | + * | |
| 24 | + * @var bool | |
| 25 | + */ | |
| 26 | + protected $dont_show_if_not_active; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * Add page specific actions given the page hook. | |
| 30 | + * | |
| 31 | + * @param string $hook Hook of current page. | |
| 32 | + */ | |
| 33 | + abstract public function add_page_actions( $hook ); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * Create a menu item for the page and returns the hook. | |
| 37 | + * | |
| 38 | + * @return string|false Return value from WordPress's `add_menu_page()` or `add_submenu_page()`. | |
| 39 | + */ | |
| 40 | + abstract public function get_page_hook(); | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * Enqueue and localize page specific scripts. | |
| 44 | + */ | |
| 45 | + abstract public function page_admin_scripts(); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Render page specific HTML | |
| 49 | + */ | |
| 50 | + abstract public function page_render(); | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Function called after admin_styles to load any additional needed styles. | |
| 54 | + * | |
| 55 | + * @since 4.3.0 | |
| 56 | + */ | |
| 57 | + public function additional_styles() {} | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Add common page actions and attach page-specific actions. | |
| 61 | + */ | |
| 62 | + public function add_actions() { | |
| 63 | + $is_offline_mode = ( new Status() )->is_offline_mode(); | |
| 64 | + | |
| 65 | + // If user is not an admin and site is in Offline Mode or not connected yet then don't do anything. | |
| 66 | + if ( ! current_user_can( 'manage_options' ) && ( $is_offline_mode || ! Jetpack::is_connection_ready() ) ) { | |
| 67 | + return; | |
| 68 | + } | |
| 69 | + | |
| 70 | + // Is Jetpack not connected and not offline? | |
| 71 | + // True means that Jetpack is NOT connected and NOT in offline mode. | |
| 72 | + // If Jetpack is connected OR in offline mode, this will be false. | |
| 73 | + $connectable = ! Jetpack::is_connection_ready() && ! $is_offline_mode; | |
| 74 | + | |
| 75 | + // Don't add in the modules page unless modules are available! | |
| 76 | + if ( $this->dont_show_if_not_active && $connectable ) { | |
| 77 | + return; | |
| 78 | + } | |
| 79 | + | |
| 80 | + // Initialize menu item for the page in the admin. | |
| 81 | + $hook = $this->get_page_hook(); | |
| 82 | + | |
| 83 | + // Attach hooks common to all Jetpack admin pages based on the created hook. | |
| 84 | + add_action( "load-$hook", array( $this, 'admin_page_load' ) ); | |
| 85 | + add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) ); | |
| 86 | + add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) ); | |
| 87 | + add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) ); | |
| 88 | + | |
| 89 | + // Check if the site plan changed and deactivate modules accordingly. | |
| 90 | + add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) ); | |
| 91 | + | |
| 92 | + // Attach page specific actions in addition to the above. | |
| 93 | + $this->add_page_actions( $hook ); | |
| 94 | + | |
| 95 | + // Override the page title for the module list page and the debugger page. | |
| 96 | + add_action( 'current_screen', array( __CLASS__, 'override_page_title' ) ); | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * Render the page with a common top and bottom part, and page specific content. | |
| 101 | + */ | |
| 102 | + public function render() { | |
| 103 | + /** This action is documented in class.jetpack.php */ | |
| 104 | + do_action( 'jetpack_initialize_tracking' ); | |
| 105 | + | |
| 106 | + // We're in an IDC: we need a decision made before we show the UI again. | |
| 107 | + if ( $this->block_page_rendering_for_idc() ) { | |
| 108 | + return; | |
| 109 | + } | |
| 110 | + | |
| 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. | |
| 113 | + $this->page_render(); | |
| 114 | + return; | |
| 115 | + } | |
| 116 | + | |
| 117 | + $args = array(); | |
| 118 | + | |
| 119 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 120 | + if ( isset( $_GET['page'] ) && 'jetpack_modules' === $_GET['page'] ) { | |
| 121 | + $args['is-wide'] = true; | |
| 122 | + $args['show-nav'] = false; | |
| 123 | + } | |
| 124 | + | |
| 125 | + self::wrap_ui( array( $this, 'page_render' ), $args ); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Call the existing admin page events. | |
| 130 | + */ | |
| 131 | + public function admin_page_load() { | |
| 132 | + Jetpack::init()->admin_page_load(); | |
| 133 | + } | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * Add page specific scripts and jetpack stats for all menu pages. | |
| 137 | + */ | |
| 138 | + public function admin_scripts() { | |
| 139 | + $this->page_admin_scripts(); // Delegate to inheriting class. | |
| 140 | + add_action( 'admin_footer', array( Jetpack::init(), 'do_stats' ) ); | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Enqueue the Jetpack admin stylesheet. | |
| 145 | + */ | |
| 146 | + public function admin_styles() { | |
| 147 | + $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; | |
| 148 | + | |
| 149 | + wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons', 'jetpack-connection' ), JETPACK__VERSION . '-20121016' ); | |
| 150 | + wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' ); | |
| 151 | + wp_style_add_data( 'jetpack-admin', 'suffix', $min ); | |
| 152 | + } | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * Checks if REST API is enabled. | |
| 156 | + * | |
| 157 | + * @since 4.4.2 | |
| 158 | + * | |
| 159 | + * @return bool | |
| 160 | + */ | |
| 161 | + public function is_rest_api_enabled() { | |
| 162 | + return /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ | |
| 163 | + apply_filters( 'rest_enabled', true ) && | |
| 164 | + /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */ | |
| 165 | + apply_filters( 'rest_authentication_errors', true ); | |
| 166 | + } | |
| 167 | + | |
| 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 | + /** | |
| 189 | + * Checks the site plan and deactivates modules that were active but are no longer included in the plan. | |
| 190 | + * | |
| 191 | + * @since 4.4.0 | |
| 192 | + * | |
| 193 | + * @param WP_Screen $page Current WP_Screen object. | |
| 194 | + * | |
| 195 | + * @return array | |
| 196 | + */ | |
| 197 | + public function check_plan_deactivate_modules( $page ) { | |
| 198 | + if ( | |
| 199 | + ( new Status() )->is_offline_mode() | |
| 200 | + || ! in_array( | |
| 201 | + $page->base, | |
| 202 | + array( | |
| 203 | + 'toplevel_page_jetpack', | |
| 204 | + 'jetpack_page_jetpack-settings', | |
| 205 | + 'admin_page_jetpack_modules', | |
| 206 | + 'jetpack_page_vaultpress', | |
| 207 | + 'jetpack_page_stats', | |
| 208 | + 'jetpack_page_akismet-key-config', | |
| 209 | + ), | |
| 210 | + true | |
| 211 | + ) | |
| 212 | + ) { | |
| 213 | + return false; | |
| 214 | + } | |
| 215 | + | |
| 216 | + $current = Jetpack_Plan::get(); | |
| 217 | + | |
| 218 | + $to_deactivate = array(); | |
| 219 | + if ( isset( $current['product_slug'] ) ) { | |
| 220 | + $active = Jetpack::get_active_modules(); | |
| 221 | + switch ( $current['product_slug'] ) { | |
| 222 | + case 'jetpack_free': | |
| 223 | + case 'jetpack_personal': | |
| 224 | + case 'jetpack_personal_monthly': | |
| 225 | + $to_deactivate = array( 'google-analytics', 'wordads', 'search' ); | |
| 226 | + break; | |
| 227 | + case 'jetpack_premium': | |
| 228 | + case 'jetpack_premium_monthly': | |
| 229 | + $to_deactivate = array( 'google-analytics', 'search' ); | |
| 230 | + break; | |
| 231 | + } | |
| 232 | + $to_deactivate = array_intersect( $active, $to_deactivate ); | |
| 233 | + | |
| 234 | + $to_leave_enabled = array(); | |
| 235 | + foreach ( $to_deactivate as $feature ) { | |
| 236 | + if ( Jetpack_Plan::supports( $feature ) ) { | |
| 237 | + $to_leave_enabled [] = $feature; | |
| 238 | + } | |
| 239 | + } | |
| 240 | + $to_deactivate = array_diff( $to_deactivate, $to_leave_enabled ); | |
| 241 | + | |
| 242 | + if ( ! empty( $to_deactivate ) ) { | |
| 243 | + Jetpack::update_active_modules( array_filter( array_diff( $active, $to_deactivate ) ) ); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + return array( | |
| 247 | + 'current' => $current, | |
| 248 | + 'deactivate' => $to_deactivate, | |
| 249 | + ); | |
| 250 | + } | |
| 251 | + | |
| 252 | + /** | |
| 253 | + * Enqueue inline wrapper styles for the main container. | |
| 254 | + */ | |
| 255 | + public static function load_wrapper_styles() { | |
| 256 | + $rtl = is_rtl() ? '.rtl' : ''; | |
| 257 | + wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/admin{$rtl}.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION ); | |
| 258 | + wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min{$rtl}.css", JETPACK__PLUGIN_FILE ), array( 'wp-components' ), JETPACK__VERSION ); | |
| 259 | + } | |
| 260 | + | |
| 261 | + /** | |
| 262 | + * Build header, content, and footer for admin page. | |
| 263 | + * | |
| 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. | |
| 268 | + */ | |
| 269 | + public static function wrap_ui( $callback, $args = array() ) { | |
| 270 | + $defaults = array( | |
| 271 | + 'is-wide' => false, | |
| 272 | + 'show-nav' => true, | |
| 273 | + ); | |
| 274 | + $args = wp_parse_args( $args, $defaults ); | |
| 275 | + | |
| 276 | + // Is Jetpack not connected and not offline? | |
| 277 | + // True means that Jetpack is NOT connected and NOT in offline mode. | |
| 278 | + // If Jetpack is connected OR in offline mode, this will be false. | |
| 279 | + $connectable = ! Jetpack::is_connection_ready() && ! ( new Status() )->is_offline_mode(); | |
| 280 | + | |
| 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 | + | |
| 285 | + $jetpack_about_url = ! $connectable | |
| 286 | + ? admin_url( 'admin.php?page=jetpack_about' ) | |
| 287 | + : Redirect::get_url( 'jetpack' ); | |
| 288 | + | |
| 289 | + ?> | |
| 290 | + <div id="jp-plugin-container" class=" | |
| 291 | + <?php | |
| 292 | + if ( $args['is-wide'] ) { | |
| 293 | + echo 'is-wide'; } | |
| 294 | + ?> | |
| 295 | + "> | |
| 296 | + | |
| 297 | + <header class="jp-masthead"> | |
| 298 | + <div class="jp-masthead__inside-container"> | |
| 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 | + </div> | |
| 338 | + <?php | |
| 339 | + if ( $args['show-nav'] && ! ( new Host() )->is_wpcom_platform() ) : | |
| 340 | + ?> | |
| 341 | + <div class="jp-masthead__nav"> | |
| 342 | + <?php | |
| 343 | + if ( is_network_admin() ) { | |
| 344 | + $current_screen = get_current_screen(); | |
| 345 | + | |
| 346 | + $highlight_current_sites = ( 'toplevel_page_jetpack-network' === $current_screen->id ? 'is-primary' : '' ); | |
| 347 | + $highlight_current_settings = ( 'jetpack_page_jetpack-settings-network' === $current_screen->id ? 'is-primary' : '' ); | |
| 348 | + ?> | |
| 349 | + <span class="dops-button-group"> | |
| 350 | + <?php | |
| 351 | + if ( current_user_can( 'jetpack_network_sites_page' ) ) { | |
| 352 | + ?> | |
| 353 | + <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack' ) ); ?>" type="button" class="<?php echo esc_attr( $highlight_current_sites ); ?> dops-button is-compact" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>"><?php echo esc_html_x( 'Sites', 'Navigation item', 'jetpack' ); ?></a> | |
| 354 | + <?php | |
| 355 | + } if ( current_user_can( 'jetpack_network_settings_page' ) ) { | |
| 356 | + ?> | |
| 357 | + <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack-settings' ) ); ?>" type="button" class="<?php echo esc_attr( $highlight_current_settings ); ?> dops-button is-compact" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>"><?php echo esc_html_x( 'Network Settings', 'Navigation item', 'jetpack' ); ?></a> | |
| 358 | + <?php | |
| 359 | + } | |
| 360 | + ?> | |
| 361 | + </span> | |
| 362 | + <?php } elseif ( current_user_can( 'jetpack_manage_modules' ) ) { ?> | |
| 363 | + <span class="dops-button-group"> | |
| 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> | |
| 365 | + </span> | |
| 366 | + <?php } ?> | |
| 367 | + </div> | |
| 368 | + <?php endif; ?> | |
| 369 | + </div> | |
| 370 | + </header> | |
| 371 | + <div class="wrap"><div id="jp-admin-notices" aria-live="polite"></div></div> | |
| 372 | + <!-- START OF CALLBACK --> | |
| 373 | + <?php | |
| 374 | + ob_start(); | |
| 375 | + call_user_func( $callback ); | |
| 376 | + $callback_ui = ob_get_contents(); | |
| 377 | + ob_end_clean(); | |
| 378 | + echo $callback_ui;// phpcs:ignore WordPress.Security.EscapeOutput -- Callback is responsible for any needed escaping. | |
| 379 | + ?> | |
| 380 | + <!-- END OF CALLBACK --> | |
| 381 | + | |
| 382 | + <div id="jp-stats-report-bottom"> | |
| 383 | + <div class="wrap"> | |
| 384 | + <?php | |
| 385 | + /** | |
| 386 | + * Fires at the bottom of the Jetpack admin page template, after the dynamic content section. | |
| 387 | + * | |
| 388 | + * @since 10.0.0 | |
| 389 | + * | |
| 390 | + * @param string $callback The callback sent to the Jetpack_Admin_Page::wrap_ui method. | |
| 391 | + * @param array $args The arguments sent to the Jetpack_Admin_Page::wrap_ui method. | |
| 392 | + */ | |
| 393 | + do_action( 'jetpack_admin_pages_wrap_ui_after_callback', $callback, $args ); | |
| 394 | + ?> | |
| 395 | + </div> | |
| 396 | + </div> | |
| 397 | + | |
| 398 | + <div class="jp-footer jp-footer--static"> | |
| 399 | + <div class="jp-footer__container"> | |
| 400 | + <div class="jp-footer__logo"> | |
| 401 | + <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 32 32" class="jetpack-logo jp-footer__jetpack-symbol" aria-labelledby="jetpack-logo-title" height="16" aria-label="<?php esc_html_e( 'Jetpack logo', 'jetpack' ); ?>"> | |
| 402 | + <desc id="jetpack-logo-title"> | |
| 403 | + <?php esc_html_e( 'Jetpack Logo', 'jetpack' ); ?> | |
| 404 | + </desc> | |
| 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> | |
| 406 | + </svg> | |
| 407 | + <span class="jp-footer__module-name"><?php esc_html_e( 'Jetpack', 'jetpack' ); ?></span> | |
| 408 | + </div> | |
| 409 | + <?php if ( ! ( new Host() )->is_wpcom_platform() && $my_jetpack_available ) : ?> | |
| 410 | + <?php $products_section = Footer_Links::get_my_jetpack_products_section(); ?> | |
| 411 | + <div class="jp-footer__menu"> | |
| 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> | |
| 414 | + </div> | |
| 415 | + <?php endif; ?> | |
| 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' ); ?>"> | |
| 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"> | |
| 418 | + <desc id="jp-automattic-byline-logo-title"> | |
| 419 | + <?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?> | |
| 420 | + </desc> | |
| 421 | + <path d="M317.1 38.2c-12.6 0-20.7-9.1-20.7-18.5v-1.2c0-9.6 8.2-18.5 20.7-18.5 12.6 0 20.8 8.9 20.8 18.5v1.2C337.9 29.1 329.7 38.2 317.1 38.2zM331.2 18.6c0-6.9-5-13-14.1-13s-14 6.1-14 13v0.9c0 6.9 5 13.1 14 13.1s14.1-6.2 14.1-13.1V18.6zM175 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7L157 1.3h5.5L182 36.8H175zM159.7 8.2L152 23.1h15.7L159.7 8.2zM212.4 38.2c-12.7 0-18.7-6.9-18.7-16.2V1.3h6.6v20.9c0 6.6 4.3 10.5 12.5 10.5 8.4 0 11.9-3.9 11.9-10.5V1.3h6.7V22C231.4 30.8 225.8 38.2 212.4 38.2zM268.6 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H268.6zM397.3 36.8V8.7l-1.8 3.1 -14.9 25h-3.3l-14.7-25 -1.8-3.1v28.1h-6.5V1.3h9.2l14 24.4 1.7 3 1.7-3 13.9-24.4h9.1v35.5H397.3zM454.4 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7l19.2-35.5h5.5l19.5 35.5H454.4zM439.1 8.2l-7.7 14.9h15.7L439.1 8.2zM488.4 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H488.4zM537.3 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H537.3zM569.3 36.8V4.6c2.7 0 3.7-1.4 3.7-3.4h2.8v35.5L569.3 36.8 569.3 36.8zM628 11.3c-3.2-2.9-7.9-5.7-14.2-5.7 -9.5 0-14.8 6.5-14.8 13.3v0.7c0 6.7 5.4 13 15.3 13 5.9 0 10.8-2.8 13.9-5.7l4 4.2c-3.9 3.8-10.5 7.1-18.3 7.1 -13.4 0-21.6-8.7-21.6-18.3v-1.2c0-9.6 8.9-18.7 21.9-18.7 7.5 0 14.3 3.1 18 7.1L628 11.3zM321.5 12.4c1.2 0.8 1.5 2.4 0.8 3.6l-6.1 9.4c-0.8 1.2-2.4 1.6-3.6 0.8l0 0c-1.2-0.8-1.5-2.4-0.8-3.6l6.1-9.4C318.7 11.9 320.3 11.6 321.5 12.4L321.5 12.4z"></path><path d="M37.5 36.7l-4.7-8.9H11.7l-4.6 8.9H0L19.4 0.8H25l19.7 35.9H37.5zM22 7.8l-7.8 15.1h15.9L22 7.8zM82.8 36.7l-23.3-24 -2.3-2.5v26.6h-6.7v-36H57l22.6 24 2.3 2.6V0.8h6.7v35.9H82.8z"></path><path d="M719.9 37l-4.8-8.9H694l-4.6 8.9h-7.1l19.5-36h5.6l19.8 36H719.9zM704.4 8l-7.8 15.1h15.9L704.4 8zM733 37V1h6.8v36H733zM781 37c-1.8 0-2.6-2.5-2.9-5.8l-0.2-3.7c-0.2-3.6-1.7-5.1-8.4-5.1h-12.8V37H750V1h19.6c10.8 0 15.7 4.3 15.7 9.9 0 3.9-2 7.7-9 9 7 0.5 8.5 3.7 8.6 7.9l0.1 3c0.1 2.5 0.5 4.3 2.2 6.1V37H781zM778.5 11.8c0-2.6-2.1-5.1-7.9-5.1h-13.8v10.8h14.4c5 0 7.3-2.4 7.3-5.2V11.8zM794.8 37V1h6.8v30.4h28.2V37H794.8zM836.7 37V1h6.8v36H836.7zM886.2 37l-23.4-24.1 -2.3-2.5V37h-6.8V1h6.5l22.7 24.1 2.3 2.6V1h6.8v36H886.2zM902.3 37V1H935v5.6h-26v9.2h20v5.5h-20v10.1h26V37H902.3z"></path> | |
| 422 | + </svg> | |
| 423 | + </a> | |
| 424 | + </div> | |
| 425 | + </div> | |
| 426 | + </div> | |
| 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 | + } | |
| 457 | + } | |
| 458 | +} | |