PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
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 13.7.2 All 507 releases
← All changes | _inc/lib/admin-pages/class-jetpack-redux-state-helper.php +25 -18 16.2-beta → 16.3-beta View file →
@@ -6,9 +6,10 @@
6 6 * @package automattic/jetpack
7 7 */
8 8
9 9 use Automattic\Jetpack\Blaze;
10 -use Automattic\Jetpack\Boost_Speed_Score\Speed_Score_History;
10 +use Automattic\Jetpack\Comments\Block_Editor;
11 +use Automattic\Jetpack\Comments\Comments;
11 12 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
12 13 use Automattic\Jetpack\Connection\Plugin_Storage as Connection_Plugin_Storage;
13 14 use Automattic\Jetpack\Connection\REST_Connector;
14 15 use Automattic\Jetpack\Constants;
@@ -18,11 +19,9 @@
18 19 use Automattic\Jetpack\IP\Utils as IP_Utils;
19 20 use Automattic\Jetpack\Licensing;
20 21 use Automattic\Jetpack\Licensing\Endpoints as Licensing_Endpoints;
21 22 use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer;
22 -use Automattic\Jetpack\My_Jetpack\Jetpack_Manage;
23 23 use Automattic\Jetpack\Partner;
24 -use Automattic\Jetpack\Partner_Coupon as Jetpack_Partner_Coupon;
25 24 use Automattic\Jetpack\Publicize\Keyring_Helper;
26 25 use Automattic\Jetpack\Stats\Options as Stats_Options;
27 26 use Automattic\Jetpack\Status;
28 27 use Automattic\Jetpack\Status\Host;
@@ -43,8 +42,29 @@
43 42 );
44 43 }
45 44
46 45 /**
46 + * Generate the state for the plugins page: the minimal state plus what the deactivation survey needs.
47 + *
48 + * @since 16.3
49 + *
50 + * @return array
51 + */
52 + public static function get_plugins_page_state() {
53 + $state = self::get_minimal_state();
54 +
55 + $connection = new Connection_Manager();
56 +
57 + $state['pluginDeactivation'] = array(
58 + 'siteId' => (int) Jetpack_Options::get_option( 'id' ),
59 + 'hasConnectedUser' => $connection->has_connected_user(),
60 + 'isCurrentUserConnected' => $connection->is_user_connected(),
61 + );
62 +
63 + return $state;
64 + }
65 +
66 + /**
47 67 * Generate the initial state array to be used by the Redux store.
48 68 */
49 69 public static function get_initial_state() {
50 70 global $is_safari;
@@ -126,10 +146,8 @@
126 146 );
127 147
128 148 $connection_status = array_merge( REST_Connector::connection_status( false ), $connection_status );
129 149
130 - $speed_score_history = new Speed_Score_History( wp_parse_url( get_site_url(), PHP_URL_HOST ) );
131 -
132 150 $block_availability = Jetpack_Gutenberg::get_cached_availability();
133 151
134 152 return array(
135 153 'WP_API_root' => esc_url_raw( rest_url() ),
@@ -135,9 +153,8 @@
135 153 'WP_API_root' => esc_url_raw( rest_url() ),
136 154 'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
137 155 'registrationNonce' => '', // Not used, keeping it for compatibility reasons, see https://github.com/Automattic/jetpack/pull/42076
138 156 'purchaseToken' => self::get_purchase_token(),
139 - 'partnerCoupon' => Jetpack_Partner_Coupon::get_coupon(),
140 157 'pluginBaseUrl' => plugins_url( '', JETPACK__PLUGIN_FILE ),
141 158 'connectionStatus' => $connection_status,
142 159 'connectedPlugins' => Connection_Plugin_Storage::get_all(),
143 160 'connectUrl' => false == $current_user_data['isConnected'] // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
@@ -184,18 +201,18 @@
184 201 'showPromotions' => apply_filters( 'jetpack_show_promotions', true ),
185 202 'plan' => Jetpack_Plan::get(),
186 203 'showBackups' => Jetpack::show_backups_ui(),
187 204 'showScan' => Jetpack::show_scan_ui(),
188 - 'showRecommendations' => Jetpack_Recommendations::is_enabled(),
189 205 /** This filter is documented in my-jetpack/src/class-initializer.php */
190 206 'showMyJetpack' => My_Jetpack_Initializer::should_initialize(),
191 207 'isMultisite' => is_multisite(),
192 208 'dateFormat' => get_option( 'date_format' ),
193 - 'latestBoostSpeedScores' => $speed_score_history->latest(),
194 209 'isSharingBlockAvailable' => isset( $block_availability['sharing-buttons'] )
195 210 && $block_availability['sharing-buttons']['available'],
196 211 'isLikeBlockAvailable' => isset( $block_availability['like'] )
197 212 && $block_availability['like']['available'],
213 + // The rebuilt comment form is what offers blocks; the package may lag this file on a staged deploy.
214 + 'isCommentBlocksAvailable' => class_exists( Block_Editor::class ) && Comments::is_enabled(),
198 215 ),
199 216 'themeData' => array(
200 217 'name' => $current_theme->get( 'Name' ),
201 218 'stylesheet' => $current_theme->get_stylesheet(),
@@ -217,10 +234,8 @@
217 234 'currentIp' => IP_Utils::get_ip(),
218 235 'lastPostUrl' => esc_url( $last_post ),
219 236 'externalServicesConnectUrls' => self::get_external_services_connect_urls(),
220 237 'calypsoEnv' => ( new Host() )->get_calypso_env(),
221 - 'products' => Jetpack::get_products_for_purchase(),
222 - 'recommendationsStep' => Jetpack_Core_Json_Api_Endpoints::get_recommendations_step()['step'],
223 238 'isSafari' => $is_safari || User_Agent_Info::is_opera_desktop(), // @todo Rename isSafari everywhere.
224 239 'doNotUseConnectionIframe' => Constants::is_true( 'JETPACK_SHOULD_NOT_USE_CONNECTION_IFRAME' ),
225 240 'licensing' => array(
226 241 'error' => Licensing::instance()->last_error(),
@@ -227,16 +242,8 @@
227 242 'showLicensingUi' => Licensing::instance()->is_licensing_input_enabled(),
228 243 'userCounts' => Licensing_Endpoints::get_user_license_counts(),
229 244 'activationNoticeDismiss' => Licensing::instance()->get_license_activation_notice_dismiss(),
230 245 ),
231 - 'jetpackManage' => array(
232 - 'isEnabled' => Jetpack_Manage::could_use_jp_manage(),
233 - 'isAgencyAccount' => Jetpack_Manage::is_agency_account(),
234 - ),
235 - 'hasSeenWCConnectionModal' => Jetpack_Options::get_option( 'has_seen_wc_connection_modal', false ),
236 - 'newRecommendations' => Jetpack_Recommendations::get_new_conditional_recommendations(),
237 - // Check if WooCommerce plugin is active (based on https://docs.woocommerce.com/document/create-a-plugin/).
238 - 'isWooCommerceActive' => in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', Jetpack::get_active_plugins() ), true ),
239 246 'useMyJetpackLicensingUI' => My_Jetpack_Initializer::is_licensing_ui_enabled(),
240 247 'isOdysseyStatsEnabled' => Stats_Options::get_option( 'enable_odyssey_stats' ),
241 248 'shouldInitializeBlaze' => Blaze::should_initialize(),
242 249 'isBlazeDashboardEnabled' => Blaze::is_dashboard_enabled(),