diff options
Diffstat (limited to 'plugins/jetpack/class.jetpack-network.php')
-rw-r--r-- | plugins/jetpack/class.jetpack-network.php | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/plugins/jetpack/class.jetpack-network.php b/plugins/jetpack/class.jetpack-network.php index 00218ed1..026ee1c7 100644 --- a/plugins/jetpack/class.jetpack-network.php +++ b/plugins/jetpack/class.jetpack-network.php @@ -2,13 +2,11 @@ /** * Jetpack Network Manager class file. * - * @package jetpack + * @package automattic/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\Connection\Tokens; use Automattic\Jetpack\Status; /** @@ -85,6 +83,7 @@ class Jetpack_Network { */ if ( is_multisite() && is_plugin_active_for_network( 'jetpack/jetpack.php' ) ) { add_action( 'wp_before_admin_bar_render', array( $this, 'add_to_menubar' ) ); + add_filter( 'jetpack_disconnect_cap', array( $this, 'set_multisite_disconnect_cap' ) ); /* * If admin wants to automagically register new sites set the hook here @@ -107,19 +106,6 @@ class Jetpack_Network { } /** - * Sets which modules get activated by default on subsite connection. - * Modules can be set in Network Admin > Jetpack > Settings - * - * @since 2.9 - * @deprecated since 7.7.0 - * - * @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 @@ -203,9 +189,11 @@ class Jetpack_Network { */ if ( ! in_array( 'jetpack/jetpack.php', $active_plugins, true ) ) { Jetpack::disconnect(); + Jetpack_Options::delete_option( 'version' ); } + restore_current_blog(); } - restore_current_blog(); + } /** @@ -385,6 +373,26 @@ class Jetpack_Network { } /** + * Set the disconnect capability for multisite. + * + * @param array $caps The capabilities array. + */ + public function set_multisite_disconnect_cap( $caps ) { + // Can individual site admins manage their own connection? + if ( ! is_super_admin() && ! $this->get_option( 'sub-site-connection-override' ) ) { + /* + * We need to update the option name -- it's terribly unclear which + * direction the override goes. + * + * @todo: Update the option name to `sub-sites-can-manage-own-connections` + */ + return array( 'do_not_allow' ); + } + + return $caps; + } + + /** * Shows the Jetpack plugin notices. */ public function show_jetpack_notice() { @@ -434,7 +442,7 @@ class Jetpack_Network { return; } - if ( ( new Status() )->is_development_mode() ) { + if ( ( new Status() )->is_offline_mode() ) { return; } @@ -471,19 +479,19 @@ class Jetpack_Network { * @param Object $token the received token. */ public function filter_register_user_token( $token ) { - $is_master_user = ! Jetpack::is_active(); - Connection_Utils::update_user_token( + $is_connection_owner = ! $this->connection->has_connected_owner(); + ( new Tokens() )->update_user_token( get_current_user_id(), sprintf( '%s.%d', $token->secret, get_current_user_id() ), - $is_master_user + $is_connection_owner ); } /** * Filters the registration request body to include additional properties. * - * @param Array $properties standard register request body properties. - * @return Array amended 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(); @@ -541,11 +549,11 @@ class Jetpack_Network { // We should be, but ensure we are on the main blog. switch_to_blog( $current_site->blog_id ); - $main_active = $jp->is_active(); + $main_active = $jp->is_connection_ready(); restore_current_blog(); // If we are in dev mode, just show the notice and bail. - if ( ( new Status() )->is_development_mode() ) { + if ( ( new Status() )->is_offline_mode() ) { Jetpack::show_development_mode_notice(); return; } @@ -584,7 +592,7 @@ class Jetpack_Network { * @since 2.9 */ public function network_admin_page_header() { - $is_connected = Jetpack::is_active(); + $is_connected = Jetpack::is_connection_ready(); $data = array( 'is_connected' => $is_connected, |