diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2018-03-10 19:17:40 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2018-03-10 19:17:40 -0500 |
commit | 1ede1db458d07b50cfede5937958cb20752df616 (patch) | |
tree | b7484d24649fb07b8a591148ada617b14d8bbc6d /plugins/jetpack/3rd-party | |
parent | Update akismet 4.0.3 (diff) | |
download | blogs-gentoo-1ede1db458d07b50cfede5937958cb20752df616.tar.gz blogs-gentoo-1ede1db458d07b50cfede5937958cb20752df616.tar.bz2 blogs-gentoo-1ede1db458d07b50cfede5937958cb20752df616.zip |
Update jetpack 5.9
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/3rd-party')
-rw-r--r-- | plugins/jetpack/3rd-party/3rd-party.php | 6 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/beaverbuilder.php | 20 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php | 137 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/debug-bar.php | 19 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php | 154 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/debug-bar/debug-bar.css | 56 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/debug-bar/debug-bar.js | 22 | ||||
-rw-r--r-- | plugins/jetpack/3rd-party/vaultpress.php | 26 |
8 files changed, 439 insertions, 1 deletions
diff --git a/plugins/jetpack/3rd-party/3rd-party.php b/plugins/jetpack/3rd-party/3rd-party.php index 04b3e2da..9aeb8364 100644 --- a/plugins/jetpack/3rd-party/3rd-party.php +++ b/plugins/jetpack/3rd-party/3rd-party.php @@ -1,6 +1,6 @@ <?php -/* +/** * Placeholder to load 3rd party plugin tweaks until a legit system * is architected */ @@ -12,6 +12,10 @@ require_once( JETPACK__PLUGIN_DIR . '3rd-party/bbpress.php' ); require_once( JETPACK__PLUGIN_DIR . '3rd-party/woocommerce.php' ); require_once( JETPACK__PLUGIN_DIR . '3rd-party/domain-mapping.php' ); require_once( JETPACK__PLUGIN_DIR . '3rd-party/qtranslate-x.php' ); +require_once( JETPACK__PLUGIN_DIR . '3rd-party/vaultpress.php' ); +require_once( JETPACK__PLUGIN_DIR . '3rd-party/beaverbuilder.php' ); +require_once( JETPACK__PLUGIN_DIR . '3rd-party/debug-bar.php' ); +require_once( JETPACK__PLUGIN_DIR . '3rd-party/class.jetpack-modules-overrides.php' ); // We can't load this conditionally since polldaddy add the call in class constuctor. require_once( JETPACK__PLUGIN_DIR . '3rd-party/polldaddy.php' ); diff --git a/plugins/jetpack/3rd-party/beaverbuilder.php b/plugins/jetpack/3rd-party/beaverbuilder.php new file mode 100644 index 00000000..b3215ca2 --- /dev/null +++ b/plugins/jetpack/3rd-party/beaverbuilder.php @@ -0,0 +1,20 @@ +<?php +/** + * Beaverbuilder Compatibility. + */ +class Jetpack_BeaverBuilderCompat { + + function __construct() { + add_action( 'init', array( $this, 'beaverbuilder_refresh' ) ); + } + + /** + * If masterbar module is active force BeaverBuilder to refresh when publishing a layout. + */ + function beaverbuilder_refresh() { + if ( Jetpack::is_module_active( 'masterbar' ) ) { + add_filter( 'fl_builder_should_refresh_on_publish', '__return_true' ); + } + } +} +new Jetpack_BeaverBuilderCompat(); diff --git a/plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php b/plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php new file mode 100644 index 00000000..3d5a06ba --- /dev/null +++ b/plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php @@ -0,0 +1,137 @@ +<?php + +/** + * Provides methods for dealing with module overrides. + * + * @since 5.9.0 + */ +class Jetpack_Modules_Overrides { + /** + * Used to cache module overrides so that we minimize how many times we appy the + * option_jetpack_active_modules filter. + * + * @var null|array + */ + private $overrides = null; + + /** + * Clears the $overrides member used for caching. + * + * Since get_overrides() can be passed a falsey value to skip caching, this is probably + * most useful for clearing cache between tests. + * + * @return void + */ + public function clear_cache() { + $this->overrides = null; + } + + /** + * Returns true if there is a filter on the jetpack_active_modules option. + * + * @return bool Whether there is a filter on the jetpack_active_modules option. + */ + public function do_overrides_exist() { + return (bool) has_filter( 'option_jetpack_active_modules' ); + } + + /** + * Gets the override for a given module. + * + * @param string $module_slug The module's slug. + * @param boolean $use_cache Whether or not cached overrides should be used. + * + * @return bool|string False if no override for module. 'active' or 'inactive' if there is an override. + */ + public function get_module_override( $module_slug, $use_cache = true ) { + $overrides = $this->get_overrides( $use_cache ); + + if ( ! isset( $overrides[ $module_slug ] ) ) { + return false; + } + + return $overrides[ $module_slug ]; + } + + /** + * Returns an array of module overrides where the key is the module slug and the value + * is true if the module is forced on and false if the module is forced off. + * + * @param bool $use_cache Whether or not cached overrides should be used. + * + * @return array The array of module overrides. + */ + public function get_overrides( $use_cache = true ) { + if ( $use_cache && ! is_null( $this->overrides ) ) { + return $this->overrides; + } + + if ( ! $this->do_overrides_exist() ) { + return array(); + } + + $available_modules = Jetpack::get_available_modules(); + + /** + * First, let's get all modules that have been forced on. + */ + + /** This filter is documented in wp-includes/option.php */ + $filtered = apply_filters( 'option_jetpack_active_modules', array() ); + + $forced_on = array_diff( $filtered, array() ); + + /** + * Second, let's get all modules forced off. + */ + + /** This filter is documented in wp-includes/option.php */ + $filtered = apply_filters( 'option_jetpack_active_modules', $available_modules ); + + $forced_off = array_diff( $available_modules, $filtered ); + + /** + * Last, build the return value. + */ + $return_value = array(); + foreach ( $forced_on as $on ) { + $return_value[ $on ] = 'active'; + } + + foreach ( $forced_off as $off ) { + $return_value[ $off ] = 'inactive'; + } + + $this->overrides = $return_value; + + return $return_value; + } + + /** + * A reference to an instance of this class. + * + * @var Jetpack_Modules_Overrides + */ + private static $instance = null; + + /** + * Returns the singleton instance of Jetpack_Modules_Overrides + * + * @return Jetpack_Modules_Overrides + */ + public static function instance() { + if ( is_null( self::$instance ) ) { + self::$instance = new Jetpack_Modules_Overrides(); + } + + return self::$instance; + } + + /** + * Private construct to enforce singleton. + */ + private function __construct() { + } +} + +Jetpack_Modules_Overrides::instance(); diff --git a/plugins/jetpack/3rd-party/debug-bar.php b/plugins/jetpack/3rd-party/debug-bar.php new file mode 100644 index 00000000..a6449903 --- /dev/null +++ b/plugins/jetpack/3rd-party/debug-bar.php @@ -0,0 +1,19 @@ +<?php + +/** + * Checks if the search module is active, and if so, will initialize the singleton instance + * of Jetpack_Search_Debug_Bar and add it to the array of debug bar panels. + * + * @param array $panels The array of debug bar panels. + * @return array $panel The array of debug bar panels with our added panel. + */ +function init_jetpack_search_debug_bar( $panels ) { + if ( ! Jetpack::is_module_active( 'search' ) ) { + return $panels; + } + + require_once dirname( __FILE__ ) . '/debug-bar/class.jetpack-search-debug-bar.php'; + $panels[] = Jetpack_Search_Debug_Bar::instance(); + return $panels; +} +add_filter( 'debug_bar_panels', 'init_jetpack_search_debug_bar' ); diff --git a/plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php b/plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php new file mode 100644 index 00000000..5d00c5a0 --- /dev/null +++ b/plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php @@ -0,0 +1,154 @@ +<?php + +/** + * Singleton class instantiated by Jetpack_Searc_Debug_Bar::instance() that handles + * rendering the Jetpack Search debug bar menu item and panel. + */ +class Jetpack_Search_Debug_Bar extends Debug_Bar_Panel { + /** + * Holds singleton instance + * + * @var Jetpack_Search_Debug_Bar + */ + protected static $instance = null; + + /** + * The title to use in the debug bar navigation + * + * @var string + */ + public $title; + + /** + * Constructor + */ + public function __construct() { + $this->title( esc_html__( 'Jetpack Search', 'jetpack' ) ); + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + } + + /** + * Returns the singleton instance of Jetpack_Search_Debug_Bar + * + * @return Jetpack_Search_Debug_Bar + */ + public static function instance() { + if ( is_null( self::$instance ) ) { + self::$instance = new Jetpack_Search_Debug_Bar(); + } + return self::$instance; + } + + /** + * Enqueues styles for our panel in the debug bar + * + * @return void + */ + public function enqueue_scripts() { + wp_enqueue_style( + 'jetpack-search-debug-bar', + plugins_url( '3rd-party/debug-bar/debug-bar.css', JETPACK__PLUGIN_FILE ) + ); + wp_enqueue_script( + 'jetpack-search-debug-bar', + plugins_url( '3rd-party/debug-bar/debug-bar.js', JETPACK__PLUGIN_FILE ), + array( 'jquery' ) + ); + } + + /** + * Should the Jetpack Search Debug Bar show? + * + * Since we've previously done a check for the search module being activated, let's just return true. + * Later on, we can update this to only show when `is_search()` is true. + * + * @return boolean + */ + public function is_visible() { + return true; + } + + /** + * Renders the panel content + * + * @return void + */ + public function render() { + if ( ! class_exists( 'Jetpack_Search' ) ) { + return; + } + + $jetpack_search = Jetpack_Search::instance(); + $last_query_info = $jetpack_search->get_last_query_info(); + + // If not empty, let's reshuffle the order of some things. + if ( ! empty( $last_query_info ) ) { + $args = $last_query_info['args']; + $response = $last_query_info['response']; + $response_code = $last_query_info['response_code']; + + unset( $last_query_info['args'] ); + unset( $last_query_info['response'] ); + unset( $last_query_info['response_code'] ); + + if ( is_null( $last_query_info['es_time'] ) ) { + $last_query_info['es_time'] = esc_html_x( + 'cache hit', + 'displayed in search results when results are cached', + 'jetpack' + ); + } + + $temp = array_merge( + array( 'response_code' => $response_code ), + array( 'args' => $args ), + $last_query_info, + array( 'response' => $response ) + ); + + $last_query_info = $temp; + } + ?> + <div class="jetpack-search-debug-bar"> + <h2><?php esc_html_e( 'Last query information:', 'jetpack' ); ?></h2> + <?php if ( empty( $last_query_info ) ) : ?> + <?php echo esc_html_x( 'None', 'Text displayed when there is no information', 'jetpack' ); ?> + <?php + else : + foreach ( $last_query_info as $key => $info ) : + ?> + <h3><?php echo esc_html( $key ); ?></h3> + <?php + if ( 'response' !== $key && 'args' !== $key ) : + ?> + <pre><?php print_r( esc_html( $info ) ); ?></pre> + <?php + else : + $this->render_json_toggle( $info ); + endif; + ?> + <?php + endforeach; + endif; + ?> + </div><!-- Closes .jetpack-search-debug-bar --> + <?php + } + + /** + * Responsible for rendering the HTML necessary for the JSON toggle + * + * @param array $value The resonse from the API as an array. + * @return void + */ + public function render_json_toggle( $value ) { + ?> + <div class="json-toggle-wrap"> + <pre class="json"><?php echo wp_json_encode( $value ); ?></pre> + <span class="pretty toggle"><?php echo esc_html_x( 'Pretty', 'label for formatting JSON', 'jetpack' ); ?></span> + <span class="ugly toggle"><?php echo esc_html_x( 'Minify', 'label for formatting JSON', 'jetpack' ); ?></span> + </div> + <?php + } +} diff --git a/plugins/jetpack/3rd-party/debug-bar/debug-bar.css b/plugins/jetpack/3rd-party/debug-bar/debug-bar.css new file mode 100644 index 00000000..2cc922c4 --- /dev/null +++ b/plugins/jetpack/3rd-party/debug-bar/debug-bar.css @@ -0,0 +1,56 @@ +.jetpack-search-debug-bar h2, +.qm-debug-bar-output .jetpack-search-debug-bar h2 { + float: none !important; + padding: 0 !important; + text-align: left !important; +} + +.qm-debug-bar-output .jetpack-search-debug-bar h2 { + margin-top: 1em !important; +} + +.qm-debug-bar-output .jetpack-search-debug-bar h2:first-child { + margin-top: .5em !important; +} + +.debug-menu-target h3 { + padding-top: 0 +} + +.jetpack-search-debug-output-toggle .print-r { + display: none; +} + +.json-toggle-wrap { + position: relative; +} + +.json-toggle-wrap .toggle { + position: absolute; + bottom: 10px; + right: 10px; + background: #fff; + border: 1px solid #000; + cursor: pointer; + padding: 2px 4px; +} + +.json-toggle-wrap .ugly { + display: none; +} + +.json-toggle-wrap.pretty .pretty { + display: none; +} + +.json-toggle-wrap.pretty .ugly { + display: inline; +} + +.jetpack-search-debug-bar pre { + white-space: pre-wrap; + white-space: -moz-pre-wrap; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + word-wrap: break-word; +} diff --git a/plugins/jetpack/3rd-party/debug-bar/debug-bar.js b/plugins/jetpack/3rd-party/debug-bar/debug-bar.js new file mode 100644 index 00000000..5043cf10 --- /dev/null +++ b/plugins/jetpack/3rd-party/debug-bar/debug-bar.js @@ -0,0 +1,22 @@ +/* global jQuery, JSON */ + +( function( $ ) { + $( document ).ready( function() { + $( '.jetpack-search-debug-bar .json-toggle-wrap .toggle' ).click( function() { + var t = $( this ), + wrap = t.closest( '.json-toggle-wrap' ), + pre = wrap.find( 'pre' ), + content = pre.text(), + isPretty = wrap.hasClass( 'pretty' ); + + if ( ! isPretty ) { + pre.text( JSON.stringify( JSON.parse( content ), null, 2 ) ); + } else { + content.replace( '\t', '' ).replace( '\n', '' ).replace( ' ', '' ); + pre.text( JSON.stringify( JSON.parse( content ) ) ); + } + + wrap.toggleClass( 'pretty' ); + } ); + } ); +} )( jQuery ); diff --git a/plugins/jetpack/3rd-party/vaultpress.php b/plugins/jetpack/3rd-party/vaultpress.php new file mode 100644 index 00000000..b1c1cfd7 --- /dev/null +++ b/plugins/jetpack/3rd-party/vaultpress.php @@ -0,0 +1,26 @@ +<?php + +function jetpack_vaultpress_rewind_enabled_notice() { + $plugin_file = 'vaultpress/vaultpress.php'; + + deactivate_plugins( $plugin_file ); + ?> + <div class="notice notice-success vp-deactivated"> + <h2 style="margin-bottom: 0.25em;"><?php _e( 'Jetpack is now handling your backups.', 'jetpack' ); ?></h2> + <p><?php _e( 'VaultPress is no longer needed and has been deactivated.', 'jetpack' ); ?></p> + </div> + <?php +} + +// If Rewind is enabled, then show a notification to disable VaultPress. +function jetpack_vaultpress_rewind_check() { + if ( Jetpack::is_active() && + Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) && + Jetpack::is_rewind_enabled() + ) { + add_action( 'admin_notices', 'jetpack_vaultpress_rewind_enabled_notice' ); + } +} + + +add_action( 'admin_init', 'jetpack_vaultpress_rewind_check', 11 );
\ No newline at end of file |