summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
committerAnthony G. Basile <blueness@gentoo.org>2020-01-06 14:32:30 -0500
commit10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch)
treeb4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
parentUpdating script for Update (diff)
downloadblogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2
blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php')
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php100
1 files changed, 39 insertions, 61 deletions
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
index e5a423f0..9d3ce44c 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
@@ -1,4 +1,6 @@
<?php
+use Automattic\Jetpack\Status;
+
include_once( 'class.jetpack-admin-page.php' );
// Builds the landing page and its menu
@@ -51,7 +53,7 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
* @since 4.3.0
*/
function jetpack_add_dashboard_sub_nav_item() {
- if ( Jetpack::is_development_mode() || Jetpack::is_active() ) {
+ if ( ( new Status() )->is_development_mode() || Jetpack::is_active() ) {
global $submenu;
if ( current_user_can( 'jetpack_admin_page' ) ) {
$submenu['jetpack'][] = array( __( 'Dashboard', 'jetpack' ), 'jetpack_admin_page', 'admin.php?page=jetpack#/dashboard' );
@@ -65,7 +67,7 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
* @since 4.3.0
*/
function jetpack_add_settings_sub_nav_item() {
- if ( ( Jetpack::is_development_mode() || Jetpack::is_active() ) && current_user_can( 'jetpack_admin_page' ) && current_user_can( 'edit_posts' ) ) {
+ if ( ( ( new Status() )->is_development_mode() || Jetpack::is_active() ) && current_user_can( 'jetpack_admin_page' ) && current_user_can( 'edit_posts' ) ) {
global $submenu;
$submenu['jetpack'][] = array( __( 'Settings', 'jetpack' ), 'jetpack_admin_page', 'admin.php?page=jetpack#/settings' );
}
@@ -113,6 +115,8 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
// We got the static.html so let's display it
echo $static_html;
+ self::render_footer();
+
}
}
@@ -144,21 +148,26 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
return; // No need for scripts on a fallback page
}
- $script_deps_path = JETPACK__PLUGIN_DIR . '_inc/build/admin.deps.json';
- $script_dependencies = file_exists( $script_deps_path )
- ? json_decode( file_get_contents( $script_deps_path ) )
- : array();
- $script_dependencies[] = 'wp-polyfill';
-
- wp_enqueue_script(
- 'react-plugin',
- plugins_url( '_inc/build/admin.js', JETPACK__PLUGIN_FILE ),
- $script_dependencies,
- JETPACK__VERSION,
- true
- );
+ $is_development_mode = ( new Status() )->is_development_mode();
+ $script_deps_path = JETPACK__PLUGIN_DIR . '_inc/build/admin.asset.php';
+ $script_dependencies = array( 'wp-polyfill' );
+ if ( file_exists( $script_deps_path ) ) {
+ $asset_manifest = include $script_deps_path;
+ $script_dependencies = $asset_manifest['dependencies'];
+ }
+
+ if ( Jetpack::is_active() || $is_development_mode ) {
+ wp_enqueue_script(
+ 'react-plugin',
+ plugins_url( '_inc/build/admin.js', JETPACK__PLUGIN_FILE ),
+ $script_dependencies,
+ JETPACK__VERSION,
+ true
+ );
+ }
+
- if ( ! Jetpack::is_development_mode() && Jetpack::is_active() ) {
+ if ( ! $is_development_mode && Jetpack::is_active() ) {
// Required for Analytics.
wp_enqueue_script( 'jp-tracks', '//stats.wp.com/w.js', array(), gmdate( 'YW' ), true );
}
@@ -219,6 +228,8 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
require_once JETPACK__PLUGIN_DIR . 'class.jetpack-affiliate.php';
}
+ $current_user_data = jetpack_current_user_data();
+
return array(
'WP_API_root' => esc_url_raw( rest_url() ),
'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
@@ -227,7 +238,7 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
'isActive' => Jetpack::is_active(),
'isStaging' => Jetpack::is_staging_site(),
'devMode' => array(
- 'isActive' => Jetpack::is_development_mode(),
+ 'isActive' => ( new Status() )->is_development_mode(),
'constant' => defined( 'JETPACK_DEV_DEBUG' ) && JETPACK_DEV_DEBUG,
'url' => site_url() && false === strpos( site_url(), '.' ),
'filter' => apply_filters( 'jetpack_development_mode', false ),
@@ -236,13 +247,12 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option(),
'sandboxDomain' => JETPACK__SANDBOX_DOMAIN,
),
- 'connectUrl' => Jetpack::init()->build_connect_url( true, false, false ),
+ 'connectUrl' => $current_user_data['isConnected'] == false ? Jetpack::init()->build_connect_url( true, false, false ) : '',
'dismissedNotices' => $this->get_dismissed_jetpack_notices(),
'isDevVersion' => Jetpack::is_development_version(),
'currentVersion' => JETPACK__VERSION,
'is_gutenberg_available' => true,
'getModules' => $modules,
- 'showJumpstart' => jetpack_show_jumpstart(),
'rawUrl' => Jetpack::build_raw_urls( get_home_url() ),
'adminUrl' => esc_url( admin_url() ),
'stats' => array(
@@ -259,13 +269,13 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
'settings' => $this->get_flattened_settings( $modules ),
'userData' => array(
// 'othersLinked' => Jetpack::get_other_linked_admins(),
- 'currentUser' => jetpack_current_user_data(),
+ 'currentUser' => $current_user_data,
),
'siteData' => array(
- 'icon' => has_site_icon()
+ 'icon' => has_site_icon()
? apply_filters( 'jetpack_photon_url', get_site_icon_url(), array( 'w' => 64 ) )
: '',
- 'siteVisibleToSearchEngines' => '1' == get_option( 'blog_public' ),
+ 'siteVisibleToSearchEngines' => '1' == get_option( 'blog_public' ), // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
/**
* Whether promotions are visible or not.
*
@@ -273,10 +283,11 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
*
* @param bool $are_promotions_active Status of promotions visibility. True by default.
*/
- 'showPromotions' => apply_filters( 'jetpack_show_promotions', true ),
- 'isAtomicSite' => jetpack_is_atomic_site(),
- 'plan' => Jetpack_Plan::get(),
- 'showBackups' => Jetpack::show_backups_ui(),
+ 'showPromotions' => apply_filters( 'jetpack_show_promotions', true ),
+ 'isAtomicSite' => jetpack_is_atomic_site(),
+ 'plan' => Jetpack_Plan::get(),
+ 'showBackups' => Jetpack::show_backups_ui(),
+ 'isMultisite' => is_multisite(),
),
'themeData' => array(
'name' => $current_theme->get( 'Name' ),
@@ -295,7 +306,8 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
'currentIp' => function_exists( 'jetpack_protect_get_ip' ) ? jetpack_protect_get_ip() : false,
'lastPostUrl' => esc_url( $last_post ),
- 'externalServicesConnectUrls' => $this->get_external_services_connect_urls()
+ 'externalServicesConnectUrls' => $this->get_external_services_connect_urls(),
+ 'calypsoEnv' => Jetpack::get_calypso_env(),
);
}
@@ -322,40 +334,6 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
}
}
-/*
- * Only show Jump Start on first activation.
- * Any option 'jumpstart' other than 'new connection' will hide it.
- *
- * The option can be of 4 things, and will be stored as such:
- * new_connection : Brand new connection - Show
- * jumpstart_activated : Jump Start has been activated - dismiss
- * jumpstart_dismissed : Manual dismissal of Jump Start - dismiss
- * jetpack_action_taken: Deprecated since 7.3 But still listed here to respect behaviour for old versions.
- * Manual activation of a module already happened - dismiss.
- *
- * @todo move to functions.global.php when available
- * @since 3.6
- * @return bool | show or hide
- */
-function jetpack_show_jumpstart() {
- if ( ! Jetpack::is_active() ) {
- return false;
- }
- $jumpstart_option = Jetpack_Options::get_option( 'jumpstart' );
-
- $hide_options = array(
- 'jumpstart_activated',
- 'jetpack_action_taken',
- 'jumpstart_dismissed'
- );
-
- if ( ! $jumpstart_option || in_array( $jumpstart_option, $hide_options ) ) {
- return false;
- }
-
- return true;
-}
-
/**
* Gather data about the current user.
*