summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/class.jetpack-network.php')
-rw-r--r--plugins/jetpack/class.jetpack-network.php439
1 files changed, 199 insertions, 240 deletions
diff --git a/plugins/jetpack/class.jetpack-network.php b/plugins/jetpack/class.jetpack-network.php
index bf6b6d38..00218ed1 100644
--- a/plugins/jetpack/class.jetpack-network.php
+++ b/plugins/jetpack/class.jetpack-network.php
@@ -1,4 +1,15 @@
-<?php
+<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFilename
+/**
+ * Jetpack Network Manager class file.
+ *
+ * @package jetpack
+ */
+
+use Automattic\Jetpack\Connection\Client;
+use Automattic\Jetpack\Connection\Manager;
+use Automattic\Jetpack\Connection\Utils as Connection_Utils;
+use Automattic\Jetpack\Constants;
+use Automattic\Jetpack\Status;
/**
* Used to manage Jetpack installation on Multisite Network installs
@@ -20,6 +31,14 @@ class Jetpack_Network {
private static $instance = null;
/**
+ * An instance of the connection manager object.
+ *
+ * @since 7.7
+ * @var Automattic\Jetpack\Connection\Manager
+ */
+ private $connection;
+
+ /**
* Name of the network wide settings
*
* @since 2.9
@@ -34,9 +53,8 @@ class Jetpack_Network {
* @var array
*/
private $setting_defaults = array(
- 'auto-connect' => 0,
- 'sub-site-connection-override' => 1,
- //'manage_auto_activated_modules' => 0,
+ 'auto-connect' => 0,
+ 'sub-site-connection-override' => 1,
);
/**
@@ -45,9 +63,10 @@ class Jetpack_Network {
* @since 2.9
*/
private function __construct() {
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); // For the is_plugin... check
- require_once( JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php' ); // For managing the global whitelist
- /*
+ require_once ABSPATH . '/wp-admin/includes/plugin.php'; // For the is_plugin... check.
+ require_once JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php'; // For managing the global whitelist.
+
+ /**
* Sanity check to ensure the install is Multisite and we
* are in Network Admin
*/
@@ -70,15 +89,21 @@ class Jetpack_Network {
/*
* If admin wants to automagically register new sites set the hook here
*
- * This is a hacky way because xmlrpc is not available on wpmu_new_blog
+ * This is a hacky way because xmlrpc is not available on wp_initialize_site
*/
- if ( $this->get_option( 'auto-connect' ) == 1 ) {
- add_action( 'wpmu_new_blog', array( $this, 'do_automatically_add_new_site' ) );
+ if ( 1 === $this->get_option( 'auto-connect' ) ) {
+ add_action( 'wp_initialize_site', array( $this, 'do_automatically_add_new_site' ) );
}
}
+ }
- // Remove the toggles for 2.9, re-evaluate how they're done and added for a 3.0 release. They don't feel quite right yet.
- // add_filter( 'jetpack_get_default_modules', array( $this, 'set_auto_activated_modules' ) );
+ /**
+ * Sets a connection object.
+ *
+ * @param Automattic\Jetpack\Connection\Manager $connection the connection manager object.
+ */
+ public function set_connection( Manager $connection ) {
+ $this->connection = $connection;
}
/**
@@ -86,33 +111,27 @@ class Jetpack_Network {
* Modules can be set in Network Admin > Jetpack > Settings
*
* @since 2.9
+ * @deprecated since 7.7.0
*
- * @param array $modules
- *
- * @return array
- **/
- public function set_auto_activated_modules( $modules ) {
- return $modules;
-
- /* Remove the toggles for 2.9, re-evaluate how they're done and added for a 3.0 release. They don't feel quite right yet.
- if( 1 == $this->get_option( 'manage_auto_activated_modules' ) ) {
- return (array) $this->get_option( 'modules' );
- } else {
- return $modules;
- }
- */
+ * @param array $modules List of modules.
+ */
+ public function set_auto_activated_modules( $modules ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ _deprecated_function( __METHOD__, 'jetpack-7.7' );
}
/**
* Registers new sites upon creation
*
* @since 2.9
- * @uses wpmu_new_blog
+ * @since 7.4.0 Uses a WP_Site object.
+ * @uses wp_initialize_site
*
- * @param int $blog_id
+ * @param WP_Site $site the WordPress site object.
**/
- public function do_automatically_add_new_site( $blog_id ) {
- $this->do_subsiteregister( $blog_id );
+ public function do_automatically_add_new_site( $site ) {
+ if ( is_a( $site, 'WP_Site' ) ) {
+ $this->do_subsiteregister( $site->id );
+ }
}
/**
@@ -120,6 +139,9 @@ class Jetpack_Network {
* Helps distinguish network admin JP styles from regular site JP styles
*
* @since 2.9
+ *
+ * @param String $classes current assigned body classes.
+ * @return String amended class string.
*/
public function body_class( $classes ) {
return trim( $classes ) . ' network-admin ';
@@ -135,7 +157,7 @@ class Jetpack_Network {
*/
public static function init() {
if ( ! self::$instance || ! is_a( self::$instance, 'Jetpack_Network' ) ) {
- self::$instance = new Jetpack_Network;
+ self::$instance = new Jetpack_Network();
}
return self::$instance;
@@ -162,7 +184,7 @@ class Jetpack_Network {
* @since 2.9
**/
public function deactivate() {
- // Only fire if in network admin
+ // Only fire if in network admin.
if ( ! is_network_admin() ) {
return;
}
@@ -176,10 +198,10 @@ class Jetpack_Network {
/*
* If this plugin was activated in the subsite individually
* we do not want to call disconnect. Plugins activated
- * individually (before network activation) stay activated
- * when the network deactivation occurs
- */
- if ( ! in_array( 'jetpack/jetpack.php', $active_plugins ) ) {
+ * individually (before network activation) stay activated
+ * when the network deactivation occurs
+ */
+ if ( ! in_array( 'jetpack/jetpack.php', $active_plugins, true ) ) {
Jetpack::disconnect();
}
}
@@ -198,12 +220,14 @@ class Jetpack_Network {
return;
}
- $wp_admin_bar->add_node( array(
- 'parent' => 'network-admin',
- 'id' => 'network-admin-jetpack',
- 'title' => 'Jetpack',
- 'href' => $this->get_url( 'network_admin_page' ),
- ) );
+ $wp_admin_bar->add_node(
+ array(
+ 'parent' => 'network-admin',
+ 'id' => 'network-admin-jetpack',
+ 'title' => 'Jetpack',
+ 'href' => $this->get_url( 'network_admin_page' ),
+ )
+ );
}
/**
@@ -219,23 +243,25 @@ class Jetpack_Network {
*
* @since 2.9
*
- * @param Mixed $args
+ * @param Mixed $args URL parameters.
*
* @return String
**/
public function get_url( $args ) {
- $url = null; // Default url value
+ $url = null; // Default url value.
if ( is_string( $args ) ) {
$name = $args;
- } else {
+ } else if ( is_array( $args ) ) {
$name = $args['name'];
+ } else {
+ return $url;
}
switch ( $name ) {
case 'subsiteregister':
if ( ! isset( $args['site_id'] ) ) {
- break; // If there is not a site id present we cannot go further
+ break; // If there is not a site id present we cannot go further.
}
$url = network_admin_url(
'admin.php?page=jetpack&action=subsiteregister&site_id='
@@ -249,7 +275,7 @@ class Jetpack_Network {
case 'subsitedisconnect':
if ( ! isset( $args['site_id'] ) ) {
- break; // If there is not a site id present we cannot go further
+ break; // If there is not a site id present we cannot go further.
}
$url = network_admin_url(
'admin.php?page=jetpack&action=subsitedisconnect&site_id='
@@ -268,16 +294,16 @@ class Jetpack_Network {
*/
public function add_network_admin_menu() {
add_menu_page( 'Jetpack', 'Jetpack', 'jetpack_network_admin_page', 'jetpack', array( $this, 'wrap_network_admin_page' ), 'div', 3 );
- $jetpack_sites_page_hook = add_submenu_page( 'jetpack', __( 'Jetpack Sites', 'jetpack' ), __( 'Sites', 'jetpack' ), 'jetpack_network_sites_page', 'jetpack', array( $this, 'wrap_network_admin_page' ) );
+ $jetpack_sites_page_hook = add_submenu_page( 'jetpack', __( 'Jetpack Sites', 'jetpack' ), __( 'Sites', 'jetpack' ), 'jetpack_network_sites_page', 'jetpack', array( $this, 'wrap_network_admin_page' ) );
$jetpack_settings_page_hook = add_submenu_page( 'jetpack', __( 'Settings', 'jetpack' ), __( 'Settings', 'jetpack' ), 'jetpack_network_settings_page', 'jetpack-settings', array( $this, 'wrap_render_network_admin_settings_page' ) );
- add_action( "admin_print_styles-$jetpack_sites_page_hook", array( 'Jetpack_Admin_Page', 'load_wrapper_styles' ) );
- add_action( "admin_print_styles-$jetpack_settings_page_hook", array( 'Jetpack_Admin_Page', 'load_wrapper_styles' ) );
+ add_action( "admin_print_styles-$jetpack_sites_page_hook", array( 'Jetpack_Admin_Page', 'load_wrapper_styles' ) );
+ add_action( "admin_print_styles-$jetpack_settings_page_hook", array( 'Jetpack_Admin_Page', 'load_wrapper_styles' ) );
/**
* As jetpack_register_genericons is by default fired off a hook,
* the hook may have already fired by this point.
* So, let's just trigger it manually.
*/
- require_once( JETPACK__PLUGIN_DIR . '_inc/genericons.php' );
+ require_once JETPACK__PLUGIN_DIR . '_inc/genericons.php';
jetpack_register_genericons();
if ( ! wp_style_is( 'jetpack-icons', 'registered' ) ) {
@@ -292,7 +318,7 @@ class Jetpack_Network {
*
* @since 2.9
**/
- function admin_menu_css() {
+ public function admin_menu_css() {
wp_enqueue_style( 'jetpack-icons' );
}
@@ -308,22 +334,25 @@ class Jetpack_Network {
if ( isset( $_GET['action'] ) ) {
switch ( $_GET['action'] ) {
case 'subsiteregister':
- /*
+ /**
+ * Add actual referrer checking.
+ *
* @todo check_admin_referer( 'jetpack-subsite-register' );
*/
Jetpack::log( 'subsiteregister' );
- // If !$_GET['site_id'] stop registration and error
+ // If !$_GET['site_id'] stop registration and error.
if ( ! isset( $_GET['site_id'] ) || empty( $_GET['site_id'] ) ) {
- // Log error to state cookie for display later
/**
+ * Log error to state cookie for display later.
+ *
* @todo Make state messages show on Jetpack NA pages
- **/
+ */
Jetpack::state( 'missing_site_id', esc_html__( 'Site ID must be provided to register a sub-site.', 'jetpack' ) );
break;
}
- // Send data to register endpoint and retrieve shadow blog details
+ // Send data to register endpoint and retrieve shadow blog details.
$result = $this->do_subsiteregister();
$url = $this->get_url( 'network_admin_page' );
@@ -355,16 +384,19 @@ class Jetpack_Network {
}
}
+ /**
+ * Shows the Jetpack plugin notices.
+ */
public function show_jetpack_notice() {
if ( isset( $_GET['action'] ) && 'connected' == $_GET['action'] ) {
- $notice = __( 'Site successfully connected.', 'jetpack' );
+ $notice = __( 'Site successfully connected.', 'jetpack' );
$classname = 'updated';
- } else if ( isset( $_GET['action'] ) && 'connection_failed' == $_GET['action'] ) {
- $notice = __( 'Site connection failed!', 'jetpack' );
+ } elseif ( isset( $_GET['action'] ) && 'connection_failed' == $_GET['action'] ) {
+ $notice = __( 'Site connection failed!', 'jetpack' );
$classname = 'error';
}
?>
- <div id="message" class="<?php echo esc_attr( $classname );?> jetpack-message jp-connect" style="display:block !important;">
+ <div id="message" class="<?php echo esc_attr( $classname ); ?> jetpack-message jp-connect" style="display:block !important;">
<p><?php echo esc_html( $notice ); ?></p>
</div>
<?php
@@ -375,6 +407,8 @@ class Jetpack_Network {
*
* @since 2.9
* @see Jetpack_Network::jetpack_sites_list()
+ *
+ * @param int $site_id the site identifier.
*/
public function do_subsitedisconnect( $site_id = null ) {
if ( ! current_user_can( 'jetpack_disconnect' ) ) {
@@ -392,28 +426,21 @@ class Jetpack_Network {
* @since 2.9
* @todo Break apart into easier to manage chunks that can be unit tested
* @see Jetpack_Network::jetpack_sites_list();
+ *
+ * @param int $site_id the site identifier.
*/
public function do_subsiteregister( $site_id = null ) {
if ( ! current_user_can( 'jetpack_disconnect' ) ) {
return;
}
- if ( Jetpack::is_development_mode() ) {
+ if ( ( new Status() )->is_development_mode() ) {
return;
}
- $jp = Jetpack::init();
-
- // Figure out what site we are working on
+ // Figure out what site we are working on.
$site_id = ( is_null( $site_id ) ) ? $_GET['site_id'] : $site_id;
- // better to try (and fail) to set a higher timeout than this system
- // supports than to have register fail for more users than it should
- $timeout = Jetpack::set_min_time_limit( 60 ) / 2;
-
- // The blog id on WordPress.com of the primary network site
- $network_wpcom_blog_id = Jetpack_Options::get_option( 'id' );
-
/*
* Here we need to switch to the subsite
* For the registration process we really only hijack how it
@@ -421,44 +448,52 @@ class Jetpack_Network {
*/
switch_to_blog( $site_id );
+ add_filter( 'jetpack_register_request_body', array( $this, 'filter_register_request_body' ) );
+ add_action( 'jetpack_site_registered_user_token', array( $this, 'filter_register_user_token' ) );
+
// Save the secrets in the subsite so when the wpcom server does a pingback it
- // will be able to validate the connection
- $secrets = $jp->generate_secrets( 'register' );
- if (
- empty( $secrets['secret_1'] ) ||
- empty( $secrets['secret_2'] ) ||
- empty( $secrets['exp'] )
- ) {
- return new Jetpack_Error( 'missing_secrets' );
- }
+ // will be able to validate the connection.
+ $result = $this->connection->register( 'subsiteregister' );
- // Gra info for gmt offset
- $gmt_offset = get_option( 'gmt_offset' );
- if ( ! $gmt_offset ) {
- $gmt_offset = 0;
+ if ( is_wp_error( $result ) || ! $result ) {
+ restore_current_blog();
+ return $result;
}
- /*
- * Get the stats_option option from the db.
- * It looks like the server strips this out so maybe it is not necessary?
- * Does it match the Jetpack site with the old stats plugin id?
- *
- * @todo Find out if sending the stats_id is necessary
- */
- $stat_options = get_option( 'stats_options' );
- $stat_id = $stat_options = isset( $stats_options['blog_id'] ) ? $stats_options['blog_id'] : null;
- $user_id = get_current_user_id();
+ Jetpack::activate_default_modules( false, false, array(), false );
- $tracks_identity = jetpack_tracks_get_identity( $user_id );
+ restore_current_blog();
+ }
- /*
- * Use the subsite's registration date as the site creation date.
- *
- * This is in contrast to regular standalone sites, where we use the helper
- * `Jetpack::get_assumed_site_creation_date()` to assume the site's creation date.
- */
+ /**
+ * Receives the registration response token.
+ *
+ * @param Object $token the received token.
+ */
+ public function filter_register_user_token( $token ) {
+ $is_master_user = ! Jetpack::is_active();
+ Connection_Utils::update_user_token(
+ get_current_user_id(),
+ sprintf( '%s.%d', $token->secret, get_current_user_id() ),
+ $is_master_user
+ );
+ }
+
+ /**
+ * Filters the registration request body to include additional properties.
+ *
+ * @param Array $properties standard register request body properties.
+ * @return Array amended properties.
+ */
+ public function filter_register_request_body( $properties ) {
$blog_details = get_blog_details();
- $site_creation_date = $blog_details->registered;
+
+ $network = get_network();
+
+ switch_to_blog( $network->blog_id );
+ // The blog id on WordPress.com of the primary network site.
+ $network_wpcom_blog_id = Jetpack_Options::get_option( 'id' );
+ restore_current_blog();
/**
* Both `state` and `user_id` need to be sent in the request, even though they are the same value.
@@ -466,99 +501,28 @@ class Jetpack_Network {
* because we assume the main site is already authorized. `state` is used to verify the `register()`
* request, while `user_id()` is used to create the token in the `authorize()` request.
*/
- $args = array(
- 'method' => 'POST',
- 'body' => array(
+ return array_merge(
+ $properties,
+ array(
'network_url' => $this->get_url( 'network_admin_page' ),
'network_wpcom_blog_id' => $network_wpcom_blog_id,
- 'siteurl' => site_url(),
- 'home' => home_url(),
- 'gmt_offset' => $gmt_offset,
- 'timezone_string' => (string) get_option( 'timezone_string' ),
- 'site_name' => (string) get_option( 'blogname' ),
- 'secret_1' => $secrets['secret_1'],
- 'secret_2' => $secrets['secret_2'],
- 'site_lang' => get_locale(),
- 'timeout' => $timeout,
- 'stats_id' => $stat_id, // Is this still required?
- 'user_id' => $user_id,
- 'state' => $user_id,
- '_ui' => $tracks_identity['_ui'],
- '_ut' => $tracks_identity['_ut'],
- 'site_created' => $site_creation_date,
- 'jetpack_version' => JETPACK__VERSION
- ),
- 'headers' => array(
- 'Accept' => 'application/json',
- ),
- 'timeout' => $timeout,
- );
-
- Jetpack::apply_activation_source_to_args( $args['body'] );
-
- // Attempt to retrieve shadow blog details
- $response = Jetpack_Client::_wp_remote_request(
- Jetpack::fix_url_for_bad_hosts( Jetpack::api_url( 'subsiteregister' ) ), $args, true
- );
-
- /*
- * $response should either be invalid or contain:
- * - jetpack_id => id
- * - jetpack_secret => blog_token
- * - jetpack_public
- *
- * Store the wpcom site details
- */
- $valid_response = $jp->validate_remote_register_response( $response );
-
- if ( is_wp_error( $valid_response ) || ! $valid_response ) {
- restore_current_blog();
- return $valid_response;
- }
-
- // Grab the response values to work with
- $code = wp_remote_retrieve_response_code( $response );
- $entity = wp_remote_retrieve_body( $response );
- if ( $entity ) {
- $json = json_decode( $entity );
- } else {
- $json = false;
- }
-
- if ( empty( $json->jetpack_secret ) || ! is_string( $json->jetpack_secret ) ) {
- restore_current_blog();
- return new Jetpack_Error( 'jetpack_secret', '', $code );
- }
-
- if ( isset( $json->jetpack_public ) ) {
- $jetpack_public = (int) $json->jetpack_public;
- } else {
- $jetpack_public = false;
- }
-
- Jetpack_Options::update_options( array(
- 'id' => (int) $json->jetpack_id,
- 'blog_token' => (string) $json->jetpack_secret,
- 'public' => $jetpack_public,
- ) );
-
- /*
- * Update the subsiteregister method on wpcom so that it also sends back the
- * token in this same request
- */
- $is_master_user = ! Jetpack::is_active();
- Jetpack::update_user_token(
- get_current_user_id(),
- sprintf( '%s.%d', $json->token->secret, get_current_user_id() ),
- $is_master_user
+ 'user_id' => get_current_user_id(),
+
+ /*
+ * Use the subsite's registration date as the site creation date.
+ *
+ * This is in contrast to regular standalone sites, where we use the helper
+ * `Jetpack::get_assumed_site_creation_date()` to assume the site's creation date.
+ */
+ 'site_created' => $blog_details->registered,
+ )
);
-
- Jetpack::activate_default_modules();
-
- restore_current_blog();
}
- function wrap_network_admin_page() {
+ /**
+ * A hook handler for adding admin pages and subpages.
+ */
+ public function wrap_network_admin_page() {
Jetpack_Admin_Page::wrap_ui( array( $this, 'network_admin_page' ) );
}
@@ -569,19 +533,19 @@ class Jetpack_Network {
* @since 2.9
* @see Jetpack_Network::jetpack_sites_list()
*/
- function network_admin_page() {
+ public function network_admin_page() {
global $current_site;
$this->network_admin_page_header();
$jp = Jetpack::init();
- // We should be, but ensure we are on the main blog
+ // We should be, but ensure we are on the main blog.
switch_to_blog( $current_site->blog_id );
$main_active = $jp->is_active();
restore_current_blog();
- // If we are in dev mode, just show the notice and bail
- if ( Jetpack::is_development_mode() ) {
+ // If we are in dev mode, just show the notice and bail.
+ if ( ( new Status() )->is_development_mode() ) {
Jetpack::show_development_mode_notice();
return;
}
@@ -591,22 +555,25 @@ class Jetpack_Network {
* connections will feed off this one
*/
if ( ! $main_active ) {
- $url = $this->get_url( array(
- 'name' => 'subsiteregister',
- 'site_id' => 1,
- ) );
+ $url = $this->get_url(
+ array(
+ 'name' => 'subsiteregister',
+ 'site_id' => 1,
+ )
+ );
$data = array( 'url' => $jp->build_connect_url() );
Jetpack::init()->load_view( 'admin/must-connect-main-blog.php', $data );
return;
}
- require_once( 'class.jetpack-network-sites-list-table.php' );
- $myListTable = new Jetpack_Network_Sites_List_Table();
- echo '<div class="wrap"><h2>' . __( 'Sites', 'jetpack' ) . '</h2>';
+ require_once 'class.jetpack-network-sites-list-table.php';
+
+ $network_sites_table = new Jetpack_Network_Sites_List_Table();
+ echo '<div class="wrap"><h2>' . esc_html__( 'Sites', 'jetpack' ) . '</h2>';
echo '<form method="post">';
- $myListTable->prepare_items();
- $myListTable->display();
+ $network_sites_table->prepare_items();
+ $network_sites_table->display();
echo '</form></div>';
}
@@ -616,18 +583,15 @@ class Jetpack_Network {
*
* @since 2.9
*/
- function network_admin_page_header() {
- global $current_user;
-
+ public function network_admin_page_header() {
$is_connected = Jetpack::is_active();
$data = array(
- 'is_connected' => $is_connected
+ 'is_connected' => $is_connected,
);
Jetpack::init()->load_view( 'admin/network-admin-header.php', $data );
}
-
/**
* Fires when the Jetpack > Settings page is saved.
*
@@ -636,7 +600,7 @@ class Jetpack_Network {
public function save_network_settings_page() {
if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'jetpack-network-settings' ) ) {
- // no nonce, push back to settings page
+ // No nonce, push back to settings page.
wp_safe_redirect(
add_query_arg(
array( 'page' => 'jetpack-settings' ),
@@ -646,14 +610,17 @@ class Jetpack_Network {
exit();
}
- // try to save the Protect whitelist before anything else, since that action can result in errors
+ // Try to save the Protect whitelist before anything else, since that action can result in errors.
$whitelist = str_replace( ' ', '', $_POST['global-whitelist'] );
$whitelist = explode( PHP_EOL, $whitelist );
- $result = jetpack_protect_save_whitelist( $whitelist, $global = true );
+ $result = jetpack_protect_save_whitelist( $whitelist, true );
if ( is_wp_error( $result ) ) {
wp_safe_redirect(
add_query_arg(
- array( 'page' => 'jetpack-settings', 'error' => 'jetpack_protect_whitelist' ),
+ array(
+ 'page' => 'jetpack-settings',
+ 'error' => 'jetpack_protect_whitelist',
+ ),
network_admin_url( 'admin.php' )
)
);
@@ -676,44 +643,39 @@ class Jetpack_Network {
$sub_site_connection_override = 1;
}
- /* Remove the toggles for 2.9, re-evaluate how they're done and added for a 3.0 release. They don't feel quite right yet.
- $manage_auto_activated_modules = 0;
- if ( isset( $_POST['manage_auto_activated_modules'] ) ) {
- $manage_auto_activated_modules = 1;
- }
-
- $modules = array();
- if ( isset( $_POST['modules'] ) ) {
- $modules = $_POST['modules'];
- }
- */
-
$data = array(
- 'auto-connect' => $auto_connect,
- 'sub-site-connection-override' => $sub_site_connection_override,
- //'manage_auto_activated_modules' => $manage_auto_activated_modules,
- //'modules' => $modules,
+ 'auto-connect' => $auto_connect,
+ 'sub-site-connection-override' => $sub_site_connection_override,
);
update_site_option( $this->settings_name, $data );
wp_safe_redirect(
add_query_arg(
- array( 'page' => 'jetpack-settings', 'updated' => 'true' ),
+ array(
+ 'page' => 'jetpack-settings',
+ 'updated' => 'true',
+ ),
network_admin_url( 'admin.php' )
)
);
exit();
}
+ /**
+ * A hook handler for adding admin pages and subpages.
+ */
public function wrap_render_network_admin_settings_page() {
Jetpack_Admin_Page::wrap_ui( array( $this, 'render_network_admin_settings_page' ) );
}
+ /**
+ * A hook rendering the admin settings page.
+ */
public function render_network_admin_settings_page() {
$this->network_admin_page_header();
$options = wp_parse_args( get_site_option( $this->settings_name ), $this->setting_defaults );
- $modules = array();
+ $modules = array();
$module_slugs = Jetpack::get_available_modules();
foreach ( $module_slugs as $slug ) {
$module = Jetpack::get_module( $slug );
@@ -728,8 +690,8 @@ class Jetpack_Network {
}
$data = array(
- 'modules' => $modules,
- 'options' => $options,
+ 'modules' => $modules,
+ 'options' => $options,
'jetpack_protect_whitelist' => jetpack_protect_format_whitelist(),
);
@@ -741,13 +703,13 @@ class Jetpack_Network {
*
* @since 2.9
*
- * @param string $key
- * @param mixed $value
+ * @param string $key option name.
+ * @param mixed $value option value.
*
* @return boolean
**/
public function update_option( $key, $value ) {
- $options = get_site_option( $this->settings_name, $this->setting_defaults );
+ $options = get_site_option( $this->settings_name, $this->setting_defaults );
$options[ $key ] = $value;
return update_site_option( $this->settings_name, $options );
@@ -758,7 +720,7 @@ class Jetpack_Network {
*
* @since 2.9
*
- * @param string $name - Name of the option in the database
+ * @param string $name - Name of the option in the database.
**/
public function get_option( $name ) {
$options = get_site_option( $this->settings_name, $this->setting_defaults );
@@ -770,7 +732,4 @@ class Jetpack_Network {
return $options[ $name ];
}
-
}
-
-// end class