summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
committerYury German <blueknight@gentoo.org>2019-05-22 01:01:36 -0400
commit0914c92da22824025992c368c745546e41fbeb84 (patch)
tree965f6adf3b725e56d559fe4a93eff02281499dcc /plugins/jetpack/_inc/lib/admin-pages
parentDeleting plugins for update (diff)
downloadblogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.gz
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.tar.bz2
blogs-gentoo-0914c92da22824025992c368c745546e41fbeb84.zip
Adding Plugins
Updating the following akismet.4.1.2, google-authenticator.0.52, jetpack.7.3.1 Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/_inc/lib/admin-pages')
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class-jetpack-about-page.php679
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php353
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php3
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php399
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php141
5 files changed, 1575 insertions, 0 deletions
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-about-page.php b/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-about-page.php
new file mode 100644
index 00000000..b9987a0f
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/admin-pages/class-jetpack-about-page.php
@@ -0,0 +1,679 @@
+<?php
+/**
+ * Class for the Jetpack About Page within the wp-admin.
+ *
+ * @package Jetpack
+ */
+
+/**
+ * Disable direct access and execution.
+ */
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+require_once 'class.jetpack-admin-page.php';
+
+/**
+ * Builds the landing page and its menu.
+ */
+class Jetpack_About_Page extends Jetpack_Admin_Page {
+
+ /**
+ * Show the settings page only when Jetpack is connected or in dev mode.
+ *
+ * @var bool If the page should be shown.
+ */
+ protected $dont_show_if_not_active = true;
+
+ /**
+ * Add a submenu item to the Jetpack admin menu.
+ *
+ * @return string
+ */
+ public function get_page_hook() {
+ // Add the main admin Jetpack menu.
+ return add_submenu_page(
+ 'jetpack',
+ esc_html__( 'About Jetpack', 'jetpack' ),
+ esc_html__( 'About Jetpack', 'jetpack' ),
+ 'jetpack_admin_page',
+ 'jetpack_about',
+ array( $this, 'render' )
+ );
+ }
+
+ /**
+ * Add page action
+ *
+ * @param string $hook Hook of current page, unused.
+ */
+ public function add_page_actions( $hook ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ // Place the Jetpack menu item on top and others in the order they appear.
+ add_filter( 'custom_menu_order', '__return_true' );
+ add_filter( 'menu_order', array( $this, 'submenu_order' ) );
+ }
+
+ /**
+ * Enqueues scripts and styles for the admin page.
+ */
+ public function page_admin_scripts() {
+ wp_enqueue_style( 'plugin-install' );
+ wp_enqueue_script( 'plugin-install' );
+ // required for plugin modal action button functionality.
+ wp_enqueue_script( 'updates' );
+ // required for modal popup JS and styling.
+ wp_enqueue_style( 'thickbox' );
+ wp_enqueue_script( 'thickbox' );
+ }
+
+ /**
+ * Load styles for static page.
+ */
+ public function additional_styles() {
+ Jetpack_Admin_Page::load_wrapper_styles();
+ }
+
+ /**
+ * Render the page with a common top and bottom part, and page specific content
+ */
+ public function render() {
+ Jetpack_Admin_Page::wrap_ui( array( $this, 'page_render' ), array( 'show-nav' => false ) );
+ }
+
+ /**
+ * Change order of menu item so the About page menu item is below Site Stats.
+ *
+ * @param array $menu_order List of menu slugs. It's unaffected. This filter is used to reorder the Jetpack submenu items.
+ *
+ * @return array
+ */
+ public function submenu_order( $menu_order ) {
+ global $submenu;
+
+ $stats_key = null;
+ $about_key = null;
+
+ foreach ( $submenu['jetpack'] as $index => $menu_item ) {
+ if ( false !== array_search( 'stats', $menu_item, true ) ) {
+ $stats_key = $index;
+ }
+ if ( false !== array_search( 'jetpack_about', $menu_item, true ) ) {
+ $about_key = $index;
+ }
+ }
+
+ if ( $stats_key && $about_key ) {
+ $temp = $submenu['jetpack'][ $stats_key ];
+ $submenu['jetpack'][ $stats_key ] = $submenu['jetpack'][ $about_key ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+ $submenu['jetpack'][ $about_key ] = $temp; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+ }
+
+ return $menu_order;
+ }
+
+ /**
+ * Render the page content
+ */
+ public function page_render() {
+ ?>
+ <div class="jp-lower">
+ <div class="jetpack-about__link-back">
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack' ) ); ?>">
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="0" fill="none" width="24" height="24"/><g><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></g></svg>
+ <?php esc_html_e( 'Back to Jetpack Dashboard', 'jetpack' ); ?>
+ </a>
+ </div>
+ <div class="jetpack-about__main">
+ <div class="jetpack-about__logo">
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 800 96" style="enable-background:new 0 0 800 96;" xml:space="preserve">
+ <g>
+ <path style="fill: #39c;" d="M292.922,78c-19.777,0-32.598-14.245-32.598-29.078V47.08c0-15.086,12.821-29.08,32.598-29.08
+ c19.861,0,32.682,13.994,32.682,29.08v1.843C325.604,63.755,312.783,78,292.922,78z M315.044,47.245
+ c0-10.808-7.877-20.447-22.122-20.447s-22.04,9.639-22.04,20.447v1.341c0,10.811,7.795,20.614,22.04,20.614
+ s22.122-9.803,22.122-20.614V47.245z"/>
+ <path d="M69.602,75.821l-7.374-13.826H29.463l-7.124,13.826H11.277l30.167-55.81h8.715l30.671,55.81H69.602z M45.552,30.906
+ L33.401,54.369h24.72L45.552,30.906z"/>
+ <path d="M128.427,78c-20.028,0-29.329-10.894-29.329-25.391V20.012h10.391v32.765c0,10.308,6.788,16.424,19.692,16.424
+ c13.242,0,18.687-6.116,18.687-16.424V20.012h10.475v32.598C158.342,66.436,149.46,78,128.427,78z"/>
+ <path d="M216.667,28.727v47.094h-10.475V28.727h-24.386v-8.715h59.245v8.715H216.667z"/>
+ <path d="M418.955,75.821V31.659l-2.766,4.861l-23.379,39.301h-5.112L364.569,36.52l-2.765-4.861v44.162h-10.224v-55.81h14.497
+ l22.038,38.296L390.713,63l2.599-4.692l21.786-38.296h14.331v55.81H418.955z"/>
+ <path d="M508.619,75.821l-7.374-13.826H468.48l-7.123,13.826h-11.061l30.167-55.81h8.715l30.669,55.81H508.619z M484.569,30.906
+ l-12.151,23.464h24.72L484.569,30.906z"/>
+ <path d="M562.081,28.727v47.094h-10.474V28.727h-24.386v-8.715h59.245v8.715H562.081z"/>
+ <path d="M638.924,28.727v47.094H628.45V28.727h-24.386v-8.715h59.245v8.715H638.924z"/>
+ <path d="M689.118,75.821v-50.53c4.19,0,5.866-2.263,5.866-5.28h4.442v55.81H689.118z"/>
+ <path d="M781.464,35.765c-5.028-4.609-12.402-8.967-22.374-8.967c-14.916,0-23.296,10.225-23.296,20.867v1.089
+ c0,10.558,8.464,20.445,24.05,20.445c9.303,0,17.012-4.441,21.872-8.965L788,66.854C781.883,72.887,771.492,78,759.174,78
+ c-21.118,0-33.939-13.743-33.939-28.828v-1.843c0-15.084,13.993-29.329,34.44-29.329c11.816,0,22.541,4.944,28.324,11.146
+ L781.464,35.765z"/>
+ <path d="M299.82,37.417c1.889,1.218,2.418,3.749,1.192,5.648l-9.553,14.797c-1.226,1.901-3.752,2.452-5.637,1.234l0,0
+ c-1.886-1.22-2.421-3.745-1.192-5.647l9.553-14.797C295.41,36.753,297.935,36.201,299.82,37.417L299.82,37.417z"/>
+ </g>
+ </svg>
+ </div>
+ <div class="jetpack-about__content">
+ <div class="jetpack-about__images">
+ <ul class="jetpack-about__gravatars">
+ <?php $this->display_gravatars(); ?>
+ </ul>
+ <p class="meet-the-team">
+ <a href="https://automattic.com/about/" target="_blank" rel="noopener noreferrer" class="jptracks" data-jptracks-name="jetpack_about_meet_the_team"><?php esc_html_e( 'Meet the Automattic team', 'jetpack' ); ?></a>
+ </p>
+ </div>
+
+ <div class="jetpack-about__text">
+ <p>
+ <?php esc_html_e( 'We are the people behind WordPress.com, WooCommerce, Jetpack, Simplenote, Longreads, VaultPress, Akismet, Gravatar, Crowdsignal, Cloudup, and more. We believe in making the web a better place.', 'jetpack' ); ?>
+ <a href="https://automattic.com/" target="_blank" rel="noopener noreferrer" class="jptracks" data-jptracks-name="jetpack_about_learn_more">
+ <?php esc_html_e( 'Learn more about us.', 'jetpack' ); ?>
+ </a>
+ </p>
+ <p>
+ <?php esc_html_e( 'We’re a distributed company with over 875 Automatticians in more than 67 countries speaking at least 83 different languages. Our common goal is to democratize publishing so that anyone with a story can tell it, regardless of income, gender, politics, language, or where they live in the world.', 'jetpack' ); ?>
+ </p>
+ <p>
+ <?php esc_html_e( 'We believe in Open Source and the vast majority of our work is available under the GPL.', 'jetpack' ); ?>
+ </p>
+ <p>
+ <?php
+ // Maybe use printf() because we'll want to escape the string but still allow for the link, so we can't use esc_html_e().
+ echo wp_kses(
+ __( 'We strive to live by the <a href="https://automattic.com/creed/" target="_blank" class="jptracks" data-jptracks-name="jetpack_about_creed" rel="noopener noreferrer">Automattic Creed</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'class' => array(),
+ 'target' => array(),
+ 'rel' => array(),
+ 'data-jptracks-name' => array(),
+ ),
+ )
+ );
+ ?>
+ </p>
+ <p>
+ <a href="https://automattic.com/work-with-us" target="_blank" rel="noopener noreferrer" class="jptracks" data-jptracks-name="jetpack_about_work_with_us">
+ <?php esc_html_e( 'Come work with us', 'jetpack' ); ?>
+ </a>
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="jetpack-about__colophon">
+ <h3><?php esc_html_e( 'Popular WordPress services by Automattic', 'jetpack' ); ?></h3>
+ <ul class="jetpack-about__services">
+ <?php $this->display_plugins(); ?>
+ </ul>
+
+ <p class="jetpack-about__services-more">
+ <?php
+ echo wp_kses(
+ __( 'For even more of our WordPress plugins, please <a href="https://profiles.wordpress.org/automattic/#content-plugins" target="_blank" rel="noopener noreferrer" class="jptracks" data-jptracks-name="jetpack_about_wporg_profile">take a look at our WordPress.org profile</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ 'rel' => array(),
+ 'class' => array(),
+ 'data-jptracks-name' => array(),
+ ),
+ )
+ );
+ ?>
+ </p>
+ </div>
+ </div>
+ <?php
+ }
+
+ /**
+ * Add information cards for a8c plugins.
+ */
+ public function display_plugins() {
+ $plugins_allowedtags = array(
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ 'target' => array(),
+ ),
+ 'abbr' => array( 'title' => array() ),
+ 'acronym' => array( 'title' => array() ),
+ 'code' => array(),
+ 'pre' => array(),
+ 'em' => array(),
+ 'strong' => array(),
+ 'ul' => array(),
+ 'ol' => array(),
+ 'li' => array(),
+ 'p' => array(),
+ 'br' => array(),
+ );
+
+ // slugs for plugins we want to display.
+ $a8c_plugins = array(
+ 'woocommerce',
+ 'wp-super-cache',
+ 'wp-job-manager',
+ 'co-authors-plus',
+ );
+
+ // need this to access the plugins_api() function.
+ include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
+
+ $plugins = array();
+ foreach ( $a8c_plugins as $slug ) {
+ $args = array(
+ 'slug' => $slug,
+ 'fields' => array(
+ 'added' => false,
+ 'author' => false,
+ 'author_profile' => false,
+ 'banners' => false,
+ 'contributors' => false,
+ 'donate_link' => false,
+ 'homepage' => false,
+ 'reviews' => false,
+ 'screenshots' => false,
+ 'support_threads' => false,
+ 'support_threads_resolved' => false,
+ 'sections' => false,
+ 'tags' => false,
+ 'versions' => false,
+
+ 'compatibility' => true,
+ 'downloaded' => true,
+ 'downloadlink' => true,
+ 'icons' => true,
+ 'last_updated' => true,
+ 'num_ratings' => true,
+ 'rating' => true,
+ 'requires' => true,
+ 'requires_php' => true,
+ 'short_description' => true,
+ 'tested' => true,
+ ),
+ );
+
+ // should probably add some error checking here too.
+ $api = plugins_api( 'plugin_information', $args );
+ $plugins[] = $api;
+ }
+
+ foreach ( $plugins as $plugin ) {
+ if ( is_object( $plugin ) ) {
+ $plugin = (array) $plugin;
+ }
+
+ $title = wp_kses( $plugin['name'], $plugins_allowedtags );
+ $version = wp_kses( $plugin['version'], $plugins_allowedtags );
+
+ $name = wp_strip_all_tags( $title . ' ' . $version );
+
+ // Remove any HTML from the description.
+ $description = wp_strip_all_tags( $plugin['short_description'] );
+
+ $wp_version = get_bloginfo( 'version' );
+
+ $compatible_php = ( empty( $plugin['requires_php'] ) || version_compare( phpversion(), $plugin['requires_php'], '>=' ) );
+ $compatible_wp = ( empty( $plugin['requires'] ) || version_compare( $wp_version, $plugin['requires'], '>=' ) );
+
+ $action_links = array();
+
+ // install button.
+ if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
+ $status = install_plugin_install_status( $plugin );
+ switch ( $status['status'] ) {
+ case 'install':
+ if ( $status['url'] ) {
+ if ( $compatible_php && $compatible_wp ) {
+ $action_links[] = sprintf(
+ '<a class="install-now button jptracks" data-slug="%1$s" href="%2$s" aria-label="%3$s" data-name="%4$s" data-jptracks-name="jetpack_about_install_button" data-jptracks-prop="%4$s">%5$s</a>',
+ esc_attr( $plugin['slug'] ),
+ esc_url( $status['url'] ),
+ /* translators: %s: plugin name and version */
+ esc_attr( sprintf( __( 'Install %s now', 'jetpack' ), $name ) ),
+ esc_attr( $name ),
+ esc_html__( 'Install Now', 'jetpack' )
+ );
+ } else {
+ $action_links[] = sprintf(
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
+ _x( 'Cannot Install', 'plugin', 'jetpack' )
+ );
+ }
+ }
+ break;
+
+ case 'update_available':
+ if ( $status['url'] ) {
+ $action_links[] = sprintf(
+ '<a class="update-now button aria-button-if-js jptracks" data-plugin="%1$s" data-slug="%2$s" href="%3$s" aria-label="%4$s" data-name="%5$s" data-jptracks-name="jetpack_about_update_button" data-jptracks-prop="%5$s">%6$s</a>',
+ esc_attr( $status['file'] ),
+ esc_attr( $plugin['slug'] ),
+ esc_url( $status['url'] ),
+ /* translators: %s: plugin name and version */
+ esc_attr( sprintf( __( 'Update %s now', 'jetpack' ), $name ) ),
+ esc_attr( $name ),
+ __( 'Update Now', 'jetpack' )
+ );
+ }
+ break;
+
+ case 'latest_installed':
+ case 'newer_installed':
+ if ( is_plugin_active( $status['file'] ) ) {
+ $action_links[] = sprintf(
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
+ _x( 'Active', 'plugin', 'jetpack' )
+ );
+ } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
+ $button_text = __( 'Activate', 'jetpack' );
+ /* translators: %s: plugin name */
+ $button_label = _x( 'Activate %s', 'plugin', 'jetpack' );
+ $activate_url = add_query_arg(
+ array(
+ '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
+ 'action' => 'activate',
+ 'plugin' => $status['file'],
+ ),
+ network_admin_url( 'plugins.php' )
+ );
+
+ if ( is_network_admin() ) {
+ $button_text = __( 'Network Activate', 'jetpack' );
+ /* translators: %s: plugin name */
+ $button_label = _x( 'Network Activate %s', 'plugin', 'jetpack' );
+ $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
+ }
+
+ $action_links[] = sprintf(
+ '<a href="%1$s" class="button activate-now" aria-label="%2$s" data-jptracks-name="jetpack_about_activate_button" data-jptracks-prop="%3$s">%4$s</a>',
+ esc_url( $activate_url ),
+ esc_attr( sprintf( $button_label, $plugin['name'] ) ),
+ esc_attr( $plugin['name'] ),
+ $button_text
+ );
+ } else {
+ $action_links[] = sprintf(
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
+ _x( 'Installed', 'plugin', 'jetpack' )
+ );
+ }
+ break;
+ }
+ }
+
+ $plugin_install = "plugin-install.php?tab=plugin-information&amp;plugin={$plugin['slug']}&amp;TB_iframe=true&amp;width=600&amp;height=550";
+ $details_link = is_multisite()
+ ? network_admin_url( $plugin_install )
+ : admin_url( $plugin_install );
+
+ if ( ! empty( $plugin['icons']['svg'] ) ) {
+ $plugin_icon_url = $plugin['icons']['svg'];
+ } elseif ( ! empty( $plugin['icons']['2x'] ) ) {
+ $plugin_icon_url = $plugin['icons']['2x'];
+ } elseif ( ! empty( $plugin['icons']['1x'] ) ) {
+ $plugin_icon_url = $plugin['icons']['1x'];
+ } else {
+ $plugin_icon_url = $plugin['icons']['default'];
+ }
+ ?>
+
+ <li class="jetpack-about__plugin plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
+ <?php
+ if ( ! $compatible_php || ! $compatible_wp ) {
+ echo '<div class="notice inline notice-error notice-alt"><p>';
+ if ( ! $compatible_php && ! $compatible_wp ) {
+ esc_html_e( 'This plugin doesn&#8217;t work with your versions of WordPress and PHP.', 'jetpack' );
+ if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
+ printf(
+ /* translators: 1: "Update WordPress" screen URL, 2: "Update PHP" page URL */
+ ' ' . wp_kses( __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ),
+ esc_url( self_admin_url( 'update-core.php' ) ),
+ esc_url( $this->jp_get_update_php_url() )
+ );
+ $this->jp_update_php_annotation();
+ } elseif ( current_user_can( 'update_core' ) ) {
+ printf(
+ /* translators: %s: "Update WordPress" screen URL */
+ ' ' . wp_kses( __( '<a href="%s">Please update WordPress</a>.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ),
+ esc_url( self_admin_url( 'update-core.php' ) )
+ );
+ } elseif ( current_user_can( 'update_php' ) ) {
+ printf(
+ /* translators: %s: "Update PHP" page URL */
+ ' ' . wp_kses( __( '<a href="%s">Learn more about updating PHP</a>.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ),
+ esc_url( $this->jp_get_update_php_url() )
+ );
+ $this->jp_update_php_annotation();
+ }
+ } elseif ( ! $compatible_wp ) {
+ esc_html_e( 'This plugin doesn&#8217;t work with your version of WordPress.', 'jetpack' );
+ if ( current_user_can( 'update_core' ) ) {
+ printf(
+ /* translators: %s: "Update WordPress" screen URL */
+ ' ' . wp_kses( __( '<a href="%s">Please update WordPress</a>.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ),
+ esc_url( self_admin_url( 'update-core.php' ) )
+ );
+ }
+ } elseif ( ! $compatible_php ) {
+ esc_html_e( 'This plugin doesn&#8217;t work with your version of PHP.', 'jetpack' );
+ if ( current_user_can( 'update_php' ) ) {
+ printf(
+ /* translators: %s: "Update PHP" page URL */
+ ' ' . wp_kses( __( '<a href="%s">Learn more about updating PHP</a>.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ),
+ esc_url( $this->jp_get_update_php_url() )
+ );
+ $this->jp_update_php_annotation();
+ }
+ }
+ echo '</p></div>';
+ }
+ ?>
+
+ <div class="plugin-card-top">
+ <div class="name column-name">
+ <h3>
+ <a href="<?php echo esc_url( $details_link ); ?>" class="jptracks thickbox open-plugin-details-modal" data-jptracks-name="jetpack_about_plugin_modal" data-jptracks-prop="<?php echo esc_attr( $plugin['slug'] ); ?>">
+ <?php echo esc_html( $title ); ?>
+ <img src="<?php echo esc_attr( $plugin_icon_url ); ?>" class="plugin-icon" alt="">
+ </a>
+ </h3>
+ </div>
+ <div class="desc column-description">
+ <p><?php echo esc_html( $description ); ?></p>
+ </div>
+
+ <div class="details-link">
+ <a class="jptracks thickbox open-plugin-details-modal" href="<?php echo esc_url( $details_link ); ?>" data-jptracks-name="jetpack_about_plugin_details_modal" data-jptracks-prop="<?php echo esc_attr( $plugin['slug'] ); ?>"><?php esc_html_e( 'More Details', 'jetpack' ); ?></a>
+ </div>
+ </div>
+
+ <div class="plugin-card-bottom">
+ <div class="meta">
+ <?php
+ wp_star_rating(
+ array(
+ 'rating' => $plugin['rating'],
+ 'type' => 'percent',
+ 'number' => $plugin['num_ratings'],
+ )
+ );
+ ?>
+ <span class="num-ratings" aria-hidden="true">(<?php echo esc_html( number_format_i18n( $plugin['num_ratings'] ) ); ?> <?php esc_html_e( 'ratings', 'jetpack' ); ?>)</span>
+ <div class="downloaded">
+ <?php
+ if ( $plugin['active_installs'] >= 1000000 ) {
+ $active_installs_millions = floor( $plugin['active_installs'] / 1000000 );
+ $active_installs_text = sprintf(
+ /* translators: number of millions of installs. */
+ _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations', 'jetpack' ),
+ number_format_i18n( $active_installs_millions )
+ );
+ } elseif ( 0 === $plugin['active_installs'] ) {
+ $active_installs_text = _x( 'Less Than 10', 'Active plugin installations', 'jetpack' );
+ } else {
+ $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
+ }
+ /* translators: number of active installs */
+ printf( esc_html__( '%s Active Installations', 'jetpack' ), esc_html( $active_installs_text ) );
+ ?>
+ </div>
+ </div>
+
+ <div class="action-links">
+ <?php
+ if ( $action_links ) {
+ // The var simply collects strings that have already been sanitized.
+ // phpcs:ignore WordPress.Security.EscapeOutput
+ echo '<ul class="action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
+ }
+ ?>
+ </div>
+ </div>
+ </li>
+ <?php
+
+ }
+
+ }
+
+ /**
+ * Fetch Gravatar hashes for public A12s from wpcom and display them as a list.
+ *
+ * @since 7.3
+ */
+ public function display_gravatars() {
+ $hashes = array(
+ 'https://1.gravatar.com/avatar/d2ab03dbab0c97740be75f290a2e3190',
+ 'https://2.gravatar.com/avatar/b0b357b291ac72bc7da81b4d74430fe6',
+ 'https://2.gravatar.com/avatar/9e149207a0e0818abed0edbb1fb2d0bf',
+ 'https://2.gravatar.com/avatar/9f376366854d750124dffe057dda99c9',
+ 'https://1.gravatar.com/avatar/1c75d26ad0d38624f02b15accc1f20cd',
+ 'https://1.gravatar.com/avatar/c510e69d83c7d10be4df64feeff4e46a',
+ 'https://0.gravatar.com/avatar/88ec0dcadea38adf5f30a17e54e9b248',
+ 'https://1.gravatar.com/avatar/bc45834430c5b0936d76e3f468f9ca57',
+ 'https://0.gravatar.com/avatar/032677e4115f3a38dc7785529e8cc4d9',
+ 'https://0.gravatar.com/avatar/72a638c2520ea177976e8eafb201a82f',
+ 'https://0.gravatar.com/avatar/b3618d70c63bbc5cc7caee0beded5ff0',
+ 'https://1.gravatar.com/avatar/4d346581a3340e32cf93703c9ce46bd4',
+ 'https://2.gravatar.com/avatar/9c2f6b95a00dfccfadc6a912a2b859ba',
+ 'https://1.gravatar.com/avatar/1a33e7a69df4f675fcd799edca088ac2',
+ 'https://2.gravatar.com/avatar/d5dc443845c134f365519568d5d80e62',
+ 'https://0.gravatar.com/avatar/c0ccdd53794779bcc07fcae7b79c4d80',
+ );
+ $output = '';
+ foreach ( $hashes as $hash ) {
+ $output .= '<li><img src="' . esc_url( $hash ) . '?s=150"></li>' . "\n";
+ }
+ echo wp_kses(
+ $output,
+ array(
+ 'li' => true,
+ 'img' => array(
+ 'src' => true,
+ ),
+ )
+ );
+ }
+
+ // The following methods jp_get_update_php_url, jp_get_default_update_php_url, and jp_update_php_annotation,
+ // are copies of functions introduced in WP 5.1
+ // At the time of releasing this, we're still supporting WP 5.0, so we needed
+ // to have them here to avoid fatal errors in old installations.
+
+ /**
+ * Gets the URL to learn more about updating the PHP version the site is running on.
+ *
+ * This URL can be overridden by specifying an environment variable `WP_UPDATE_PHP_URL` or by using the
+ * {@see 'wp_update_php_url'} filter. Providing an empty string is not allowed and will result in the
+ * default URL being used. Furthermore the page the URL links to should preferably be localized in the
+ * site language.
+ *
+ * @todo: Remove when 5.1 is minimum WP version.
+ * @since 5.1.0
+ *
+ * @return string URL to learn more about updating PHP.
+ */
+ private function jp_get_update_php_url() {
+ $default_url = $this->jp_get_default_update_php_url();
+
+ $update_url = $default_url;
+ if ( false !== getenv( 'WP_UPDATE_PHP_URL' ) ) {
+ $update_url = getenv( 'WP_UPDATE_PHP_URL' );
+ }
+
+ /**
+ * Filters the URL to learn more about updating the PHP version the site is running on.
+ *
+ * Providing an empty string is not allowed and will result in the default URL being used. Furthermore
+ * the page the URL links to should preferably be localized in the site language.
+ *
+ * @since 5.1.0
+ *
+ * @param string $update_url URL to learn more about updating PHP.
+ */
+ $update_url = apply_filters( 'wp_update_php_url', $update_url );
+
+ if ( empty( $update_url ) ) {
+ $update_url = $default_url;
+ }
+
+ return $update_url;
+ }
+
+ /**
+ * Gets the default URL to learn more about updating the PHP version the site is running on.
+ *
+ * Do not use this function to retrieve this URL. Instead, use {@see wp_get_update_php_url()} when relying on the URL.
+ * This function does not allow modifying the returned URL, and is only used to compare the actually used URL with the
+ * default one.
+ *
+ * @todo: Remove when 5.1 is minimum WP version.
+ * @since 5.1.0
+ * @access private
+ *
+ * @return string Default URL to learn more about updating PHP.
+ */
+ private function jp_get_default_update_php_url() {
+ return _x( 'https://wordpress.org/support/update-php/', 'localized PHP upgrade information page', 'jetpack' );
+ }
+
+ /**
+ * Prints the default annotation for the web host altering the "Update PHP" page URL.
+ *
+ * This function is to be used after {@see wp_get_update_php_url()} to display a consistent
+ * annotation if the web host has altered the default "Update PHP" page URL.
+ *
+ * @todo: Remove when 5.1 is minimum WP version.
+ * @since 5.1.0
+ */
+ private function jp_update_php_annotation() {
+ $update_url = $this->jp_get_update_php_url();
+ $default_url = $this->jp_get_default_update_php_url();
+
+ if ( $update_url === $default_url ) {
+ return;
+ }
+
+ echo '<p class="description">';
+ printf(
+ wp_kses(
+ /* translators: %s: default Update PHP page URL */
+ __( 'This resource is provided by your web host, and is specific to your site. For more information, <a href="%s" target="_blank" rel="noopener noreferrer">see the official WordPress documentation</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => true,
+ 'rel' => true,
+ ),
+ )
+ ),
+ esc_url( $default_url )
+ );
+ echo '</p>';
+ }
+
+}
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
new file mode 100644
index 00000000..a6822678
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
@@ -0,0 +1,353 @@
+<?php
+
+// Shared logic between Jetpack admin pages
+abstract class Jetpack_Admin_Page {
+ // Add page specific actions given the page hook
+ abstract function add_page_actions( $hook );
+
+ // Create a menu item for the page and returns the hook
+ abstract function get_page_hook();
+
+ // Enqueue and localize page specific scripts
+ abstract function page_admin_scripts();
+
+ // Render page specific HTML
+ abstract function page_render();
+
+ /**
+ * Should we block the page rendering because the site is in IDC?
+ *
+ * @var bool
+ */
+ static $block_page_rendering_for_idc;
+
+ /**
+ * Function called after admin_styles to load any additional needed styles.
+ *
+ * @since 4.3.0
+ */
+ function additional_styles() {}
+
+ function __construct() {
+ $this->jetpack = Jetpack::init();
+ self::$block_page_rendering_for_idc = (
+ Jetpack::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' )
+ );
+ }
+
+ function add_actions() {
+ global $pagenow;
+
+ // If user is not an admin and site is in Dev Mode, don't do anything
+ if ( ! current_user_can( 'manage_options' ) && Jetpack::is_development_mode() ) {
+ return;
+ }
+
+ // Don't add in the modules page unless modules are available!
+ if ( $this->dont_show_if_not_active && ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) {
+ 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
+ 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' ) );
+ add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) );
+
+ if ( ! self::$block_page_rendering_for_idc ) {
+ add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) );
+ }
+ // 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' )
+ && ! Jetpack::is_development_mode()
+ ) {
+ add_action( 'admin_enqueue_scripts', array( 'Jetpack_Connection_Banner', 'enqueue_banner_scripts' ) );
+ add_action( 'admin_print_styles', array( Jetpack::init(), 'admin_banner_styles' ) );
+ add_action( 'admin_notices', array( 'Jetpack_Connection_Banner', 'render_connect_prompt_full_screen' ) );
+ delete_transient( 'activated_jetpack' );
+ }
+
+ // 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
+ function render() {
+ // We're in an IDC: we need a decision made before we show the UI again.
+ if ( self::$block_page_rendering_for_idc ) {
+ return;
+ }
+
+ // Check if we are looking at the main dashboard
+ if ( isset( $_GET['page'] ) && 'jetpack' === $_GET['page'] ) {
+ $this->page_render();
+ return;
+ }
+ self::wrap_ui( array( $this, 'page_render' ) );
+ }
+
+ function admin_help() {
+ $this->jetpack->admin_help();
+ }
+
+ function admin_page_load() {
+ // This is big. For the moment, just call the existing one.
+ $this->jetpack->admin_page_load();
+ }
+
+ // Add page specific scripts and jetpack stats for all menu pages
+ function admin_scripts() {
+ $this->page_admin_scripts(); // Delegate to inheriting class
+ add_action( 'admin_footer', array( $this->jetpack, 'do_stats' ) );
+ }
+
+ // Enqueue the Jetpack admin stylesheet
+ function admin_styles() {
+ $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
+
+ wp_enqueue_style( 'jetpack-admin', plugins_url( "css/jetpack-admin{$min}.css", JETPACK__PLUGIN_FILE ), array( 'genericons' ), JETPACK__VERSION . '-20121016' );
+ wp_style_add_data( 'jetpack-admin', 'rtl', 'replace' );
+ wp_style_add_data( 'jetpack-admin', 'suffix', $min );
+ }
+
+ /**
+ * Checks if REST API is enabled.
+ *
+ * @since 4.4.2
+ *
+ * @return bool
+ */
+ function is_rest_api_enabled() {
+ 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 );
+ }
+
+ /**
+ * Checks the site plan and deactivates modules that were active but are no longer included in the plan.
+ *
+ * @since 4.4.0
+ *
+ * @param $page
+ *
+ * @return array
+ */
+ function check_plan_deactivate_modules( $page ) {
+ if (
+ Jetpack::is_development_mode()
+ || ! in_array(
+ $page->base,
+ array(
+ 'toplevel_page_jetpack',
+ 'admin_page_jetpack_modules',
+ 'jetpack_page_vaultpress',
+ 'jetpack_page_stats',
+ 'jetpack_page_akismet-key-config',
+ )
+ )
+ ) {
+ return false;
+ }
+
+ $current = Jetpack_Plan::get();
+
+ $to_deactivate = array();
+ if ( isset( $current['product_slug'] ) ) {
+ $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' );
+ break;
+ case 'jetpack_premium':
+ case 'jetpack_premium_monthly':
+ $to_deactivate = array( 'seo-tools', 'google-analytics', 'search' );
+ break;
+ }
+ $to_deactivate = array_intersect( $active, $to_deactivate );
+
+ $to_leave_enabled = array();
+ foreach ( $to_deactivate as $feature ) {
+ if ( Jetpack_Plan::supports( $feature ) ) {
+ $to_leave_enabled [] = $feature;
+ }
+ }
+ $to_deactivate = array_diff( $to_deactivate, $to_leave_enabled );
+
+ if ( ! empty( $to_deactivate ) ) {
+ Jetpack::update_active_modules( array_filter( array_diff( $active, $to_deactivate ) ) );
+ }
+ }
+ return array(
+ 'current' => $current,
+ 'deactivate' => $to_deactivate,
+ );
+ }
+
+ static function load_wrapper_styles() {
+ $rtl = is_rtl() ? '.rtl' : '';
+ wp_enqueue_style( 'dops-css', plugins_url( "_inc/build/admin.dops-style{$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 );
+ $custom_css = '
+ #wpcontent {
+ padding-left: 0 !important;
+ }
+ #wpbody-content {
+ background-color: #f6f6f6;
+ }
+
+ #jp-plugin-container .wrap {
+ margin: 0 auto;
+ max-width:45rem;
+ padding: 0 1.5rem;
+ }
+ #jp-plugin-container.is-wide .wrap {
+ max-width: 1040px;
+ }
+ #jp-plugin-container .wrap .jetpack-wrap-container {
+ margin-top: 1em;
+ }
+ .wp-admin #dolly {
+ float: none;
+ position: relative;
+ right: 0;
+ left: 0;
+ top: 0;
+ padding: .625rem;
+ text-align: right;
+ background: #fff;
+ font-size: .75rem;
+ font-style: italic;
+ color: #87a6bc;
+ border-bottom: 1px #e9eff3 solid;
+ }
+ ';
+ wp_add_inline_style( 'dops-css', $custom_css );
+ }
+
+ public static function wrap_ui( $callback, $args = array() ) {
+ $defaults = array(
+ 'is-wide' => false,
+ 'show-nav' => true,
+ );
+ $args = wp_parse_args( $args, $defaults );
+ $jetpack_admin_url = admin_url( 'admin.php?page=jetpack' );
+
+ ?>
+ <div id="jp-plugin-container" class="
+ <?php
+ if ( $args['is-wide'] ) {
+ echo 'is-wide'; }
+ ?>
+ ">
+
+ <div class="jp-masthead">
+ <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>
+ </a>
+ </div>
+ <?php
+ if ( $args['show-nav'] ) :
+ ?>
+ <div class="jp-masthead__nav">
+ <?php
+ if ( is_network_admin() ) {
+ $current_screen = get_current_screen();
+
+ $highlight_current_sites = ( 'toplevel_page_jetpack-network' === $current_screen->id ? 'is-primary' : '' );
+ $highlight_current_settings = ( 'jetpack_page_jetpack-settings-network' === $current_screen->id ? 'is-primary' : '' );
+ ?>
+ <span class="dops-button-group">
+ <?php
+ if ( current_user_can( 'jetpack_network_sites_page' ) ) {
+ ?>
+ <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack' ) ); ?>" type="button" class="<?php echo esc_attr( $highlight_current_sites ); ?> dops-button is-compact" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>"><?php echo esc_html_x( 'Sites', 'Navigation item', 'jetpack' ); ?></a>
+ <?php
+ } if ( current_user_can( 'jetpack_network_settings_page' ) ) {
+ ?>
+ <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack-settings' ) ); ?>" type="button" class="<?php echo esc_attr( $highlight_current_settings ); ?> dops-button is-compact" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>"><?php echo esc_html_x( 'Network Settings', 'Navigation item', 'jetpack' ); ?></a>
+ <?php
+ }
+ ?>
+ </span>
+ <?php } else { ?>
+ <span class="dops-button-group">
+ <a href="<?php echo esc_url( $jetpack_admin_url ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Dashboard', 'jetpack' ); ?></a>
+ <?php
+ if ( current_user_can( 'jetpack_manage_modules' ) ) {
+ ?>
+ <a href="<?php echo esc_url( $jetpack_admin_url . '#/settings' ); ?>" type="button" class="dops-button is-compact"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a>
+ <?php
+ }
+ ?>
+ </span>
+ <?php } ?>
+ </div>
+ <?php endif; ?>
+ </div>
+ </div>
+ <div class="wrap"><div id="jp-admin-notices" aria-live="polite"></div></div>
+ <!-- START OF CALLBACK -->
+ <?php
+ ob_start();
+ call_user_func( $callback );
+ $callback_ui = ob_get_contents();
+ ob_end_clean();
+ echo $callback_ui;
+ ?>
+ <!-- END OF CALLBACK -->
+ <div class="jp-footer">
+ <div class="jp-footer__a8c-attr-container"><a href="https://automattic.com" target="_blank" rel="noopener noreferrer"><svg role="img" class="jp-footer__a8c-attr" x="0" y="0" viewBox="0 0 935 38.2" enable-background="new 0 0 935 38.2" aria-labelledby="a8c-svg-title"><title id="a8c-svg-title">An Automattic Airline</title><path d="M317.1 38.2c-12.6 0-20.7-9.1-20.7-18.5v-1.2c0-9.6 8.2-18.5 20.7-18.5 12.6 0 20.8 8.9 20.8 18.5v1.2C337.9 29.1 329.7 38.2 317.1 38.2zM331.2 18.6c0-6.9-5-13-14.1-13s-14 6.1-14 13v0.9c0 6.9 5 13.1 14 13.1s14.1-6.2 14.1-13.1V18.6zM175 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7L157 1.3h5.5L182 36.8H175zM159.7 8.2L152 23.1h15.7L159.7 8.2zM212.4 38.2c-12.7 0-18.7-6.9-18.7-16.2V1.3h6.6v20.9c0 6.6 4.3 10.5 12.5 10.5 8.4 0 11.9-3.9 11.9-10.5V1.3h6.7V22C231.4 30.8 225.8 38.2 212.4 38.2zM268.6 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H268.6zM397.3 36.8V8.7l-1.8 3.1 -14.9 25h-3.3l-14.7-25 -1.8-3.1v28.1h-6.5V1.3h9.2l14 24.4 1.7 3 1.7-3 13.9-24.4h9.1v35.5H397.3zM454.4 36.8l-4.7-8.8h-20.9l-4.5 8.8h-7l19.2-35.5h5.5l19.5 35.5H454.4zM439.1 8.2l-7.7 14.9h15.7L439.1 8.2zM488.4 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H488.4zM537.3 6.8v30h-6.7v-30h-15.5V1.3h37.7v5.5H537.3zM569.3 36.8V4.6c2.7 0 3.7-1.4 3.7-3.4h2.8v35.5L569.3 36.8 569.3 36.8zM628 11.3c-3.2-2.9-7.9-5.7-14.2-5.7 -9.5 0-14.8 6.5-14.8 13.3v0.7c0 6.7 5.4 13 15.3 13 5.9 0 10.8-2.8 13.9-5.7l4 4.2c-3.9 3.8-10.5 7.1-18.3 7.1 -13.4 0-21.6-8.7-21.6-18.3v-1.2c0-9.6 8.9-18.7 21.9-18.7 7.5 0 14.3 3.1 18 7.1L628 11.3zM321.5 12.4c1.2 0.8 1.5 2.4 0.8 3.6l-6.1 9.4c-0.8 1.2-2.4 1.6-3.6 0.8l0 0c-1.2-0.8-1.5-2.4-0.8-3.6l6.1-9.4C318.7 11.9 320.3 11.6 321.5 12.4L321.5 12.4z"></path><path d="M37.5 36.7l-4.7-8.9H11.7l-4.6 8.9H0L19.4 0.8H25l19.7 35.9H37.5zM22 7.8l-7.8 15.1h15.9L22 7.8zM82.8 36.7l-23.3-24 -2.3-2.5v26.6h-6.7v-36H57l22.6 24 2.3 2.6V0.8h6.7v35.9H82.8z"></path><path d="M719.9 37l-4.8-8.9H694l-4.6 8.9h-7.1l19.5-36h5.6l19.8 36H719.9zM704.4 8l-7.8 15.1h15.9L704.4 8zM733 37V1h6.8v36H733zM781 37c-1.8 0-2.6-2.5-2.9-5.8l-0.2-3.7c-0.2-3.6-1.7-5.1-8.4-5.1h-12.8V37H750V1h19.6c10.8 0 15.7 4.3 15.7 9.9 0 3.9-2 7.7-9 9 7 0.5 8.5 3.7 8.6 7.9l0.1 3c0.1 2.5 0.5 4.3 2.2 6.1V37H781zM778.5 11.8c0-2.6-2.1-5.1-7.9-5.1h-13.8v10.8h14.4c5 0 7.3-2.4 7.3-5.2V11.8zM794.8 37V1h6.8v30.4h28.2V37H794.8zM836.7 37V1h6.8v36H836.7zM886.2 37l-23.4-24.1 -2.3-2.5V37h-6.8V1h6.5l22.7 24.1 2.3 2.6V1h6.8v36H886.2zM902.3 37V1H935v5.6h-26v9.2h20v5.5h-20v10.1h26V37H902.3z"></path></svg></a></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>
+ </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>
+ </li>
+ <li class="jp-footer__link-item">
+ <a href="<?php echo esc_url( $jetpack_admin_url . '#/privacy' ); ?>" 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>
+ </li>
+ <?php if ( is_multisite() && current_user_can( 'jetpack_network_sites_page' ) ) { ?>
+ <li class="jp-footer__link-item">
+ <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack' ) ); ?>" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Network Sites', 'Navigation item', 'jetpack' ); ?></a>
+ </li>
+ <?php } ?>
+ <?php if ( is_multisite() && current_user_can( 'jetpack_network_settings_page' ) ) { ?>
+ <li class="jp-footer__link-item">
+ <a href="<?php echo esc_url( network_admin_url( 'admin.php?page=jetpack-settings' ) ); ?>" title="<?php esc_html_e( "Manage your network's Jetpack Sites.", 'jetpack' ); ?>" class="jp-footer__link"><?php echo esc_html_x( 'Network Settings', 'Navigation item', 'jetpack' ); ?></a>
+ </li>
+ <?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>
+ </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>
+ </li>
+ <?php } ?>
+ </ul>
+ </div>
+ </div>
+ <?php
+ return;
+ }
+}
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php
new file mode 100644
index 00000000..5c06c284
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php
@@ -0,0 +1,3 @@
+<?php
+// This is intentionally left empty as a stub because some sites were caching the require()
+// @see https://github.com/Automattic/jetpack/issues/5091
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
new file mode 100644
index 00000000..e5a423f0
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
@@ -0,0 +1,399 @@
+<?php
+include_once( 'class.jetpack-admin-page.php' );
+
+// Builds the landing page and its menu
+class Jetpack_React_Page extends Jetpack_Admin_Page {
+
+ protected $dont_show_if_not_active = false;
+
+ protected $is_redirecting = false;
+
+ function get_page_hook() {
+ // Add the main admin Jetpack menu
+ return add_menu_page( 'Jetpack', 'Jetpack', 'jetpack_admin_page', 'jetpack', array( $this, 'render' ), 'div' );
+ }
+
+ function add_page_actions( $hook ) {
+ /** This action is documented in class.jetpack.php */
+ do_action( 'jetpack_admin_menu', $hook );
+
+ // Place the Jetpack menu item on top and others in the order they appear
+ add_filter( 'custom_menu_order', '__return_true' );
+ add_filter( 'menu_order', array( $this, 'jetpack_menu_order' ) );
+
+ if ( ! isset( $_GET['page'] ) || 'jetpack' !== $_GET['page'] ) {
+ return; // No need to handle the fallback redirection if we are not on the Jetpack page
+ }
+
+ // Adding a redirect meta tag if the REST API is disabled
+ if ( ! $this->is_rest_api_enabled() ) {
+ $this->is_redirecting = true;
+ add_action( 'admin_head', array( $this, 'add_fallback_head_meta' ) );
+ }
+
+ // Adding a redirect meta tag wrapped in noscript tags for all browsers in case they have JavaScript disabled
+ add_action( 'admin_head', array( $this, 'add_noscript_head_meta' ) );
+
+ // If this is the first time the user is viewing the admin, don't show JITMs.
+ // This filter is added just in time because this function is called on admin_menu
+ // and JITMs are initialized on admin_init
+ if ( Jetpack::is_active() && ! Jetpack_Options::get_option( 'first_admin_view', false ) ) {
+ Jetpack_Options::update_option( 'first_admin_view', true );
+ add_filter( 'jetpack_just_in_time_msgs', '__return_false' );
+ }
+ }
+
+ /**
+ * Add Jetpack Dashboard sub-link and point it to AAG if the user can view stats, manage modules or if Protect is active.
+ *
+ * Works in Dev Mode or when user is connected.
+ *
+ * @since 4.3.0
+ */
+ function jetpack_add_dashboard_sub_nav_item() {
+ if ( Jetpack::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' );
+ }
+ }
+ }
+
+ /**
+ * If user is allowed to see the Jetpack Admin, add Settings sub-link.
+ *
+ * @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' ) ) {
+ global $submenu;
+ $submenu['jetpack'][] = array( __( 'Settings', 'jetpack' ), 'jetpack_admin_page', 'admin.php?page=jetpack#/settings' );
+ }
+ }
+
+ function add_fallback_head_meta() {
+ echo '<meta http-equiv="refresh" content="0; url=?page=jetpack_modules">';
+ }
+
+ function add_noscript_head_meta() {
+ echo '<noscript>';
+ $this->add_fallback_head_meta();
+ echo '</noscript>';
+ }
+
+ function jetpack_menu_order( $menu_order ) {
+ $jp_menu_order = array();
+
+ foreach ( $menu_order as $index => $item ) {
+ if ( $item != 'jetpack' )
+ $jp_menu_order[] = $item;
+
+ if ( $index == 0 )
+ $jp_menu_order[] = 'jetpack';
+ }
+
+ return $jp_menu_order;
+ }
+
+ function page_render() {
+ /** This action is already documented in views/admin/admin-page.php */
+ do_action( 'jetpack_notices' );
+
+ // Try fetching by patch
+ $static_html = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static.html' );
+
+ if ( false === $static_html ) {
+
+ // If we still have nothing, display an error
+ echo '<p>';
+ esc_html_e( 'Error fetching static.html. Try running: ', 'jetpack' );
+ echo '<code>yarn distclean && yarn build</code>';
+ echo '</p>';
+ } else {
+
+ // We got the static.html so let's display it
+ echo $static_html;
+ }
+ }
+
+ /**
+ * Gets array of any Jetpack notices that have been dismissed.
+ *
+ * @since 4.0.1
+ * @return mixed|void
+ */
+ function get_dismissed_jetpack_notices() {
+ $jetpack_dismissed_notices = get_option( 'jetpack_dismissed_notices', array() );
+ /**
+ * Array of notices that have been dismissed.
+ *
+ * @since 4.0.1
+ *
+ * @param array $jetpack_dismissed_notices If empty, will not show any Jetpack notices.
+ */
+ $dismissed_notices = apply_filters( 'jetpack_dismissed_notices', $jetpack_dismissed_notices );
+ return $dismissed_notices;
+ }
+
+ function additional_styles() {
+ Jetpack_Admin_Page::load_wrapper_styles();
+ }
+
+ function page_admin_scripts() {
+ if ( $this->is_redirecting ) {
+ 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
+ );
+
+ if ( ! Jetpack::is_development_mode() && Jetpack::is_active() ) {
+ // Required for Analytics.
+ wp_enqueue_script( 'jp-tracks', '//stats.wp.com/w.js', array(), gmdate( 'YW' ), true );
+ }
+
+ // Add objects to be passed to the initial state of the app.
+ wp_localize_script( 'react-plugin', 'Initial_State', $this->get_initial_state() );
+ }
+
+ function get_initial_state() {
+ // Load API endpoint base classes and endpoints for getting the module list fed into the JS Admin Page
+ require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/class.jetpack-core-api-xmlrpc-consumer-endpoint.php';
+ require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php';
+ $moduleListEndpoint = new Jetpack_Core_API_Module_List_Endpoint();
+ $modules = $moduleListEndpoint->get_modules();
+
+ // Preparing translated fields for JSON encoding by transforming all HTML entities to
+ // respective characters.
+ foreach( $modules as $slug => $data ) {
+ $modules[ $slug ]['name'] = html_entity_decode( $data['name'] );
+ $modules[ $slug ]['description'] = html_entity_decode( $data['description'] );
+ $modules[ $slug ]['short_description'] = html_entity_decode( $data['short_description'] );
+ $modules[ $slug ]['long_description'] = html_entity_decode( $data['long_description'] );
+ }
+
+ // Collecting roles that can view site stats.
+ $stats_roles = array();
+ $enabled_roles = function_exists( 'stats_get_option' ) ? stats_get_option( 'roles' ) : array( 'administrator' );
+
+ if ( ! function_exists( 'get_editable_roles' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/user.php';
+ }
+ foreach ( get_editable_roles() as $slug => $role ) {
+ $stats_roles[ $slug ] = array(
+ 'name' => translate_user_role( $role['name'] ),
+ 'canView' => is_array( $enabled_roles ) ? in_array( $slug, $enabled_roles, true ) : false,
+ );
+ }
+
+ // Get information about current theme.
+ $current_theme = wp_get_theme();
+
+ // Get all themes that Infinite Scroll provides support for natively.
+ $inf_scr_support_themes = array();
+ foreach ( Jetpack::glob_php( JETPACK__PLUGIN_DIR . 'modules/infinite-scroll/themes' ) as $path ) {
+ if ( is_readable( $path ) ) {
+ $inf_scr_support_themes[] = basename( $path, '.php' );
+ }
+ }
+
+ // Get last post, to build the link to Customizer in the Related Posts module.
+ $last_post = get_posts( array( 'posts_per_page' => 1 ) );
+ $last_post = isset( $last_post[0] ) && $last_post[0] instanceof WP_Post
+ ? get_permalink( $last_post[0]->ID )
+ : get_home_url();
+
+ // Ensure that class to get the affiliate code is loaded
+ if ( ! class_exists( 'Jetpack_Affiliate' ) ) {
+ require_once JETPACK__PLUGIN_DIR . 'class.jetpack-affiliate.php';
+ }
+
+ return array(
+ 'WP_API_root' => esc_url_raw( rest_url() ),
+ 'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
+ 'pluginBaseUrl' => plugins_url( '', JETPACK__PLUGIN_FILE ),
+ 'connectionStatus' => array(
+ 'isActive' => Jetpack::is_active(),
+ 'isStaging' => Jetpack::is_staging_site(),
+ 'devMode' => array(
+ 'isActive' => Jetpack::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 ),
+ ),
+ 'isPublic' => '1' == get_option( 'blog_public' ),
+ 'isInIdentityCrisis' => Jetpack::validate_sync_error_idc_option(),
+ 'sandboxDomain' => JETPACK__SANDBOX_DOMAIN,
+ ),
+ 'connectUrl' => 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(
+ // data is populated asynchronously on page load
+ 'data' => array(
+ 'general' => false,
+ 'day' => false,
+ 'week' => false,
+ 'month' => false,
+ ),
+ 'roles' => $stats_roles,
+ ),
+ 'aff' => Jetpack_Affiliate::init()->get_affiliate_code(),
+ 'settings' => $this->get_flattened_settings( $modules ),
+ 'userData' => array(
+// 'othersLinked' => Jetpack::get_other_linked_admins(),
+ 'currentUser' => jetpack_current_user_data(),
+ ),
+ 'siteData' => array(
+ 'icon' => has_site_icon()
+ ? apply_filters( 'jetpack_photon_url', get_site_icon_url(), array( 'w' => 64 ) )
+ : '',
+ 'siteVisibleToSearchEngines' => '1' == get_option( 'blog_public' ),
+ /**
+ * Whether promotions are visible or not.
+ *
+ * @since 4.8.0
+ *
+ * @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(),
+ ),
+ 'themeData' => array(
+ 'name' => $current_theme->get( 'Name' ),
+ 'hasUpdate' => (bool) get_theme_update_available( $current_theme ),
+ 'support' => array(
+ 'infinite-scroll' => current_theme_supports( 'infinite-scroll' ) || in_array( $current_theme->get_stylesheet(), $inf_scr_support_themes ),
+ ),
+ ),
+ 'locale' => Jetpack::get_i18n_data_json(),
+ 'localeSlug' => join( '-', explode( '_', get_user_locale() ) ),
+ 'jetpackStateNotices' => array(
+ 'messageCode' => Jetpack::state( 'message' ),
+ 'errorCode' => Jetpack::state( 'error' ),
+ 'errorDescription' => Jetpack::state( 'error_description' ),
+ ),
+ '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()
+ );
+ }
+
+ function get_external_services_connect_urls() {
+ $connect_urls = array();
+ jetpack_require_lib( 'class.jetpack-keyring-service-helper' );
+ foreach ( Jetpack_Keyring_Service_Helper::$SERVICES as $service_name => $service_info ) {
+ $connect_urls[ $service_name ] = Jetpack_Keyring_Service_Helper::connect_url( $service_name, $service_info[ 'for' ] );
+ }
+ return $connect_urls;
+ }
+
+ /**
+ * Returns an array of modules and settings both as first class members of the object.
+ *
+ * @param array $modules the result of an API request to get all modules.
+ *
+ * @return array flattened settings with modules.
+ */
+ function get_flattened_settings( $modules ) {
+ $core_api_endpoint = new Jetpack_Core_API_Data();
+ $settings = $core_api_endpoint->get_all_options();
+ return $settings->data;
+ }
+}
+
+/*
+ * 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.
+ *
+ * @since 4.1.0
+ *
+ * @return array
+ */
+function jetpack_current_user_data() {
+ $current_user = wp_get_current_user();
+ $is_master_user = $current_user->ID == Jetpack_Options::get_option( 'master_user' );
+ $dotcom_data = Jetpack::get_connected_user_data();
+ // Add connected user gravatar to the returned dotcom_data.
+ $dotcom_data['avatar'] = get_avatar_url( $dotcom_data['email'], array( 'size' => 64, 'default' => 'mysteryman' ) );
+
+ $current_user_data = array(
+ 'isConnected' => Jetpack::is_user_connected( $current_user->ID ),
+ 'isMaster' => $is_master_user,
+ 'username' => $current_user->user_login,
+ 'id' => $current_user->ID,
+ 'wpcomUser' => $dotcom_data,
+ 'gravatar' => get_avatar( $current_user->ID, 40, 'mm', '', array( 'force_display' => true ) ),
+ 'permissions' => array(
+ 'admin_page' => current_user_can( 'jetpack_admin_page' ),
+ 'connect' => current_user_can( 'jetpack_connect' ),
+ 'disconnect' => current_user_can( 'jetpack_disconnect' ),
+ 'manage_modules' => current_user_can( 'jetpack_manage_modules' ),
+ 'network_admin' => current_user_can( 'jetpack_network_admin_page' ),
+ 'network_sites_page' => current_user_can( 'jetpack_network_sites_page' ),
+ 'edit_posts' => current_user_can( 'edit_posts' ),
+ 'publish_posts' => current_user_can( 'publish_posts' ),
+ 'manage_options' => current_user_can( 'manage_options' ),
+ 'view_stats' => current_user_can( 'view_stats' ),
+ 'manage_plugins' => current_user_can( 'install_plugins' )
+ && current_user_can( 'activate_plugins' )
+ && current_user_can( 'update_plugins' )
+ && current_user_can( 'delete_plugins' ),
+ ),
+ );
+
+ return $current_user_data;
+}
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php
new file mode 100644
index 00000000..69991c70
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php
@@ -0,0 +1,141 @@
+<?php
+include_once( 'class.jetpack-admin-page.php' );
+include_once( JETPACK__PLUGIN_DIR . 'class.jetpack-modules-list-table.php' );
+
+// Builds the settings page and its menu
+class Jetpack_Settings_Page extends Jetpack_Admin_Page {
+
+ // Show the settings page only when Jetpack is connected or in dev mode
+ protected $dont_show_if_not_active = true;
+
+ function add_page_actions( $hook ) {}
+
+ // Adds the Settings sub menu
+ function get_page_hook() {
+ return add_submenu_page(
+ null,
+ __( 'Jetpack Settings', 'jetpack' ),
+ __( 'Settings', 'jetpack' ),
+ 'jetpack_manage_modules',
+ 'jetpack_modules',
+ array( $this, 'render' )
+ );
+ }
+
+ // Renders the module list table where you can use bulk action or row
+ // actions to activate/deactivate and configure modules
+ function page_render() {
+ $list_table = new Jetpack_Modules_List_Table;
+
+ // We have static.html so let's continue trying to fetch the others
+ $noscript_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' );
+ $rest_api_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' );
+
+ $noscript_notice = str_replace(
+ '#HEADER_TEXT#',
+ esc_html__( 'You have JavaScript disabled', 'jetpack' ),
+ $noscript_notice
+ );
+ $noscript_notice = str_replace(
+ '#TEXT#',
+ esc_html__( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ),
+ $noscript_notice
+ );
+
+ $rest_api_notice = str_replace(
+ '#HEADER_TEXT#',
+ esc_html( __( 'WordPress REST API is disabled', 'jetpack' ) ),
+ $rest_api_notice
+ );
+ $rest_api_notice = str_replace(
+ '#TEXT#',
+ esc_html( __( "Enable WordPress REST API to unlock Jetpack's full potential!", 'jetpack' ) ),
+ $rest_api_notice
+ );
+
+ if ( ! $this->is_rest_api_enabled() ) {
+ echo $rest_api_notice;
+ }
+ echo $noscript_notice;
+ ?>
+
+ <div class="page-content configure">
+ <div class="frame top hide-if-no-js">
+ <div class="wrap">
+ <div class="manage-left">
+ <table class="table table-bordered fixed-top">
+ <thead>
+ <tr>
+ <th class="check-column"><input type="checkbox" class="checkall"></th>
+ <th colspan="2">
+ <?php $list_table->unprotected_display_tablenav( 'top' ); ?>
+ <span class="filter-search">
+ <button type="button" class="button">Filter</button>
+ </span>
+ </th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ </div><!-- /.wrap -->
+ </div><!-- /.frame -->
+ <div class="frame bottom">
+ <div class="wrap">
+ <div class="manage-right" style="display: none;">
+ <div class="bumper">
+ <form class="navbar-form" role="search">
+ <input type="hidden" name="page" value="jetpack_modules" />
+ <?php $list_table->search_box( __( 'Search', 'jetpack' ), 'srch-term' ); ?>
+ <p><?php esc_html_e( 'View:', 'jetpack' ); ?></p>
+ <div class="button-group filter-active">
+ <button type="button" class="button <?php if ( empty( $_GET['activated'] ) ) echo 'active'; ?>"><?php esc_html_e( 'All', 'jetpack' ); ?></button>
+ <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'true' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="true"><?php esc_html_e( 'Active', 'jetpack' ); ?></button>
+ <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'false' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="false"><?php esc_html_e( 'Inactive', 'jetpack' ); ?></button>
+ </div>
+ <p><?php esc_html_e( 'Sort by:', 'jetpack' ); ?></p>
+ <div class="button-group sort">
+ <button type="button" class="button <?php if ( empty( $_GET['sort_by'] ) ) echo 'active'; ?>" data-sort-by="name"><?php esc_html_e( 'Alphabetical', 'jetpack' ); ?></button>
+ <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'introduced' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="introduced" data-sort-order="reverse"><?php esc_html_e( 'Newest', 'jetpack' ); ?></button>
+ <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'sort' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="sort"><?php esc_html_e( 'Popular', 'jetpack' ); ?></button>
+ </div>
+ <p><?php esc_html_e( 'Show:', 'jetpack' ); ?></p>
+ <?php $list_table->views(); ?>
+ </form>
+ </div>
+ </div>
+ <div class="manage-left" style="width: 100%;">
+ <form class="jetpack-modules-list-table-form" onsubmit="return false;">
+ <table class="<?php echo implode( ' ', $list_table->get_table_classes() ); ?>">
+ <tbody id="the-list">
+ <?php $list_table->display_rows_or_placeholder(); ?>
+ </tbody>
+ </table>
+ </form>
+ </div>
+ </div><!-- /.wrap -->
+ </div><!-- /.frame -->
+ </div><!-- /.content -->
+ <?php
+
+ JetpackTracking::record_user_event( 'wpa_page_view', array( 'path' => 'old_settings' ) );
+ }
+
+ /**
+ * Load styles for static page.
+ *
+ * @since 4.3.0
+ */
+ function additional_styles() {
+ Jetpack_Admin_Page::load_wrapper_styles();
+ }
+
+ // Javascript logic specific to the list table
+ function page_admin_scripts() {
+ wp_enqueue_script(
+ 'jetpack-admin-js',
+ Jetpack::get_file_url_for_environment( '_inc/build/jetpack-admin.min.js', '_inc/jetpack-admin.js' ),
+ array( 'jquery' ),
+ JETPACK__VERSION
+ );
+ }
+}