summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php')
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php109
1 files changed, 68 insertions, 41 deletions
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
index bca7521d..86887667 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
@@ -1,5 +1,7 @@
<?php
+use Automattic\Jetpack\Identity_Crisis;
+use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;
// Shared logic between Jetpack admin pages
@@ -46,29 +48,32 @@ abstract class Jetpack_Admin_Page {
$this->jetpack = $jetpack;
self::$block_page_rendering_for_idc = (
- Jetpack::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' )
+ Identity_Crisis::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' )
);
}
function add_actions() {
- global $pagenow;
+ $is_offline_mode = ( new Status() )->is_offline_mode();
- $is_development_mode = ( new Status() )->is_development_mode();
- // If user is not an admin and site is in Dev Mode or not connected yet then don't do anything.
- if ( ! current_user_can( 'manage_options' ) && ( $is_development_mode || ! Jetpack::is_active() ) ) {
+ // If user is not an admin and site is in Offline Mode or not connected yet then don't do anything.
+ if ( ! current_user_can( 'manage_options' ) && ( $is_offline_mode || ! Jetpack::is_connection_ready() ) ) {
return;
}
+ // Is Jetpack not connected and not offline?
+ // True means that Jetpack is NOT connected and NOT in offline mode.
+ // If Jetpack is connected OR in offline mode, this will be false.
+ $connectable = ! Jetpack::is_connection_ready() && ! $is_offline_mode;
+
// Don't add in the modules page unless modules are available!
- if ( $this->dont_show_if_not_active && ! Jetpack::is_active() && ! $is_development_mode ) {
+ if ( $this->dont_show_if_not_active && $connectable ) {
return;
}
// Initialize menu item for the page in the admin
$hook = $this->get_page_hook();
- // Attach hooks common to all Jetpack admin pages based on the created
- // hook
+ // Attach hooks common to all Jetpack admin pages based on the created hook.
add_action( "load-$hook", array( $this, 'admin_help' ) );
add_action( "load-$hook", array( $this, 'admin_page_load' ) );
add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) );
@@ -77,13 +82,26 @@ abstract class Jetpack_Admin_Page {
if ( ! self::$block_page_rendering_for_idc ) {
add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) );
}
+
+ // Check if the site plan changed and deactivate modules accordingly.
+ add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) );
+
+ // Attach page specific actions in addition to the above.
+ $this->add_page_actions( $hook );
+
+ // If the current user can connect Jetpack, Jetpack isn't connected, and is not in offline mode, let's prompt!
+ if ( current_user_can( 'jetpack_connect' ) && $connectable ) {
+ $this->add_connection_banner_actions();
+ }
+ }
+
+ /**
+ * Hooks to add when Jetpack is not active or in offline mode for an user capable of connecting.
+ */
+ private function add_connection_banner_actions() {
+ global $pagenow;
// If someone just activated Jetpack, let's show them a fullscreen connection banner.
- if (
- ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] )
- && ! Jetpack::is_active()
- && current_user_can( 'jetpack_connect' )
- && ! $is_development_mode
- ) {
+ if ( ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_banner_scripts' ) );
add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_connect_button_scripts' ) );
add_action( 'admin_print_styles', array( Jetpack::init(), 'admin_banner_styles' ) );
@@ -92,20 +110,10 @@ abstract class Jetpack_Admin_Page {
}
// If Jetpack not yet connected, but user is viewing one of the pages with a Jetpack connection banner.
- if (
- ( 'index.php' === $pagenow || 'plugins.php' === $pagenow )
- && ! Jetpack::is_active()
- && current_user_can( 'jetpack_connect' )
- && ! $is_development_mode
- ) {
+ if ( ( 'index.php' === $pagenow || 'plugins.php' === $pagenow ) ) {
add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_connect_button_scripts' ) );
}
- // Check if the site plan changed and deactivate modules accordingly.
- add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) );
-
- // Attach page specific actions in addition to the above
- $this->add_page_actions( $hook );
}
// Render the page with a common top and bottom part, and page specific content
@@ -158,8 +166,6 @@ abstract class Jetpack_Admin_Page {
return /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
apply_filters( 'rest_enabled', true ) &&
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
- apply_filters( 'rest_jsonp_enabled', true ) &&
- /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
apply_filters( 'rest_authentication_errors', true );
}
@@ -174,7 +180,7 @@ abstract class Jetpack_Admin_Page {
*/
function check_plan_deactivate_modules( $page ) {
if (
- ( new Status() )->is_development_mode()
+ ( new Status() )->is_offline_mode()
|| ! in_array(
$page->base,
array(
@@ -196,15 +202,13 @@ abstract class Jetpack_Admin_Page {
$active = Jetpack::get_active_modules();
switch ( $current['product_slug'] ) {
case 'jetpack_free':
- $to_deactivate = array( 'seo-tools', 'videopress', 'google-analytics', 'wordads', 'search' );
- break;
case 'jetpack_personal':
case 'jetpack_personal_monthly':
- $to_deactivate = array( 'seo-tools', 'videopress', 'google-analytics', 'wordads', 'search' );
+ $to_deactivate = array( 'google-analytics', 'wordads', 'search' );
break;
case 'jetpack_premium':
case 'jetpack_premium_monthly':
- $to_deactivate = array( 'seo-tools', 'google-analytics', 'search' );
+ $to_deactivate = array( 'google-analytics', 'search' );
break;
}
$to_deactivate = array_intersect( $active, $to_deactivate );
@@ -230,7 +234,7 @@ abstract class Jetpack_Admin_Page {
static function load_wrapper_styles() {
$rtl = is_rtl() ? '.rtl' : '';
wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/admin{$rtl}.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
- wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min{$rtl}.css", JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
+ wp_enqueue_style( 'components-css', plugins_url( "_inc/build/style.min{$rtl}.css", JETPACK__PLUGIN_FILE ), array( 'wp-components' ), JETPACK__VERSION );
$custom_css = '
#wpcontent {
padding-left: 0 !important;
@@ -239,6 +243,12 @@ abstract class Jetpack_Admin_Page {
background-color: #f6f6f6;
}
+ @media (max-width: 782px) {
+ #wpbody-content {
+ padding-bottom: 50px;
+ }
+ }
+
#jp-plugin-container .wrap {
margin: 0 auto;
max-width:45rem;
@@ -275,13 +285,14 @@ abstract class Jetpack_Admin_Page {
);
$args = wp_parse_args( $args, $defaults );
$jetpack_admin_url = admin_url( 'admin.php?page=jetpack' );
- $jetpack_about_url = ( Jetpack::is_active() || Jetpack::is_development_mode() )
+ $jetpack_offline = ( new Status() )->is_offline_mode();
+ $jetpack_about_url = ( Jetpack::is_connection_ready() || $jetpack_offline )
? admin_url( 'admin.php?page=jetpack_about' )
- : 'https://jetpack.com';
+ : Redirect::get_url( 'jetpack' );
- $jetpack_privacy_url = ( Jetpack::is_active() || Jetpack::is_development_mode() )
+ $jetpack_privacy_url = ( Jetpack::is_connection_ready() || $jetpack_offline )
? $jetpack_admin_url . '#/privacy'
- : 'https://automattic.com/privacy/';
+ : Redirect::get_url( 'a8c-privacy' );
?>
<div id="jp-plugin-container" class="
@@ -295,7 +306,7 @@ abstract class Jetpack_Admin_Page {
<div class="jp-masthead__inside-container">
<div class="jp-masthead__logo-container">
<a class="jp-masthead__logo-link" href="<?php echo esc_url( $jetpack_admin_url ); ?>">
- <svg class="jetpack-logo__masthead" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="32" viewBox="0 0 118 32"><path fill="#00BE28" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"></path><path d="M41.3,26.6c-0.5-0.7-0.9-1.4-1.3-2.1c2.3-1.4,3-2.5,3-4.6V8h-3V6h6v13.4C46,22.8,45,24.8,41.3,26.6z"></path><path d="M65,18.4c0,1.1,0.8,1.3,1.4,1.3c0.5,0,2-0.2,2.6-0.4v2.1c-0.9,0.3-2.5,0.5-3.7,0.5c-1.5,0-3.2-0.5-3.2-3.1V12H60v-2h2.1V7.1 H65V10h4v2h-4V18.4z"></path><path d="M71,10h3v1.3c1.1-0.8,1.9-1.3,3.3-1.3c2.5,0,4.5,1.8,4.5,5.6s-2.2,6.3-5.8,6.3c-0.9,0-1.3-0.1-2-0.3V28h-3V10z M76.5,12.3 c-0.8,0-1.6,0.4-2.5,1.2v5.9c0.6,0.1,0.9,0.2,1.8,0.2c2,0,3.2-1.3,3.2-3.9C79,13.4,78.1,12.3,76.5,12.3z"></path><path d="M93,22h-3v-1.5c-0.9,0.7-1.9,1.5-3.5,1.5c-1.5,0-3.1-1.1-3.1-3.2c0-2.9,2.5-3.4,4.2-3.7l2.4-0.3v-0.3c0-1.5-0.5-2.3-2-2.3 c-0.7,0-2.3,0.5-3.7,1.1L84,11c1.2-0.4,3-1,4.4-1c2.7,0,4.6,1.4,4.6,4.7L93,22z M90,16.4l-2.2,0.4c-0.7,0.1-1.4,0.5-1.4,1.6 c0,0.9,0.5,1.4,1.3,1.4s1.5-0.5,2.3-1V16.4z"></path><path d="M104.5,21.3c-1.1,0.4-2.2,0.6-3.5,0.6c-4.2,0-5.9-2.4-5.9-5.9c0-3.7,2.3-6,6.1-6c1.4,0,2.3,0.2,3.2,0.5V13 c-0.8-0.3-2-0.6-3.2-0.6c-1.7,0-3.2,0.9-3.2,3.6c0,2.9,1.5,3.8,3.3,3.8c0.9,0,1.9-0.2,3.2-0.7V21.3z"></path><path d="M110,15.2c0.2-0.3,0.2-0.8,3.8-5.2h3.7l-4.6,5.7l5,6.3h-3.7l-4.2-5.8V22h-3V6h3V15.2z"></path><path d="M58.5,21.3c-1.5,0.5-2.7,0.6-4.2,0.6c-3.6,0-5.8-1.8-5.8-6c0-3.1,1.9-5.9,5.5-5.9s4.9,2.5,4.9,4.9c0,0.8,0,1.5-0.1,2h-7.3 c0.1,2.5,1.5,2.8,3.6,2.8c1.1,0,2.2-0.3,3.4-0.7C58.5,19,58.5,21.3,58.5,21.3z M56,15c0-1.4-0.5-2.9-2-2.9c-1.4,0-2.3,1.3-2.4,2.9 C51.6,15,56,15,56,15z"></path></svg>
+ <svg class="jetpack-logo__masthead" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="32" viewBox="0 0 118 32"><path fill="#069e08" d="M16,0C7.2,0,0,7.2,0,16s7.2,16,16,16s16-7.2,16-16S24.8,0,16,0z M15,19H7l8-16V19z M17,29V13h8L17,29z"></path><path d="M41.3,26.6c-0.5-0.7-0.9-1.4-1.3-2.1c2.3-1.4,3-2.5,3-4.6V8h-3V6h6v13.4C46,22.8,45,24.8,41.3,26.6z"></path><path d="M65,18.4c0,1.1,0.8,1.3,1.4,1.3c0.5,0,2-0.2,2.6-0.4v2.1c-0.9,0.3-2.5,0.5-3.7,0.5c-1.5,0-3.2-0.5-3.2-3.1V12H60v-2h2.1V7.1 H65V10h4v2h-4V18.4z"></path><path d="M71,10h3v1.3c1.1-0.8,1.9-1.3,3.3-1.3c2.5,0,4.5,1.8,4.5,5.6s-2.2,6.3-5.8,6.3c-0.9,0-1.3-0.1-2-0.3V28h-3V10z M76.5,12.3 c-0.8,0-1.6,0.4-2.5,1.2v5.9c0.6,0.1,0.9,0.2,1.8,0.2c2,0,3.2-1.3,3.2-3.9C79,13.4,78.1,12.3,76.5,12.3z"></path><path d="M93,22h-3v-1.5c-0.9,0.7-1.9,1.5-3.5,1.5c-1.5,0-3.1-1.1-3.1-3.2c0-2.9,2.5-3.4,4.2-3.7l2.4-0.3v-0.3c0-1.5-0.5-2.3-2-2.3 c-0.7,0-2.3,0.5-3.7,1.1L84,11c1.2-0.4,3-1,4.4-1c2.7,0,4.6,1.4,4.6,4.7L93,22z M90,16.4l-2.2,0.4c-0.7,0.1-1.4,0.5-1.4,1.6 c0,0.9,0.5,1.4,1.3,1.4s1.5-0.5,2.3-1V16.4z"></path><path d="M104.5,21.3c-1.1,0.4-2.2,0.6-3.5,0.6c-4.2,0-5.9-2.4-5.9-5.9c0-3.7,2.3-6,6.1-6c1.4,0,2.3,0.2,3.2,0.5V13 c-0.8-0.3-2-0.6-3.2-0.6c-1.7,0-3.2,0.9-3.2,3.6c0,2.9,1.5,3.8,3.3,3.8c0.9,0,1.9-0.2,3.2-0.7V21.3z"></path><path d="M110,15.2c0.2-0.3,0.2-0.8,3.8-5.2h3.7l-4.6,5.7l5,6.3h-3.7l-4.2-5.8V22h-3V6h3V15.2z"></path><path d="M58.5,21.3c-1.5,0.5-2.7,0.6-4.2,0.6c-3.6,0-5.8-1.8-5.8-6c0-3.1,1.9-5.9,5.5-5.9s4.9,2.5,4.9,4.9c0,0.8,0,1.5-0.1,2h-7.3 c0.1,2.5,1.5,2.8,3.6,2.8c1.1,0,2.2-0.3,3.4-0.7C58.5,19,58.5,21.3,58.5,21.3z M56,15c0-1.4-0.5-2.9-2-2.9c-1.4,0-2.3,1.3-2.4,2.9 C51.6,15,56,15,56,15z"></path></svg>
</a>
</div>
<?php
@@ -349,6 +360,22 @@ abstract class Jetpack_Admin_Page {
?>
<!-- END OF CALLBACK -->
+ <div id="jp-stats-report-bottom">
+ <div class="wrap">
+ <?php
+ /**
+ * Fires at the bottom of the Jetpack admin page template, after the dynamic content section.
+ *
+ * @since 10.0.0
+ *
+ * @param string $callback The callback sent to the Jetpack_Admin_Page::wrap_ui method.
+ * @param array $args The arguments sent to the Jetpack_Admin_Page::wrap_ui method.
+ */
+ do_action( 'jetpack_admin_pages_wrap_ui_after_callback', $callback, $args );
+ ?>
+ </div>
+ </div>
+
<div class="jp-footer">
<div class="jp-footer__a8c-attr-container">
<a href="<?php echo esc_url( $jetpack_about_url ); ?>">
@@ -357,13 +384,13 @@ abstract class Jetpack_Admin_Page {
</div>
<ul class="jp-footer__links">
<li class="jp-footer__link-item">
- <a href="https://jetpack.com" target="_blank" rel="noopener noreferrer" class="jp-footer__link" title="<?php esc_html_e( 'Jetpack version', 'jetpack' ); ?>">Jetpack <?php echo JETPACK__VERSION; ?></a>
+ <a href="<?php echo esc_url( Redirect::get_url( 'jetpack' ) ); ?>" target="_blank" rel="noopener noreferrer" class="jp-footer__link" title="<?php esc_html_e( 'Jetpack version', 'jetpack' ); ?>">Jetpack <?php echo esc_html( JETPACK__VERSION ); ?></a>
</li>
<li class="jp-footer__link-item">
<a href="<?php echo esc_url( $jetpack_about_url ); ?>" title="<?php esc_attr__( 'About Jetpack', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html__( 'About', 'jetpack' ); ?></a>
</li>
<li class="jp-footer__link-item">
- <a href="https://wordpress.com/tos/" target="_blank" rel="noopener noreferrer" title="<?php esc_html__( 'WordPress.com Terms of Service', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?></a>
+ <a href="<?php echo esc_url( Redirect::get_url( 'wpcom-tos' ) ); ?>" target="_blank" rel="noopener noreferrer" title="<?php esc_html__( 'WordPress.com Terms of Service', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Terms', 'Navigation item', 'jetpack' ); ?></a>
</li>
<li class="jp-footer__link-item">
<a href="<?php echo esc_url( $jetpack_privacy_url ); ?>" rel="noopener noreferrer" title="<?php esc_html_e( "Automattic's Privacy Policy", 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Privacy', 'Navigation item', 'jetpack' ); ?></a>
@@ -380,7 +407,7 @@ abstract class Jetpack_Admin_Page {
<?php } ?>
<?php if ( current_user_can( 'manage_options' ) ) { ?>
<li class="jp-footer__link-item">
- <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack_modules' ) ); ?>" title="<?php esc_html_e( "Access the full list of Jetpack modules available on your site.", 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Modules', 'Navigation item', 'jetpack' ); ?></a>
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack_modules' ) ); ?>" title="<?php esc_html_e( 'Access the full list of Jetpack modules available on your site.', 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Modules', 'Navigation item', 'jetpack' ); ?></a>
</li>
<li class="jp-footer__link-item">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack-debugger' ) ); ?>" title="<?php esc_html_e( "Test your site's compatibility with Jetpack.", 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Debug', 'Navigation item', 'jetpack' ); ?></a>