PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-connection/src/class-initial-state.php +15 -40 16.3 → 16.3-a.1 View file →
@@ -21,11 +21,9 @@
21 21 */
22 22 private static function get_data() {
23 23 global $wp_version;
24 24
25 - $status = new Status();
26 - $manager = new Manager();
27 - $can_manage_connection = current_user_can( 'jetpack_connect' );
25 + $status = new Status();
28 26
29 27 // Only expose the owner's identity to users who can act on connection issues:
30 28 // this state is printed for any logged-in user loading connection scripts
31 29 // (e.g. contributors in the editor). The owner is derived from the master_user
@@ -35,9 +33,9 @@
35 33 // invalid_connection_owner as a side effect). Unlike
36 34 // userConnectionData.connectionOwner (the *connected* owner), this field
37 35 // identifies who holds ownership regardless of token health.
38 36 $connection_owner = null;
39 - if ( $can_manage_connection ) {
37 + if ( current_user_can( 'jetpack_connect' ) ) {
40 38 $owner_id = (int) \Jetpack_Options::get_option( 'master_user' );
41 39 $owner = $owner_id > 0 ? get_userdata( $owner_id ) : false;
42 40
43 41 if ( $owner instanceof \WP_User ) {
@@ -47,45 +45,22 @@
47 45 );
48 46 }
49 47 }
50 48
51 - // Behind the same gate: on an anchored site, resolving the owner can cost a WordPress.com lookup.
52 - $has_protected_owner = null;
53 - $requires_protected_owner = null;
54 - $use_default_protected_owner_ui = null;
55 - if ( $can_manage_connection ) {
56 - $has_protected_owner = $manager->has_protected_owner();
57 - $requires_protected_owner = $manager->requires_protected_owner();
58 -
59 - /**
60 - * Filters whether the connection package renders its default protected owner UI.
61 - *
62 - * Return `false` from a consumer that renders its own confirmation flow.
63 - *
64 - * @since 9.7.0
65 - *
66 - * @param bool $use_default_ui Whether to render the default UI. Default true.
67 - */
68 - $use_default_protected_owner_ui = (bool) apply_filters( 'jetpack_connection_protected_owner_default_ui', true );
69 - }
70 -
71 49 return array(
72 - 'apiRoot' => esc_url_raw( rest_url() ),
73 - 'apiNonce' => wp_create_nonce( 'wp_rest' ),
74 - 'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ),
75 - 'connectionStatus' => REST_Connector::connection_status( false ),
76 - 'userConnectionData' => REST_Connector::get_user_connection_data( false ),
77 - 'connectedPlugins' => REST_Connector::get_connection_plugins( false ),
78 - 'wpVersion' => $wp_version,
79 - 'siteSuffix' => $status->get_site_suffix(),
80 - 'connectionErrors' => Error_Handler::get_instance()->get_displayable_errors(),
81 - 'isOfflineMode' => $status->is_offline_mode(),
82 - 'calypsoEnv' => ( new Status\Host() )->get_calypso_env(),
83 - 'isOwnershipTransferable' => $manager->is_ownership_transferable(),
84 - 'connectionOwner' => $connection_owner,
85 - 'hasProtectedOwner' => $has_protected_owner,
86 - 'requiresProtectedOwner' => $requires_protected_owner,
87 - 'useDefaultProtectedOwnerUi' => $use_default_protected_owner_ui,
50 + 'apiRoot' => esc_url_raw( rest_url() ),
51 + 'apiNonce' => wp_create_nonce( 'wp_rest' ),
52 + 'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ),
53 + 'connectionStatus' => REST_Connector::connection_status( false ),
54 + 'userConnectionData' => REST_Connector::get_user_connection_data( false ),
55 + 'connectedPlugins' => REST_Connector::get_connection_plugins( false ),
56 + 'wpVersion' => $wp_version,
57 + 'siteSuffix' => $status->get_site_suffix(),
58 + 'connectionErrors' => Error_Handler::get_instance()->get_displayable_errors(),
59 + 'isOfflineMode' => $status->is_offline_mode(),
60 + 'calypsoEnv' => ( new Status\Host() )->get_calypso_env(),
61 + 'isOwnershipTransferable' => ( new Manager() )->is_ownership_transferable(),
62 + 'connectionOwner' => $connection_owner,
88 63 );
89 64 }
90 65
91 66 /**