PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
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 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | _inc/lib/admin-pages/class.jetpack-admin-page.php +77 -93 13.3.316.3-a.1 View file →
@@ -8,19 +8,21 @@
8 8 use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
9 9 use Automattic\Jetpack\Identity_Crisis;
10 10 use Automattic\Jetpack\Redirect;
11 11 use Automattic\Jetpack\Status;
12 +use Automattic\Jetpack\Status\Host;
12 13
13 14 /**
14 15 * Shared logic between Jetpack admin pages.
15 16 */
16 17 abstract class Jetpack_Admin_Page {
18 +
17 19 /**
18 - * Jetpack Object.
20 + * Determines whether or not to hide if not active.
19 21 *
20 - * @var Jetpack
22 + * @var bool
21 23 */
22 - public $jetpack;
24 + protected $dont_show_if_not_active;
23 25
24 26 /**
25 27 * Add page specific actions given the page hook.
26 28 *
@@ -45,18 +47,8 @@
45 47 */
46 48 abstract public function page_render();
47 49
48 50 /**
49 - * Should we block the page rendering because the site is in IDC?
50 - * Beware that the property is set early on, and might not always reflect the actual value.
51 - *
52 - * @var bool
53 - *
54 - * @deprecated 13.2 Use `$this->block_page_rendering_for_idc()` instead.
55 - */
56 - public static $block_page_rendering_for_idc;
57 -
58 - /**
59 51 * Function called after admin_styles to load any additional needed styles.
60 52 *
61 53 * @since 4.3.0
62 54 */
@@ -62,28 +54,8 @@
62 54 */
63 55 public function additional_styles() {}
64 56
65 57 /**
66 - * The constructor.
67 - */
68 - public function __construct() {
69 - add_action( 'jetpack_loaded', array( $this, 'on_jetpack_loaded' ) );
70 - }
71 -
72 - /**
73 - * Runs on Jetpack being ready to load its packages.
74 - *
75 - * @param Jetpack $jetpack object.
76 - */
77 - public function on_jetpack_loaded( $jetpack ) {
78 - $this->jetpack = $jetpack;
79 -
80 - self::$block_page_rendering_for_idc = (
81 - Jetpack::is_connection_ready() && Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' )
82 - );
83 - }
84 -
85 - /**
86 58 * Add common page actions and attach page-specific actions.
87 59 */
88 60 public function add_actions() {
89 61 $is_offline_mode = ( new Status() )->is_offline_mode();
@@ -106,9 +78,8 @@
106 78 // Initialize menu item for the page in the admin.
107 79 $hook = $this->get_page_hook();
108 80
109 81 // Attach hooks common to all Jetpack admin pages based on the created hook.
110 - add_action( "load-$hook", array( $this, 'admin_help' ) );
111 82 add_action( "load-$hook", array( $this, 'admin_page_load' ) );
112 83 add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) );
113 84 add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) );
114 85 add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) );
@@ -117,8 +88,11 @@
117 88 add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) );
118 89
119 90 // Attach page specific actions in addition to the above.
120 91 $this->add_page_actions( $hook );
92 +
93 + // Override the page title for the module list page and the debugger page.
94 + add_action( 'current_screen', array( __CLASS__, 'override_page_title' ) );
121 95 }
122 96
123 97 /**
124 98 * Render the page with a common top and bottom part, and page specific content.
@@ -123,8 +97,11 @@
123 97 /**
124 98 * Render the page with a common top and bottom part, and page specific content.
125 99 */
126 100 public function render() {
101 + /** This action is documented in class.jetpack.php */
102 + do_action( 'jetpack_initialize_tracking' );
103 +
127 104 // We're in an IDC: we need a decision made before we show the UI again.
128 105 if ( $this->block_page_rendering_for_idc() ) {
129 106 return;
130 107 }
@@ -138,9 +115,10 @@
138 115 $args = array();
139 116
140 117 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
141 118 if ( isset( $_GET['page'] ) && 'jetpack_modules' === $_GET['page'] ) {
142 - $args['is-wide'] = true;
119 + $args['is-wide'] = true;
120 + $args['show-nav'] = false;
143 121 }
144 122
145 123 self::wrap_ui( array( $this, 'page_render' ), $args );
146 124 }
@@ -145,21 +123,12 @@
145 123 self::wrap_ui( array( $this, 'page_render' ), $args );
146 124 }
147 125
148 126 /**
149 - * Load Help tab.
150 - *
151 - * @todo This may no longer be used.
152 - */
153 - public function admin_help() {
154 - $this->jetpack->admin_help();
155 - }
156 -
157 - /**
158 127 * Call the existing admin page events.
159 128 */
160 129 public function admin_page_load() {
161 - $this->jetpack->admin_page_load();
130 + Jetpack::init()->admin_page_load();
162 131 }
163 132
164 133 /**
165 134 * Add page specific scripts and jetpack stats for all menu pages.
@@ -165,9 +134,9 @@
165 134 * Add page specific scripts and jetpack stats for all menu pages.
166 135 */
167 136 public function admin_scripts() {
168 137 $this->page_admin_scripts(); // Delegate to inheriting class.
169 - add_action( 'admin_footer', array( $this->jetpack, 'do_stats' ) );
138 + add_action( 'admin_footer', array( Jetpack::init(), 'do_stats' ) );
170 139 }
171 140
172 141 /**
173 142 * Enqueue the Jetpack admin stylesheet.
@@ -174,9 +143,9 @@
174 143 */
175 144 public function admin_styles() {
176 145 $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
177 146
178 - wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons' ), JETPACK__VERSION . '-20121016' );
147 + wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons', 'jetpack-connection' ), JETPACK__VERSION . '-20121016' );
179 148 wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' );
180 149 wp_style_add_data( 'jetpack-admin', 'suffix', $min );
181 150 }
182 151
@@ -268,12 +237,12 @@
268 237
269 238 /**
270 239 * Build header, content, and footer for admin page.
271 240 *
272 - * @param string $callback Callback to produce the content of the page. The callback is responsible for any needed escaping.
273 - * @param array $args Options for the wrapping. Also passed to the `jetpack_admin_pages_wrap_ui_after_callback` action.
274 - * - is-wide: (bool) Set the "is-wide" class on the wrapper div, which increases the max width. Default false.
275 - * - show-nav: (bool) Whether to show the navigation bar at the top of the page. Default true.
241 + * @param callable $callback Callback to produce the content of the page. The callback is responsible for any needed escaping.
242 + * @param array $args Options for the wrapping. Also passed to the `jetpack_admin_pages_wrap_ui_after_callback` action.
243 + * - is-wide: (bool) Set the "is-wide" class on the wrapper div, which increases the max width. Default false.
244 + * - show-nav: (bool) Whether to show the navigation bar at the top of the page. Default true.
276 245 */
277 246 public static function wrap_ui( $callback, $args = array() ) {
278 247 $defaults = array(
279 248 'is-wide' => false,
@@ -290,14 +259,8 @@
290 259 $jetpack_about_url = ! $connectable
291 260 ? admin_url( 'admin.php?page=jetpack_about' )
292 261 : Redirect::get_url( 'jetpack' );
293 262
294 - $jetpack_privacy_url = ! $connectable
295 - ? $jetpack_admin_url . '#/privacy'
296 - : Redirect::get_url( 'a8c-privacy' );
297 -
298 - $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>';
299 -
300 263 ?>
301 264 <div id="jp-plugin-container" class="
302 265 <?php
303 266 if ( $args['is-wide'] ) {
@@ -304,17 +267,43 @@
304 267 echo 'is-wide'; }
305 268 ?>
306 269 ">
307 270
308 - <div class="jp-masthead jp-masthead-middle">
271 + <header class="jp-masthead">
309 272 <div class="jp-masthead__inside-container">
310 - <div class="jp-masthead__logo-container">
311 - <a class="jp-masthead__logo-link" href="<?php echo esc_url( $jetpack_admin_url ); ?>">
312 - <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>
273 + <div class="jp-masthead__title-container">
274 + <a class="jp-masthead__logo-link" href="<?php echo esc_url( admin_url( 'admin.php?page=my-jetpack#/overview' ) ); ?>">
275 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" height="20" aria-label="<?php esc_attr_e( 'Jetpack logo', 'jetpack' ); ?>"><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></svg>
313 276 </a>
277 + <h2 class="jp-masthead__title">
278 + <?php
279 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic only.
280 + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
281 + $is_offline_mode = ( new Status() )->is_offline_mode();
282 + $current_label = '';
283 + if ( 'jetpack_modules' === $page ) {
284 + $current_label = __( 'Modules', 'jetpack' );
285 + } elseif ( 'jetpack_about' === $page ) {
286 + $current_label = __( 'About', 'jetpack' );
287 + } elseif ( 'jetpack-debugger' === $page ) {
288 + $current_label = __( 'Debug', 'jetpack' );
289 + }
290 + ?>
291 + <?php if ( $current_label ) : ?>
292 + <a class="jp-masthead__title-link" href="<?php echo esc_url( admin_url( 'admin.php?page=my-jetpack#/overview' ) ); ?>">Jetpack</a><?php // "Jetpack" is a product name, do not translate. ?>
293 + <span class="jp-masthead__title-separator" aria-hidden="true">/</span>
294 + <?php if ( $is_offline_mode ) : ?>
295 + <span class="jp-masthead__title-offline"><?php esc_html_e( 'Offline Mode', 'jetpack' ); ?></span>
296 + <span class="jp-masthead__title-separator" aria-hidden="true">/</span>
297 + <?php endif; ?>
298 + <span class="jp-masthead__title-current"><?php echo esc_html( $current_label ); ?></span>
299 + <?php else : ?>
300 + Jetpack<?php // "Jetpack" is a product name, do not translate. ?>
301 + <?php endif; ?>
302 + </h2>
314 303 </div>
315 304 <?php
316 - if ( $args['show-nav'] ) :
305 + if ( $args['show-nav'] && ! ( new Host() )->is_wpcom_platform() ) :
317 306 ?>
318 307 <div class="jp-masthead__nav">
319 308 <?php
320 309 if ( is_network_admin() ) {
@@ -350,9 +339,9 @@
350 339 <?php } ?>
351 340 </div>
352 341 <?php endif; ?>
353 342 </div>
354 - </div>
343 + </header>
355 344 <div class="wrap"><div id="jp-admin-notices" aria-live="polite"></div></div>
356 345 <!-- START OF CALLBACK -->
357 346 <?php
358 347 ob_start();
@@ -387,41 +376,16 @@
387 376 <?php esc_html_e( 'Jetpack Logo', 'jetpack' ); ?>
388 377 </desc>
389 378 <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>
390 379 </svg>
391 - <span class="jp-footer__module-name">
392 - <a href="<?php echo esc_url( Redirect::get_url( 'jetpack' ) ); ?>" target="_blank" rel="noopener noreferrer" aria-label="Jetpack 12.2-a.0">
393 - <?php esc_html_e( 'Jetpack', 'jetpack' ); ?>
394 - </a>
395 - </span>
380 + <span class="jp-footer__module-name"><?php esc_html_e( 'Jetpack', 'jetpack' ); ?></span>
396 381 </div>
382 + <?php if ( ! ( new Host() )->is_wpcom_platform() ) : ?>
397 383 <div class="jp-footer__menu">
398 - <a href="<?php echo esc_url( $jetpack_about_url ); ?>" title="<?php esc_attr__( 'About Jetpack', 'jetpack' ); ?>" class="jp-footer__menu-item">
399 - <?php echo esc_html__( 'About', 'jetpack' ); ?>
400 - </a>
401 - <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'; ?>">
402 - <?php echo esc_html_x( 'Privacy', 'Navigation item', 'jetpack' ); ?>
403 - <?php echo ! $connectable ? $external_link_icon : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
404 - </a>
405 - <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">
406 - <?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?>
407 - <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
408 - </a>
409 - <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">
410 - Version <?php echo esc_html( JETPACK__VERSION ); ?>
411 - <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
412 - </a>
413 - <?php if ( is_multisite() && current_user_can( 'jetpack_network_sites_page' ) ) { ?>
414 - <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>
415 - <?php } ?>
416 - <?php if ( is_multisite() && current_user_can( 'jetpack_network_settings_page' ) ) { ?>
417 - <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>
418 - <?php } ?>
419 - <?php if ( current_user_can( 'manage_options' ) ) { ?>
420 - <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>
421 - <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>
422 - <?php } ?>
384 + <a href="<?php echo esc_url( admin_url( 'admin.php?page=my-jetpack#/products' ) ); ?>" class="jp-footer__menu-item"><?php echo esc_html_x( 'Products', 'Navigation item', 'jetpack' ); ?></a>
385 + <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>
423 386 </div>
387 + <?php endif; ?>
424 388 <a class="jp-footer__a8c-logo" href="<?php echo esc_url( $jetpack_about_url ); ?>" aria-label="<?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?>">
425 389 <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">
426 390 <desc id="jp-automattic-byline-logo-title">
427 391 <?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?>
@@ -441,6 +405,26 @@
441 405 * @return bool
442 406 */
443 407 protected function block_page_rendering_for_idc() {
444 408 return Jetpack::is_connection_ready() && Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' );
409 + }
410 +
411 + /**
412 + * Set a page title for both the module list page and the debugger page.
413 + * We set these here because we do not register a page title when we register them,
414 + * so they do not appear in the admin navigation.
415 + *
416 + * @since 15.4
417 + *
418 + * @param WP_Screen $screen The screen object.
419 + *
420 + * @return void
421 + */
422 + public static function override_page_title( WP_Screen $screen ) {
423 + global $title;
424 + if ( 'admin_page_jetpack_modules' === $screen->id ) {
425 + $title = __( 'Jetpack Settings', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page.
426 + } elseif ( 'admin_page_jetpack-debugger' === $screen->id ) {
427 + $title = __( 'Debugging Center', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page.
428 + }
445 429 }
446 430 }