Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 203
0.00% covered (danger)
0.00%
0 / 12
CRAP
0.00% covered (danger)
0.00%
0 / 1
Jetpack_Admin_Page
0.00% covered (danger)
0.00%
0 / 203
0.00% covered (danger)
0.00%
0 / 12
4290
0.00% covered (danger)
0.00%
0 / 1
 add_page_actions
n/a
0 / 0
n/a
0 / 0
0
 get_page_hook
n/a
0 / 0
n/a
0 / 0
0
 page_admin_scripts
n/a
0 / 0
n/a
0 / 0
0
 page_render
n/a
0 / 0
n/a
0 / 0
0
 additional_styles
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 add_actions
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
56
 render
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
42
 admin_page_load
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 admin_scripts
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 admin_styles
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 is_rest_api_enabled
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 check_plan_deactivate_modules
0.00% covered (danger)
0.00%
0 / 39
0.00% covered (danger)
0.00%
0 / 1
156
 load_wrapper_styles
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 wrap_ui
0.00% covered (danger)
0.00%
0 / 121
0.00% covered (danger)
0.00%
0 / 1
600
 block_page_rendering_for_idc
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
12
 override_page_title
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
1<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2/**
3 * Main class file for Jetpack Admin pages.
4 *
5 * @package automattic/jetpack
6 */
7
8use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
9use Automattic\Jetpack\Identity_Crisis;
10use Automattic\Jetpack\Redirect;
11use Automattic\Jetpack\Status;
12use Automattic\Jetpack\Status\Host;
13
14/**
15 * Shared logic between Jetpack admin pages.
16 */
17abstract class Jetpack_Admin_Page {
18
19    /**
20     * Determines whether or not to hide if not active.
21     *
22     * @var bool
23     */
24    protected $dont_show_if_not_active;
25
26    /**
27     * Add page specific actions given the page hook.
28     *
29     * @param string $hook Hook of current page.
30     */
31    abstract public function add_page_actions( $hook );
32
33    /**
34     * Create a menu item for the page and returns the hook.
35     *
36     * @return string|false Return value from WordPress's `add_menu_page()` or `add_submenu_page()`.
37     */
38    abstract public function get_page_hook();
39
40    /**
41     * Enqueue and localize page specific scripts.
42     */
43    abstract public function page_admin_scripts();
44
45    /**
46     * Render page specific HTML
47     */
48    abstract public function page_render();
49
50    /**
51     * Function called after admin_styles to load any additional needed styles.
52     *
53     * @since 4.3.0
54     */
55    public function additional_styles() {}
56
57    /**
58     * Add common page actions and attach page-specific actions.
59     */
60    public function add_actions() {
61        $is_offline_mode = ( new Status() )->is_offline_mode();
62
63        // If user is not an admin and site is in Offline Mode or not connected yet then don't do anything.
64        if ( ! current_user_can( 'manage_options' ) && ( $is_offline_mode || ! Jetpack::is_connection_ready() ) ) {
65            return;
66        }
67
68        // Is Jetpack not connected and not offline?
69        // True means that Jetpack is NOT connected and NOT in offline mode.
70        // If Jetpack is connected OR in offline mode, this will be false.
71        $connectable = ! Jetpack::is_connection_ready() && ! $is_offline_mode;
72
73        // Don't add in the modules page unless modules are available!
74        if ( $this->dont_show_if_not_active && $connectable ) {
75            return;
76        }
77
78        // Initialize menu item for the page in the admin.
79        $hook = $this->get_page_hook();
80
81        // Attach hooks common to all Jetpack admin pages based on the created hook.
82        add_action( "load-$hook", array( $this, 'admin_page_load' ) );
83        add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) );
84        add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) );
85        add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) );
86
87        // Check if the site plan changed and deactivate modules accordingly.
88        add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) );
89
90        // Attach page specific actions in addition to the above.
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' ) );
95    }
96
97    /**
98     * Render the page with a common top and bottom part, and page specific content.
99     */
100    public function render() {
101        /** This action is documented in class.jetpack.php */
102        do_action( 'jetpack_initialize_tracking' );
103
104        // We're in an IDC: we need a decision made before we show the UI again.
105        if ( $this->block_page_rendering_for_idc() ) {
106            return;
107        }
108
109        // Check if we are looking at the main dashboard.
110        if ( isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic.
111            $this->page_render();
112            return;
113        }
114
115        $args = array();
116
117        // phpcs:ignore WordPress.Security.NonceVerification.Recommended
118        if ( isset( $_GET['page'] ) && 'jetpack_modules' === $_GET['page'] ) {
119            $args['is-wide'] = true;
120        }
121
122        self::wrap_ui( array( $this, 'page_render' ), $args );
123    }
124
125    /**
126     * Call the existing admin page events.
127     */
128    public function admin_page_load() {
129        Jetpack::init()->admin_page_load();
130    }
131
132    /**
133     * Add page specific scripts and jetpack stats for all menu pages.
134     */
135    public function admin_scripts() {
136        $this->page_admin_scripts(); // Delegate to inheriting class.
137        add_action( 'admin_footer', array( Jetpack::init(), 'do_stats' ) );
138    }
139
140    /**
141     * Enqueue the Jetpack admin stylesheet.
142     */
143    public function admin_styles() {
144        $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
145
146        wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons', 'jetpack-connection' ), JETPACK__VERSION . '-20121016' );
147        wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' );
148        wp_style_add_data( 'jetpack-admin', 'suffix', $min );
149    }
150
151    /**
152     * Checks if REST API is enabled.
153     *
154     * @since 4.4.2
155     *
156     * @return bool
157     */
158    public function is_rest_api_enabled() {
159        return /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
160            apply_filters( 'rest_enabled', true ) &&
161            /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
162            apply_filters( 'rest_authentication_errors', true );
163    }
164
165    /**
166     * Checks the site plan and deactivates modules that were active but are no longer included in the plan.
167     *
168     * @since 4.4.0
169     *
170     * @param WP_Screen $page Current WP_Screen object.
171     *
172     * @return array
173     */
174    public function check_plan_deactivate_modules( $page ) {
175        if (
176            ( new Status() )->is_offline_mode()
177            || ! in_array(
178                $page->base,
179                array(
180                    'toplevel_page_jetpack',
181                    'admin_page_jetpack_modules',
182                    'jetpack_page_vaultpress',
183                    'jetpack_page_stats',
184                    'jetpack_page_akismet-key-config',
185                ),
186                true
187            )
188        ) {
189            return false;
190        }
191
192        $current = Jetpack_Plan::get();
193
194        $to_deactivate = array();
195        if ( isset( $current['product_slug'] ) ) {
196            $active = Jetpack::get_active_modules();
197            switch ( $current['product_slug'] ) {
198                case 'jetpack_free':
199                case 'jetpack_personal':
200                case 'jetpack_personal_monthly':
201                    $to_deactivate = array( 'google-analytics', 'wordads', 'search' );
202                    break;
203                case 'jetpack_premium':
204                case 'jetpack_premium_monthly':
205                    $to_deactivate = array( 'google-analytics', 'search' );
206                    break;
207            }
208            $to_deactivate = array_intersect( $active, $to_deactivate );
209
210            $to_leave_enabled = array();
211            foreach ( $to_deactivate as $feature ) {
212                if ( Jetpack_Plan::supports( $feature ) ) {
213                    $to_leave_enabled [] = $feature;
214                }
215            }
216            $to_deactivate = array_diff( $to_deactivate, $to_leave_enabled );
217
218            if ( ! empty( $to_deactivate ) ) {
219                Jetpack::update_active_modules( array_filter( array_diff( $active, $to_deactivate ) ) );
220            }
221        }
222        return array(
223            'current'    => $current,
224            'deactivate' => $to_deactivate,
225        );
226    }
227
228    /**
229     * Enqueue inline wrapper styles for the main container.
230     */
231    public static function load_wrapper_styles() {
232        $rtl = is_rtl() ? '.rtl' : '';
233        wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/admin{$rtl}.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
234        wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min{$rtl}.css", JETPACK__PLUGIN_FILE ), array( 'wp-components' ), JETPACK__VERSION );
235    }
236
237    /**
238     * Build header, content, and footer for admin page.
239     *
240     * @param callable $callback Callback to produce the content of the page. The callback is responsible for any needed escaping.
241     * @param array    $args Options for the wrapping. Also passed to the `jetpack_admin_pages_wrap_ui_after_callback` action.
242     *     - is-wide: (bool) Set the "is-wide" class on the wrapper div, which increases the max width. Default false.
243     *     - show-nav: (bool) Whether to show the navigation bar at the top of the page. Default true.
244     */
245    public static function wrap_ui( $callback, $args = array() ) {
246        $defaults = array(
247            'is-wide'  => false,
248            'show-nav' => true,
249        );
250        $args     = wp_parse_args( $args, $defaults );
251
252        // Is Jetpack not connected and not offline?
253        // True means that Jetpack is NOT connected and NOT in offline mode.
254        // If Jetpack is connected OR in offline mode, this will be false.
255        $connectable = ! Jetpack::is_connection_ready() && ! ( new Status() )->is_offline_mode();
256
257        $jetpack_admin_url = admin_url( 'admin.php?page=jetpack' );
258        $jetpack_about_url = ! $connectable
259            ? admin_url( 'admin.php?page=jetpack_about' )
260            : Redirect::get_url( 'jetpack' );
261
262        $jetpack_privacy_url = ! $connectable
263            ? $jetpack_admin_url . '#/privacy'
264            : Redirect::get_url( 'a8c-privacy' );
265
266        $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>';
267
268        ?>
269        <div id="jp-plugin-container" class="
270        <?php
271        if ( $args['is-wide'] ) {
272            echo 'is-wide'; }
273        ?>
274        ">
275
276            <header class="jp-masthead">
277                <div class="jp-masthead__inside-container">
278                    <div class="jp-masthead__title-container">
279                        <a class="jp-masthead__logo-link" href="<?php echo esc_url( $jetpack_admin_url ); ?>">
280                            <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>
281                        </a>
282                        <h2 class="jp-masthead__title">
283                            <?php
284                            // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- View logic only.
285                            $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
286                            if ( 'jetpack_modules' === $page ) {
287                                esc_html_e( 'Modules', 'jetpack' );
288                            } elseif ( 'jetpack_about' === $page ) {
289                                esc_html_e( 'About', 'jetpack' );
290                            } else {
291                                echo 'Jetpack'; // "Jetpack" is a product name, do not translate.
292                            }
293                            ?>
294                        </h2>
295                    </div>
296                    <?php
297                    if ( $args['show-nav'] && ! ( new Host() )->is_wpcom_platform() ) :
298                        ?>
299                        <div class="jp-masthead__nav">
300                            <?php
301                            if ( is_network_admin() ) {
302                                $current_screen = get_current_screen();
303
304                                $highlight_current_sites    = ( 'toplevel_page_jetpack-network' === $current_screen->id ? 'is-primary' : '' );
305                                $highlight_current_settings = ( 'jetpack_page_jetpack-settings-network' === $current_screen->id ? 'is-primary' : '' );
306                                ?>
307                                <span class="dops-button-group">
308                                    <?php
309                                    if ( current_user_can( 'jetpack_network_sites_page' ) ) {
310                                        ?>
311                                        <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>
312                                        <?php
313                                    } if ( current_user_can( 'jetpack_network_settings_page' ) ) {
314                                        ?>
315                                        <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>
316                                        <?php
317                                    }
318                                    ?>
319                                </span>
320                            <?php } else { ?>
321                                <span class="dops-button-group">
322                                    <a href="<?php echo esc_url( $jetpack_admin_url ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Dashboard', 'jetpack' ); ?></a>
323                                                        <?php
324                                                        if ( current_user_can( 'jetpack_manage_modules' ) ) {
325                                                            ?>
326                                        <a href="<?php echo esc_url( $jetpack_admin_url . '#/settings' ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a>
327                                                            <?php
328                                                        }
329                                                        ?>
330                                </span>
331                            <?php } ?>
332                        </div>
333                    <?php endif; ?>
334                </div>
335            </header>
336            <div class="wrap"><div id="jp-admin-notices" aria-live="polite"></div></div>
337            <!-- START OF CALLBACK -->
338            <?php
339            ob_start();
340            call_user_func( $callback );
341            $callback_ui = ob_get_contents();
342            ob_end_clean();
343            echo $callback_ui;// phpcs:ignore WordPress.Security.EscapeOutput -- Callback is responsible for any needed escaping.
344            ?>
345            <!-- END OF CALLBACK -->
346
347            <div id="jp-stats-report-bottom">
348                <div class="wrap">
349                    <?php
350                    /**
351                     * Fires at the bottom of the Jetpack admin page template, after the dynamic content section.
352                     *
353                     * @since 10.0.0
354                     *
355                     * @param string $callback The callback sent to the Jetpack_Admin_Page::wrap_ui method.
356                     * @param array  $args The arguments sent to the Jetpack_Admin_Page::wrap_ui method.
357                     */
358                    do_action( 'jetpack_admin_pages_wrap_ui_after_callback', $callback, $args );
359                    ?>
360                </div>
361            </div>
362
363            <div class="jp-footer jp-footer--static">
364                <div class="jp-footer__container">
365                    <div class="jp-footer__logo">
366                        <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' ); ?>">
367                            <desc id="jetpack-logo-title">
368                                <?php esc_html_e( 'Jetpack Logo', 'jetpack' ); ?>
369                            </desc>
370                            <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>
371                        </svg>
372                        <span class="jp-footer__module-name">
373                            <a href="<?php echo esc_url( Redirect::get_url( 'jetpack' ) ); ?>" target="_blank" rel="noopener noreferrer" aria-label="Jetpack 12.2-a.0">
374                                <?php esc_html_e( 'Jetpack', 'jetpack' ); ?>
375                            </a>
376                        </span>
377                    </div>
378                    <div class="jp-footer__menu">
379                        <a href="<?php echo esc_url( $jetpack_about_url ); ?>" title="<?php esc_attr__( 'About Jetpack', 'jetpack' ); ?>" class="jp-footer__menu-item">
380                            <?php echo esc_html__( 'About', 'jetpack' ); ?>
381                        </a>
382                        <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'; ?>">
383                            <?php echo esc_html_x( 'Privacy', 'Navigation item', 'jetpack' ); ?>
384                            <?php echo ! $connectable ? $external_link_icon : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
385                        </a>
386                        <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">
387                            <?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?>
388                            <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
389                        </a>
390                        <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">
391                            Version <?php echo esc_html( JETPACK__VERSION ); ?>
392                            <?php echo $external_link_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
393                        </a>
394                        <?php if ( is_multisite() && current_user_can( 'jetpack_network_sites_page' ) ) { ?>
395                            <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>
396                        <?php } ?>
397                        <?php if ( is_multisite() && current_user_can( 'jetpack_network_settings_page' ) ) { ?>
398                            <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>
399                        <?php } ?>
400                        <?php if ( current_user_can( 'manage_options' ) ) { ?>
401                            <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>
402                            <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>
403                        <?php } ?>
404                    </div>
405                    <a class="jp-footer__a8c-logo" href="<?php echo esc_url( $jetpack_about_url ); ?>" aria-label="<?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?>">
406                        <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">
407                            <desc id="jp-automattic-byline-logo-title">
408                                <?php echo esc_attr__( 'An Automattic Airline', 'jetpack' ); ?>
409                            </desc>
410                            <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>
411                        </svg>
412                    </a>
413                </div>
414            </div>
415        </div>
416        <?php
417    }
418
419    /**
420     * Should we block the page rendering because the site is in IDC?
421     *
422     * @return bool
423     */
424    protected function block_page_rendering_for_idc() {
425        return Jetpack::is_connection_ready() && Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' );
426    }
427
428    /**
429     * Set a page title for both the module list page and the debugger page.
430     * We set these here because we do not register a page title when we register them,
431     * so they do not appear in the admin navigation.
432     *
433     * @since 15.4
434     *
435     * @param WP_Screen $screen The screen object.
436     *
437     * @return void
438     */
439    public static function override_page_title( WP_Screen $screen ) {
440        global $title;
441        if ( 'admin_page_jetpack_modules' === $screen->id ) {
442            $title = __( 'Jetpack Settings', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page.
443        } elseif ( 'admin_page_jetpack-debugger' === $screen->id ) {
444            $title = __( 'Debugging Center', 'jetpack' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- we override the title global only on this page.
445        }
446    }
447}