| @@ 119-146 (lines=28) @@ | ||
| 116 | * |
|
| 117 | * @return void |
|
| 118 | */ |
|
| 119 | public function wordpress_init() { |
|
| 120 | if ( ! current_user_can( 'jetpack_disconnect' ) && is_admin() ) { |
|
| 121 | add_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) ); |
|
| 122 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) ); |
|
| 123 | add_action( 'current_screen', array( $this, 'non_admins_current_screen_check' ) ); |
|
| 124 | ||
| 125 | return; |
|
| 126 | } |
|
| 127 | ||
| 128 | if ( |
|
| 129 | isset( $_GET['jetpack_idc_clear_confirmation'], $_GET['_wpnonce'] ) && |
|
| 130 | wp_verify_nonce( $_GET['_wpnonce'], 'jetpack_idc_clear_confirmation' ) |
|
| 131 | ) { |
|
| 132 | Jetpack_Options::delete_option( 'safe_mode_confirmed' ); |
|
| 133 | self::$is_safe_mode_confirmed = false; |
|
| 134 | } else { |
|
| 135 | self::$is_safe_mode_confirmed = (bool) Jetpack_Options::get_option( 'safe_mode_confirmed' ); |
|
| 136 | } |
|
| 137 | ||
| 138 | // 121 Priority so that it's the most inner Jetpack item in the admin bar. |
|
| 139 | add_action( 'admin_bar_menu', array( $this, 'display_admin_bar_button' ), 121 ); |
|
| 140 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_bar_css' ) ); |
|
| 141 | ||
| 142 | if ( is_admin() && ! self::$is_safe_mode_confirmed ) { |
|
| 143 | add_action( 'admin_notices', array( $this, 'display_idc_notice' ) ); |
|
| 144 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) ); |
|
| 145 | } |
|
| 146 | } |
|
| 147 | ||
| 148 | /** |
|
| 149 | * Non-admins current screen check. |
|
| @@ 93-119 (lines=27) @@ | ||
| 90 | } |
|
| 91 | } |
|
| 92 | ||
| 93 | function wordpress_init() { |
|
| 94 | if ( ! current_user_can( 'jetpack_disconnect' ) && is_admin() ) { |
|
| 95 | add_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) ); |
|
| 96 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) ); |
|
| 97 | add_action( 'current_screen', array( $this, 'non_admins_current_screen_check' ) ); |
|
| 98 | return; |
|
| 99 | } |
|
| 100 | ||
| 101 | if ( |
|
| 102 | isset( $_GET['jetpack_idc_clear_confirmation'], $_GET['_wpnonce'] ) && |
|
| 103 | wp_verify_nonce( $_GET['_wpnonce'], 'jetpack_idc_clear_confirmation' ) |
|
| 104 | ) { |
|
| 105 | Jetpack_Options::delete_option( 'safe_mode_confirmed' ); |
|
| 106 | self::$is_safe_mode_confirmed = false; |
|
| 107 | } else { |
|
| 108 | self::$is_safe_mode_confirmed = (bool) Jetpack_Options::get_option( 'safe_mode_confirmed' ); |
|
| 109 | } |
|
| 110 | ||
| 111 | // 121 Priority so that it's the most inner Jetpack item in the admin bar. |
|
| 112 | add_action( 'admin_bar_menu', array( $this, 'display_admin_bar_button' ), 121 ); |
|
| 113 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_bar_css' ) ); |
|
| 114 | ||
| 115 | if ( is_admin() && ! self::$is_safe_mode_confirmed ) { |
|
| 116 | add_action( 'admin_notices', array( $this, 'display_idc_notice' ) ); |
|
| 117 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) ); |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| 121 | function non_admins_current_screen_check( $current_screen ) { |
|
| 122 | self::$current_screen = $current_screen; |
|