summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.jetpack-idc.php')
-rw-r--r--plugins/jetpack/class.jetpack-idc.php73
1 files changed, 46 insertions, 27 deletions
diff --git a/plugins/jetpack/class.jetpack-idc.php b/plugins/jetpack/class.jetpack-idc.php
index 64d91f1d..1b4f51dc 100644
--- a/plugins/jetpack/class.jetpack-idc.php
+++ b/plugins/jetpack/class.jetpack-idc.php
@@ -1,5 +1,8 @@
<?php
+use Automattic\Jetpack\Assets;
+use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
+
/**
* This class will handle everything involved with fixing an Identity Crisis.
*
@@ -14,31 +17,35 @@ class Jetpack_IDC {
/**
* The wpcom value of the home URL
+ *
* @var string
*/
static $wpcom_home_url;
/**
* Has safe mode been confirmed?
+ *
* @var bool
*/
static $is_safe_mode_confirmed;
/**
* The current screen, which is set if the current user is a non-admin and this is an admin page.
+ *
* @var WP_Screen
*/
static $current_screen;
/**
* The link to the support document used to explain Safe Mode to users
+ *
* @var string
*/
const SAFE_MODE_DOC_LINK = 'https://jetpack.com/support/safe-mode';
static function init() {
if ( is_null( self::$instance ) ) {
- self::$instance = new Jetpack_IDC;
+ self::$instance = new Jetpack_IDC();
}
return self::$instance;
@@ -46,7 +53,6 @@ class Jetpack_IDC {
private function __construct() {
add_action( 'jetpack_sync_processed_actions', array( $this, 'maybe_clear_migrate_option' ) );
-
if ( false === $urls_in_crisis = Jetpack::check_identity_crisis() ) {
return;
}
@@ -84,7 +90,7 @@ class Jetpack_IDC {
function wordpress_init() {
if ( ! current_user_can( 'jetpack_disconnect' ) && is_admin() ) {
add_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) );
- add_action( 'admin_enqueue_scripts', array( $this,'enqueue_idc_notice_files' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
add_action( 'current_screen', array( $this, 'non_admins_current_screen_check' ) );
return;
}
@@ -105,7 +111,7 @@ class Jetpack_IDC {
if ( is_admin() && ! self::$is_safe_mode_confirmed ) {
add_action( 'admin_notices', array( $this, 'display_idc_notice' ) );
- add_action( 'admin_enqueue_scripts', array( $this,'enqueue_idc_notice_files' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
}
}
@@ -119,7 +125,7 @@ class Jetpack_IDC {
// then do not show the non-admin notice.
if ( isset( $_COOKIE, $_COOKIE['jetpack_idc_dismiss_notice'] ) ) {
remove_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) );
- remove_action( 'admin_enqueue_scripts', array( $this,'enqueue_idc_notice_files' ) );
+ remove_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
}
}
@@ -147,7 +153,7 @@ class Jetpack_IDC {
if ( ! self::$is_safe_mode_confirmed ) {
$menu['meta'] = array(
- 'class' => 'hide'
+ 'class' => 'hide',
);
}
@@ -190,7 +196,7 @@ class Jetpack_IDC {
}
$current_screen = get_current_screen();
- $tabs = $current_screen->get_help_tabs();
+ $tabs = $current_screen->get_help_tabs();
return ! empty( $tabs );
}
@@ -218,7 +224,8 @@ class Jetpack_IDC {
</p>
</div>
</div>
- <?php }
+ <?php
+ }
/**
* First "step" of the IDC mitigation. Will provide some messaging and two options/buttons.
@@ -236,7 +243,8 @@ class Jetpack_IDC {
<?php $this->render_notice_first_step(); ?>
<?php $this->render_notice_second_step(); ?>
</div>
- <?php }
+ <?php
+ }
function enqueue_admin_bar_css() {
wp_enqueue_style(
@@ -254,7 +262,7 @@ class Jetpack_IDC {
wp_enqueue_script(
'jetpack-idc-js',
- Jetpack::get_file_url_for_environment( '_inc/build/idc-notice.min.js', '_inc/idc-notice.js' ),
+ Assets::get_file_url_for_environment( '_inc/build/idc-notice.min.js', '_inc/idc-notice.js' ),
array( 'jquery' ),
JETPACK__VERSION,
true
@@ -264,12 +272,12 @@ class Jetpack_IDC {
'jetpack-idc-js',
'idcL10n',
array(
- 'apiRoot' => esc_url_raw( rest_url() ),
- 'nonce' => wp_create_nonce( 'wp_rest' ),
- 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
- 'currentUrl' => remove_query_arg( '_wpnonce', remove_query_arg( 'jetpack_idc_clear_confirmation' ) ),
+ 'apiRoot' => esc_url_raw( rest_url() ),
+ 'nonce' => wp_create_nonce( 'wp_rest' ),
+ 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
+ 'currentUrl' => remove_query_arg( '_wpnonce', remove_query_arg( 'jetpack_idc_clear_confirmation' ) ),
'tracksEventData' => array(
- 'isAdmin' => current_user_can( 'jetpack_disconnect' ),
+ 'isAdmin' => current_user_can( 'jetpack_disconnect' ),
'currentScreen' => self::$current_screen ? self::$current_screen->id : false,
),
)
@@ -278,7 +286,7 @@ class Jetpack_IDC {
if ( ! wp_style_is( 'jetpack-dops-style' ) ) {
wp_register_style(
'jetpack-dops-style',
- plugins_url( '_inc/build/admin.dops-style.css', JETPACK__PLUGIN_FILE ),
+ plugins_url( '_inc/build/admin.css', JETPACK__PLUGIN_FILE ),
array(),
JETPACK__VERSION
);
@@ -309,10 +317,14 @@ class Jetpack_IDC {
);
}
- function render_notice_header() { ?>
+ function render_notice_header() {
+ ?>
<div class="jp-idc-notice__header">
<div class="jp-idc-notice__header__emblem">
- <?php echo Jetpack::get_jp_emblem(); ?>
+ <?php
+ $jetpack_logo = new Jetpack_Logo();
+ echo $jetpack_logo->get_jp_emblem();
+ ?>
</div>
<p class="jp-idc-notice__header__text">
<?php esc_html_e( 'Jetpack Safe Mode', 'jetpack' ); ?>
@@ -320,13 +332,15 @@ class Jetpack_IDC {
</div>
<div class="jp-idc-notice__separator"></div>
- <?php }
+ <?php
+ }
/**
* Is a container for the error notices.
* Will be shown/controlled by jQuery in idc-notice.js
*/
- function render_error_notice() { ?>
+ function render_error_notice() {
+ ?>
<div class="jp-idc-error__notice dops-notice is-error">
<svg class="gridicon gridicons-notice dops-notice__icon" height="24" width="24" viewBox="0 0 24 24">
<g>
@@ -345,9 +359,11 @@ class Jetpack_IDC {
</a>
</div>
</div>
- <?php }
+ <?php
+ }
- function render_notice_first_step() { ?>
+ function render_notice_first_step() {
+ ?>
<div class="jp-idc-notice__first-step">
<div class="jp-idc-notice__content-header">
<h3 class="jp-idc-notice__content-header__lead">
@@ -381,9 +397,11 @@ class Jetpack_IDC {
</div>
</div>
</div>
- <?php }
+ <?php
+ }
- function render_notice_second_step() { ?>
+ function render_notice_second_step() {
+ ?>
<div class="jp-idc-notice__second-step">
<div class="jp-idc-notice__content-header">
<h3 class="jp-idc-notice__content-header__lead">
@@ -418,7 +436,8 @@ class Jetpack_IDC {
<?php echo $this->get_unsure_prompt(); ?>
</p>
</div>
- <?php }
+ <?php
+ }
function get_first_step_header_lead() {
$html = wp_kses(
@@ -492,7 +511,7 @@ class Jetpack_IDC {
}
function get_confirm_safe_mode_button_text() {
- $string = esc_html__( 'Confirm Safe Mode', 'jetpack' );
+ $string = esc_html__( 'Confirm Safe Mode', 'jetpack' );
/**
* Allows overriding of the default text used for the confirm safe mode action button.
@@ -697,4 +716,4 @@ class Jetpack_IDC {
}
}
-Jetpack_IDC::init();
+add_action( 'plugins_loaded', array( 'Jetpack_IDC', 'init' ) );