summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.jetpack-admin.php')
-rw-r--r--plugins/jetpack/class.jetpack-admin.php58
1 files changed, 30 insertions, 28 deletions
diff --git a/plugins/jetpack/class.jetpack-admin.php b/plugins/jetpack/class.jetpack-admin.php
index 18f18f7d..0245e1b3 100644
--- a/plugins/jetpack/class.jetpack-admin.php
+++ b/plugins/jetpack/class.jetpack-admin.php
@@ -1,5 +1,6 @@
<?php
+use Automattic\Jetpack\Status;
// Build the Jetpack admin menu as a whole
class Jetpack_Admin {
@@ -15,12 +16,12 @@ class Jetpack_Admin {
private $jetpack;
static function init() {
- if( isset( $_GET['page'] ) && $_GET['page'] === 'jetpack' ) {
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'jetpack' ) {
add_filter( 'nocache_headers', array( 'Jetpack_Admin', 'add_no_store_header' ), 100 );
}
if ( is_null( self::$instance ) ) {
- self::$instance = new Jetpack_Admin;
+ self::$instance = new Jetpack_Admin();
}
return self::$instance;
}
@@ -34,27 +35,27 @@ class Jetpack_Admin {
$this->jetpack = Jetpack::init();
jetpack_require_lib( 'admin-pages/class.jetpack-react-page' );
- $this->jetpack_react = new Jetpack_React_Page;
+ $this->jetpack_react = new Jetpack_React_Page();
jetpack_require_lib( 'admin-pages/class.jetpack-settings-page' );
- $this->fallback_page = new Jetpack_Settings_Page;
+ $this->fallback_page = new Jetpack_Settings_Page();
jetpack_require_lib( 'admin-pages/class-jetpack-about-page' );
- $this->jetpack_about = new Jetpack_About_Page;
+ $this->jetpack_about = new Jetpack_About_Page();
- add_action( 'admin_menu', array( $this->jetpack_react, 'add_actions' ), 998 );
- add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'jetpack_add_dashboard_sub_nav_item' ) );
- add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'jetpack_add_settings_sub_nav_item' ) );
- add_action( 'jetpack_admin_menu', array( $this, 'admin_menu_debugger' ) );
- add_action( 'jetpack_admin_menu', array( $this->fallback_page, 'add_actions' ) );
- add_action( 'jetpack_admin_menu', array( $this->jetpack_about, 'add_actions' ) );
+ add_action( 'admin_menu', array( $this->jetpack_react, 'add_actions' ), 998 );
+ add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'jetpack_add_dashboard_sub_nav_item' ) );
+ add_action( 'jetpack_admin_menu', array( $this->jetpack_react, 'jetpack_add_settings_sub_nav_item' ) );
+ add_action( 'jetpack_admin_menu', array( $this, 'admin_menu_debugger' ) );
+ add_action( 'jetpack_admin_menu', array( $this->fallback_page, 'add_actions' ) );
+ add_action( 'jetpack_admin_menu', array( $this->jetpack_about, 'add_actions' ) );
// Add redirect to current page for activation/deactivation of modules
- add_action( 'jetpack_pre_activate_module', array( $this, 'fix_redirect' ), 10, 2 );
+ add_action( 'jetpack_pre_activate_module', array( $this, 'fix_redirect' ), 10, 2 );
add_action( 'jetpack_pre_deactivate_module', array( $this, 'fix_redirect' ) );
// Add module bulk actions handler
- add_action( 'jetpack_unrecognized_action', array( $this, 'handle_unrecognized_action' ) );
+ add_action( 'jetpack_unrecognized_action', array( $this, 'handle_unrecognized_action' ) );
}
static function sort_requires_connection_last( $module1, $module2 ) {
@@ -72,12 +73,12 @@ class Jetpack_Admin {
// Produce JS understandable objects of modules containing information for
// presentation like description, name, configuration url, etc.
function get_modules() {
- include_once( JETPACK__PLUGIN_DIR . 'modules/module-info.php' );
+ include_once JETPACK__PLUGIN_DIR . 'modules/module-info.php';
$available_modules = Jetpack::get_available_modules();
$active_modules = Jetpack::get_active_modules();
$modules = array();
- $jetpack_active = Jetpack::is_active() || Jetpack::is_development_mode();
- $overrides = Jetpack_Modules_Overrides::instance();
+ $jetpack_active = Jetpack::is_active() || ( new Status() )->is_development_mode();
+ $overrides = Jetpack_Modules_Overrides::instance();
foreach ( $available_modules as $module ) {
if ( $module_array = Jetpack::get_module( $module ) ) {
/**
@@ -128,12 +129,12 @@ class Jetpack_Admin {
/**
* Filter the long description of a module.
- *
- * @since 3.5.0
- *
- * @param string ob_get_clean() The module long description.
+ *
+ * @since 3.5.0
+ *
+ * @param string ob_get_clean() The module long description.
* @param string $module The module name.
- */
+ */
$module_array['long_description'] = apply_filters( 'jetpack_long_module_description', ob_get_clean(), $module );
ob_start();
@@ -186,8 +187,9 @@ class Jetpack_Admin {
}
static function is_module_available( $module ) {
- if ( ! is_array( $module ) || empty( $module ) )
+ if ( ! is_array( $module ) || empty( $module ) ) {
return false;
+ }
/**
* We never want to show VaultPress as activatable through Jetpack.
@@ -196,7 +198,7 @@ class Jetpack_Admin {
return false;
}
- if ( Jetpack::is_development_mode() ) {
+ if ( ( new Status() )->is_development_mode() ) {
return ! ( $module['requires_connection'] );
} else {
if ( ! Jetpack::is_active() ) {
@@ -208,8 +210,8 @@ class Jetpack_Admin {
}
function handle_unrecognized_action( $action ) {
- switch( $action ) {
- case 'bulk-activate' :
+ switch ( $action ) {
+ case 'bulk-activate':
if ( ! current_user_can( 'jetpack_activate_modules' ) ) {
break;
}
@@ -217,14 +219,14 @@ class Jetpack_Admin {
$modules = (array) $_GET['modules'];
$modules = array_map( 'sanitize_key', $modules );
check_admin_referer( 'bulk-jetpack_page_jetpack_modules' );
- foreach( $modules as $module ) {
+ foreach ( $modules as $module ) {
Jetpack::log( 'activate', $module );
Jetpack::activate_module( $module, false );
}
// The following two lines will rarely happen, as Jetpack::activate_module normally exits at the end.
wp_safe_redirect( wp_get_referer() );
exit;
- case 'bulk-deactivate' :
+ case 'bulk-deactivate':
if ( ! current_user_can( 'jetpack_deactivate_modules' ) ) {
break;
}
@@ -268,7 +270,7 @@ class Jetpack_Admin {
add_action( "admin_head-$debugger_hook", array( 'Jetpack_Debugger', 'jetpack_debug_admin_head' ) );
}
- function wrap_debugger_page( ) {
+ function wrap_debugger_page() {
nocache_headers();
if ( ! current_user_can( 'manage_options' ) ) {
die( '-1' );