Added login request
This commit is contained in:
23
backend/wordpress/wp-content/plugins/jetpack/3rd-party/3rd-party.php
vendored
Normal file
23
backend/wordpress/wp-content/plugins/jetpack/3rd-party/3rd-party.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Placeholder to load 3rd party plugin tweaks until a legit system
|
||||
* is architected
|
||||
*/
|
||||
|
||||
require_once( JETPACK__PLUGIN_DIR . '3rd-party/buddypress.php' );
|
||||
require_once( JETPACK__PLUGIN_DIR . '3rd-party/wpml.php' );
|
||||
require_once( JETPACK__PLUGIN_DIR . '3rd-party/bitly.php' );
|
||||
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' );
|
||||
require_once( JETPACK__PLUGIN_DIR . '3rd-party/woocommerce-services.php' );
|
||||
require_once( JETPACK__PLUGIN_DIR . '3rd-party/class.jetpack-amp-support.php' );
|
||||
50
backend/wordpress/wp-content/plugins/jetpack/3rd-party/bbpress.php
vendored
Normal file
50
backend/wordpress/wp-content/plugins/jetpack/3rd-party/bbpress.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
add_action( 'init', 'jetpack_bbpress_compat', 11 ); // Priority 11 needed to ensure sharing_display is loaded.
|
||||
|
||||
/**
|
||||
* Adds Jetpack + bbPress Compatibility filters.
|
||||
*
|
||||
* @author Brandon Kraft
|
||||
* @since 3.7.1
|
||||
*/
|
||||
function jetpack_bbpress_compat() {
|
||||
if ( function_exists( 'sharing_display' ) ) {
|
||||
add_filter( 'bbp_get_topic_content', 'sharing_display', 19 );
|
||||
add_action( 'bbp_template_after_single_forum', 'jetpack_sharing_bbpress' );
|
||||
add_action( 'bbp_template_after_single_topic', 'jetpack_sharing_bbpress' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Markdown support for bbpress post types.
|
||||
*
|
||||
* @author Brandon Kraft
|
||||
* @since 6.0.0
|
||||
*/
|
||||
if ( function_exists( 'bbp_get_topic_post_type' ) ) {
|
||||
add_post_type_support( bbp_get_topic_post_type(), 'wpcom-markdown' );
|
||||
add_post_type_support( bbp_get_reply_post_type(), 'wpcom-markdown' );
|
||||
add_post_type_support( bbp_get_forum_post_type(), 'wpcom-markdown' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Use Photon for all images in Topics and replies.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*/
|
||||
if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
|
||||
add_filter( 'bbp_get_topic_content', array( 'Jetpack_Photon', 'filter_the_content' ), 999999 );
|
||||
add_filter( 'bbp_get_reply_content', array( 'Jetpack_Photon', 'filter_the_content' ), 999999 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Jetpack "Sharing" buttons on bbPress 2.x forums/ topics/ lead topics/ replies.
|
||||
*
|
||||
* Determination if the sharing buttons should display on the post type is handled within sharing_display().
|
||||
*
|
||||
* @author David Decker
|
||||
* @since 3.7.0
|
||||
*/
|
||||
function jetpack_sharing_bbpress() {
|
||||
sharing_display( null, true );
|
||||
}
|
||||
20
backend/wordpress/wp-content/plugins/jetpack/3rd-party/beaverbuilder.php
vendored
Normal file
20
backend/wordpress/wp-content/plugins/jetpack/3rd-party/beaverbuilder.php
vendored
Normal file
@@ -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();
|
||||
34
backend/wordpress/wp-content/plugins/jetpack/3rd-party/bitly.php
vendored
Normal file
34
backend/wordpress/wp-content/plugins/jetpack/3rd-party/bitly.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Fixes issues with the Official Bitly for WordPress
|
||||
* https://wordpress.org/plugins/bitly/
|
||||
*/
|
||||
if( class_exists( 'Bitly' ) ) {
|
||||
|
||||
if( isset( $GLOBALS['bitly'] ) ) {
|
||||
if ( method_exists( $GLOBALS['bitly'], 'og_tags' ) ) {
|
||||
remove_action( 'wp_head', array( $GLOBALS['bitly'], 'og_tags' ) );
|
||||
}
|
||||
|
||||
add_action( 'wp_head', 'jetpack_bitly_og_tag', 100 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* jetpack_bitly_og_tag
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function jetpack_bitly_og_tag() {
|
||||
if( has_filter( 'wp_head', 'jetpack_og_tags') === false ) {
|
||||
// Add the bitly part again back if we don't have any jetpack_og_tags added
|
||||
if ( method_exists( $GLOBALS['bitly'], 'og_tags' ) ) {
|
||||
$GLOBALS['bitly']->og_tags();
|
||||
}
|
||||
} elseif ( isset( $GLOBALS['posts'] ) && $GLOBALS['posts'][0]->ID > 0 ) {
|
||||
printf( "<meta property=\"bitly:url\" content=\"%s\" /> \n", esc_attr( $GLOBALS['bitly']->get_bitly_link_for_post_id( $GLOBALS['posts'][0]->ID ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
9
backend/wordpress/wp-content/plugins/jetpack/3rd-party/buddypress.php
vendored
Normal file
9
backend/wordpress/wp-content/plugins/jetpack/3rd-party/buddypress.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
add_filter( 'bp_core_pre_avatar_handle_upload', 'blobphoto' );
|
||||
function blobphoto( $bool ) {
|
||||
|
||||
add_filter( 'jetpack_photon_skip_image', '__return_true' );
|
||||
|
||||
return $bool;
|
||||
}
|
||||
351
backend/wordpress/wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php
vendored
Normal file
351
backend/wordpress/wp-content/plugins/jetpack/3rd-party/class.jetpack-amp-support.php
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Manages compatibility with the amp-wp plugin
|
||||
*
|
||||
* @see https://github.com/Automattic/amp-wp
|
||||
*/
|
||||
class Jetpack_AMP_Support {
|
||||
|
||||
static function init() {
|
||||
if ( ! self::is_amp_request() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// enable stats
|
||||
if ( Jetpack::is_module_active( 'stats' ) ) {
|
||||
add_action( 'amp_post_template_footer', array( 'Jetpack_AMP_Support', 'add_stats_pixel' ) );
|
||||
}
|
||||
|
||||
// carousel
|
||||
add_filter( 'jp_carousel_maybe_disable', '__return_true' );
|
||||
|
||||
// sharing
|
||||
add_filter( 'sharing_enqueue_scripts', '__return_false' );
|
||||
add_filter( 'jetpack_sharing_counts', '__return_false' );
|
||||
add_filter( 'sharing_js', '__return_false' );
|
||||
add_filter( 'jetpack_sharing_display_markup', array( 'Jetpack_AMP_Support', 'render_sharing_html' ), 10, 2 );
|
||||
|
||||
// disable lazy images
|
||||
add_filter( 'lazyload_is_enabled', '__return_false' );
|
||||
|
||||
// disable imploding CSS
|
||||
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
|
||||
|
||||
// enforce freedom mode for videopress
|
||||
add_filter( 'videopress_shortcode_options', array( 'Jetpack_AMP_Support', 'videopress_enable_freedom_mode' ) );
|
||||
|
||||
// include Jetpack og tags when rendering native AMP head
|
||||
add_action( 'amp_post_template_head', array( 'Jetpack_AMP_Support', 'amp_post_jetpack_og_tags' ) );
|
||||
|
||||
// Post rendering changes for legacy AMP
|
||||
add_action( 'pre_amp_render_post', array( 'Jetpack_AMP_Support', 'amp_disable_the_content_filters' ) );
|
||||
|
||||
// Add post template metadata for legacy AMP
|
||||
add_filter( 'amp_post_template_metadata', array( 'Jetpack_AMP_Support', 'amp_post_template_metadata' ), 10, 2 );
|
||||
}
|
||||
|
||||
static function admin_init() {
|
||||
// disable Likes metabox for post editor if AMP canonical disabled
|
||||
add_filter( 'post_flair_disable', array( 'Jetpack_AMP_Support', 'is_amp_canonical' ), 99 );
|
||||
}
|
||||
|
||||
static function init_filter_jetpack_widgets() {
|
||||
if ( ! self::is_amp_request() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// widgets
|
||||
add_filter( 'jetpack_widgets_to_include', array( 'Jetpack_AMP_Support', 'filter_available_widgets' ) );
|
||||
}
|
||||
|
||||
static function is_amp_canonical() {
|
||||
return function_exists( 'amp_is_canonical' ) && amp_is_canonical();
|
||||
}
|
||||
|
||||
static function is_amp_request() {
|
||||
// can't use is_amp_endpoint() since it's not ready early enough in init.
|
||||
// is_amp_endpoint() implementation calls is_feed, which bails with a notice if plugins_loaded isn't finished
|
||||
// "Conditional query tags do not work before the query is run"
|
||||
$is_amp_request =
|
||||
defined( 'AMP__VERSION' )
|
||||
&&
|
||||
! is_admin() // this is necessary so that modules can still be enabled/disabled/configured as per normal via Jetpack admin
|
||||
&&
|
||||
function_exists( 'amp_is_canonical' ) // this is really just testing if the plugin exists
|
||||
&&
|
||||
(
|
||||
amp_is_canonical()
|
||||
||
|
||||
isset( $_GET[ amp_get_slug() ] )
|
||||
||
|
||||
( version_compare( AMP__VERSION, '1.0', '<' ) && self::has_amp_suffix() ) // after AMP 1.0, the amp suffix will no longer be supported
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns true if the current request should return valid AMP content.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param boolean $is_amp_request Is this request supposed to return valid AMP content?
|
||||
*/
|
||||
return apply_filters( 'jetpack_is_amp_request', $is_amp_request );
|
||||
}
|
||||
|
||||
static function has_amp_suffix() {
|
||||
$request_path = wp_parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
|
||||
return $request_path && preg_match( '#/amp/?$#i', $request_path );
|
||||
}
|
||||
|
||||
static function filter_available_widgets( $widgets ) {
|
||||
if ( self::is_amp_request() ) {
|
||||
$widgets = array_filter( $widgets, array( 'Jetpack_AMP_Support', 'is_supported_widget' ) );
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
static function is_supported_widget( $widget_path ) {
|
||||
return substr( $widget_path, -14 ) !== '/milestone.php';
|
||||
}
|
||||
|
||||
static function amp_disable_the_content_filters() {
|
||||
if ( defined( 'WPCOM') && WPCOM ) {
|
||||
add_filter( 'videopress_show_2015_player', '__return_true' );
|
||||
add_filter( 'protected_embeds_use_form_post', '__return_false' );
|
||||
remove_filter( 'the_title', 'widont' );
|
||||
}
|
||||
|
||||
remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'filter' ), 11 );
|
||||
remove_filter( 'pre_kses', array( 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ), 100 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Jetpack stats pixel.
|
||||
*
|
||||
* @since 6.2.1
|
||||
*/
|
||||
static function add_stats_pixel() {
|
||||
if ( ! has_action( 'wp_footer', 'stats_footer' ) ) {
|
||||
return;
|
||||
}
|
||||
stats_render_amp_footer( stats_build_view_data() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add publisher and image metadata to legacy AMP post.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $metadata Metadata array.
|
||||
* @param WP_Post $post Post.
|
||||
* @return array Modified metadata array.
|
||||
*/
|
||||
static function amp_post_template_metadata( $metadata, $post ) {
|
||||
if ( isset( $metadata['publisher'] ) && ! isset( $metadata['publisher']['logo'] ) ) {
|
||||
$metadata = self::add_site_icon_to_metadata( $metadata );
|
||||
}
|
||||
|
||||
if ( ! isset( $metadata['image'] ) ) {
|
||||
$metadata = self::add_image_to_metadata( $metadata, $post );
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add blavatar to legacy AMP post metadata.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $metadata Metadata.
|
||||
* @return array Metadata.
|
||||
*/
|
||||
static function add_site_icon_to_metadata( $metadata ) {
|
||||
$size = 60;
|
||||
|
||||
if ( function_exists( 'blavatar_domain' ) ) {
|
||||
$metadata['publisher']['logo'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => blavatar_url( blavatar_domain( site_url() ), 'img', $size, self::staticize_subdomain( 'https://wordpress.com/i/favicons/apple-touch-icon-60x60.png' ) ),
|
||||
'width' => $size,
|
||||
'height' => $size,
|
||||
);
|
||||
} else if ( $site_icon_url = Jetpack_Sync_Functions::site_icon_url( $size ) ) {
|
||||
$metadata['publisher']['logo'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => $site_icon_url,
|
||||
'width' => $size,
|
||||
'height' => $size,
|
||||
);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add image to legacy AMP post metadata.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $metadata Metadata.
|
||||
* @param WP_Post $post Post.
|
||||
* @return array Metadata.
|
||||
*/
|
||||
static function add_image_to_metadata( $metadata, $post ) {
|
||||
$image = Jetpack_PostImages::get_image( $post->ID, array(
|
||||
'fallback_to_avatars' => true,
|
||||
'avatar_size' => 200,
|
||||
// AMP already attempts these.
|
||||
'from_thumbnail' => false,
|
||||
'from_attachment' => false,
|
||||
) );
|
||||
|
||||
if ( empty( $image ) ) {
|
||||
return self::add_fallback_image_to_metadata( $metadata );
|
||||
}
|
||||
|
||||
if ( ! isset( $image['src_width'] ) ) {
|
||||
$dimensions = self::extract_image_dimensions_from_getimagesize( array(
|
||||
$image['src'] => false,
|
||||
) );
|
||||
|
||||
if ( false !== $dimensions[ $image['src'] ] ) {
|
||||
$image['src_width'] = $dimensions['width'];
|
||||
$image['src_height'] = $dimensions['height'];
|
||||
}
|
||||
}
|
||||
|
||||
$metadata['image'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => $image['src'],
|
||||
'width' => $image['src_width'],
|
||||
'height' => $image['src_height'],
|
||||
);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fallback image to legacy AMP post metadata.
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $metadata Metadata.
|
||||
* @return array Metadata.
|
||||
*/
|
||||
static function add_fallback_image_to_metadata( $metadata ) {
|
||||
/** This filter is documented in functions.opengraph.php */
|
||||
$default_image = apply_filters( 'jetpack_open_graph_image_default', 'https://wordpress.com/i/blank.jpg' );
|
||||
|
||||
$metadata['image'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => self::staticize_subdomain( $default_image ),
|
||||
'width' => 200,
|
||||
'height' => 200,
|
||||
);
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
static function staticize_subdomain( $domain ) {
|
||||
// deal with WPCOM vs Jetpack
|
||||
if ( function_exists( 'staticize_subdomain' ) ) {
|
||||
return staticize_subdomain( $domain );
|
||||
} else {
|
||||
return Jetpack::staticize_subdomain( $domain );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract image dimensions via wpcom/imagesize, only on WPCOM
|
||||
*
|
||||
* @since 6.2.0
|
||||
*
|
||||
* @param array $dimensions Dimensions.
|
||||
* @return array Dimensions.
|
||||
*/
|
||||
static function extract_image_dimensions_from_getimagesize( $dimensions ) {
|
||||
if ( ! ( defined('WPCOM') && WPCOM && function_exists( 'require_lib' ) ) ) {
|
||||
return $dimensions;
|
||||
}
|
||||
require_lib( 'wpcom/imagesize' );
|
||||
|
||||
foreach ( $dimensions as $url => $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
$result = wpcom_getimagesize( $url );
|
||||
if ( is_array( $result ) ) {
|
||||
$dimensions[ $url ] = array(
|
||||
'width' => $result[0],
|
||||
'height' => $result[1],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $dimensions;
|
||||
}
|
||||
|
||||
static function amp_post_jetpack_og_tags() {
|
||||
Jetpack::init()->check_open_graph();
|
||||
if ( function_exists( 'jetpack_og_tags' ) ) {
|
||||
jetpack_og_tags();
|
||||
}
|
||||
}
|
||||
|
||||
static function videopress_enable_freedom_mode( $options ) {
|
||||
$options['freedom'] = true;
|
||||
return $options;
|
||||
}
|
||||
|
||||
static function render_sharing_html( $markup, $sharing_enabled ) {
|
||||
remove_action( 'wp_footer', 'sharing_add_footer' );
|
||||
if ( empty( $sharing_enabled ) ) {
|
||||
return $markup;
|
||||
}
|
||||
$supported_services = array(
|
||||
'facebook' => array(
|
||||
/** This filter is documented in modules/sharedaddy/sharing-sources.php */
|
||||
'data-param-app_id' => apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ),
|
||||
),
|
||||
'twitter' => array(),
|
||||
'pinterest' => array(),
|
||||
'whatsapp' => array(),
|
||||
'google-plus-1' => array(
|
||||
'type' => 'gplus',
|
||||
),
|
||||
'tumblr' => array(),
|
||||
'linkedin' => array(),
|
||||
);
|
||||
$sharing_links = array();
|
||||
foreach ( $sharing_enabled['visible'] as $id => $service ) {
|
||||
if ( ! isset( $supported_services[ $id ] ) ) {
|
||||
$sharing_links[] = "<!-- not supported: $id -->";
|
||||
continue;
|
||||
}
|
||||
$args = array_merge(
|
||||
array(
|
||||
'type' => $id,
|
||||
),
|
||||
$supported_services[ $id ]
|
||||
);
|
||||
$sharing_link = '<amp-social-share';
|
||||
foreach ( $args as $key => $value ) {
|
||||
$sharing_link .= sprintf( ' %s="%s"', sanitize_key( $key ), esc_attr( $value ) );
|
||||
}
|
||||
$sharing_link .= '></amp-social-share>';
|
||||
$sharing_links[] = $sharing_link;
|
||||
}
|
||||
return preg_replace( '#(?<=<div class="sd-content">).+?(?=</div>)#s', implode( '', $sharing_links ), $markup );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'init', array( 'Jetpack_AMP_Support', 'init' ), 1 );
|
||||
|
||||
add_action( 'admin_init', array( 'Jetpack_AMP_Support', 'admin_init' ), 1 );
|
||||
|
||||
// this is necessary since for better or worse Jetpack modules and widget files are loaded during plugins_loaded, which means we must
|
||||
// take the opportunity to intercept initialisation before that point, either by adding explicit detection into the module,
|
||||
// or preventing it from loading in the first place (better for performance)
|
||||
add_action( 'plugins_loaded', array( 'Jetpack_AMP_Support', 'init_filter_jetpack_widgets' ), 1 );
|
||||
143
backend/wordpress/wp-content/plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php
vendored
Normal file
143
backend/wordpress/wp-content/plugins/jetpack/3rd-party/class.jetpack-modules-overrides.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<?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' ) || has_filter( '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() );
|
||||
|
||||
/** This filter is documented in class.jetpack.php */
|
||||
$filtered = apply_filters( 'jetpack_active_modules', $filtered );
|
||||
|
||||
$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 );
|
||||
|
||||
/** This filter is documented in class.jetpack.php */
|
||||
$filtered = apply_filters( 'jetpack_active_modules', $filtered );
|
||||
|
||||
$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();
|
||||
19
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar.php
vendored
Normal file
19
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar.php
vendored
Normal file
@@ -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' );
|
||||
154
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php
vendored
Normal file
154
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/class.jetpack-search-debug-bar.php
vendored
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
56
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/debug-bar.css
vendored
Normal file
56
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/debug-bar.css
vendored
Normal file
@@ -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;
|
||||
}
|
||||
22
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/debug-bar.js
vendored
Normal file
22
backend/wordpress/wp-content/plugins/jetpack/3rd-party/debug-bar/debug-bar.js
vendored
Normal file
@@ -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 );
|
||||
113
backend/wordpress/wp-content/plugins/jetpack/3rd-party/domain-mapping.php
vendored
Normal file
113
backend/wordpress/wp-content/plugins/jetpack/3rd-party/domain-mapping.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Jetpack_3rd_Party_Domain_Mapping
|
||||
*
|
||||
* This class contains methods that are used to provide compatibility between Jetpack sync and domain mapping plugins.
|
||||
*/
|
||||
class Jetpack_3rd_Party_Domain_Mapping {
|
||||
|
||||
/**
|
||||
* @var Jetpack_3rd_Party_Domain_Mapping
|
||||
**/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* An array of methods that are used to hook the Jetpack sync filters for home_url and site_url to a mapping plugin.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $test_methods = array(
|
||||
'hook_wordpress_mu_domain_mapping',
|
||||
'hook_wpmu_dev_domain_mapping'
|
||||
);
|
||||
|
||||
static function init() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new Jetpack_3rd_Party_Domain_Mapping;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function __construct() {
|
||||
add_action( 'plugins_loaded', array( $this, 'attempt_to_hook_domain_mapping_plugins' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called on the plugins_loaded action and will loop through the $test_methods
|
||||
* to try and hook a domain mapping plugin to the Jetpack sync filters for the home_url and site_url callables.
|
||||
*/
|
||||
function attempt_to_hook_domain_mapping_plugins() {
|
||||
if ( ! Jetpack_Constants::is_defined( 'SUNRISE' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hooked = false;
|
||||
$count = count( self::$test_methods );
|
||||
for ( $i = 0; $i < $count && ! $hooked; $i++ ) {
|
||||
$hooked = call_user_func( array( $this, self::$test_methods[ $i ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will test for a constant and function that are known to be used with Donncha's WordPress MU
|
||||
* Domain Mapping plugin. If conditions are met, we hook the domain_mapping_siteurl() function to Jetpack sync
|
||||
* filters for home_url and site_url callables.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hook_wordpress_mu_domain_mapping() {
|
||||
if ( ! Jetpack_Constants::is_defined( 'SUNRISE_LOADED' ) || ! $this->function_exists( 'domain_mapping_siteurl' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
add_filter( 'jetpack_sync_home_url', 'domain_mapping_siteurl' );
|
||||
add_filter( 'jetpack_sync_site_url', 'domain_mapping_siteurl' );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will test for a class and method known to be used in WPMU Dev's domain mapping plugin. If the
|
||||
* method exists, then we'll hook the swap_to_mapped_url() to our Jetpack sync filters for home_url and site_url.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function hook_wpmu_dev_domain_mapping() {
|
||||
if ( ! $this->class_exists( 'domain_map' ) || ! $this->method_exists( 'domain_map', 'utils' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$utils = $this->get_domain_mapping_utils_instance();
|
||||
add_filter( 'jetpack_sync_home_url', array( $utils, 'swap_to_mapped_url' ) );
|
||||
add_filter( 'jetpack_sync_site_url', array( $utils, 'swap_to_mapped_url' ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility Methods
|
||||
*
|
||||
* These methods are very minimal, and in most cases, simply pass on arguments. Why create them you ask?
|
||||
* So that we can test.
|
||||
*/
|
||||
|
||||
public function method_exists( $class, $method ) {
|
||||
return method_exists( $class, $method );
|
||||
}
|
||||
|
||||
public function class_exists( $class ) {
|
||||
return class_exists( $class );
|
||||
}
|
||||
|
||||
public function function_exists( $function ) {
|
||||
return function_exists( $function );
|
||||
}
|
||||
|
||||
public function get_domain_mapping_utils_instance() {
|
||||
return domain_map::utils();
|
||||
}
|
||||
}
|
||||
|
||||
Jetpack_3rd_Party_Domain_Mapping::init();
|
||||
7
backend/wordpress/wp-content/plugins/jetpack/3rd-party/polldaddy.php
vendored
Normal file
7
backend/wordpress/wp-content/plugins/jetpack/3rd-party/polldaddy.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
class Jetpack_Sync {
|
||||
static function sync_options() {
|
||||
_deprecated_function( __METHOD__, 'jetpack-4.2', 'jetpack_options_whitelist filter' );
|
||||
}
|
||||
}
|
||||
19
backend/wordpress/wp-content/plugins/jetpack/3rd-party/qtranslate-x.php
vendored
Normal file
19
backend/wordpress/wp-content/plugins/jetpack/3rd-party/qtranslate-x.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Prevent qTranslate X from redirecting REST calls.
|
||||
*
|
||||
* @since 5.3
|
||||
*
|
||||
* @param string $url_lang Language URL to redirect to.
|
||||
* @param string $url_orig Original URL.
|
||||
* @param array $url_info Pieces of original URL.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function jetpack_no_qtranslate_rest_url_redirect( $url_lang, $url_orig, $url_info ) {
|
||||
if ( false !== strpos( $url_info['wp-path'], 'wp-json/jetpack' ) ) {
|
||||
return false;
|
||||
}
|
||||
return $url_lang;
|
||||
}
|
||||
add_filter( 'qtranslate_language_detect_redirect', 'jetpack_no_qtranslate_rest_url_redirect', 10, 3 );
|
||||
42
backend/wordpress/wp-content/plugins/jetpack/3rd-party/vaultpress.php
vendored
Normal file
42
backend/wordpress/wp-content/plugins/jetpack/3rd-party/vaultpress.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Notify user that VaultPress has been disabled. Hide VaultPress notice that requested attention.
|
||||
*
|
||||
* @since 5.8
|
||||
*/
|
||||
function jetpack_vaultpress_rewind_enabled_notice() {
|
||||
// The deactivation is performed here because there may be pages that admin_init runs on,
|
||||
// such as admin_ajax, that could deactivate the plugin without showing this notification.
|
||||
deactivate_plugins( 'vaultpress/vaultpress.php' );
|
||||
|
||||
// Remove WP core notice that says that the plugin was activated.
|
||||
if ( isset( $_GET['activate'] ) ) {
|
||||
unset( $_GET['activate'] );
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
<style>#vp-notice{display:none;}</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* If Rewind is enabled, remove its entry in sidebar, deactivate VaultPress, and show a notification.
|
||||
*
|
||||
* @since 5.8
|
||||
*/
|
||||
function jetpack_vaultpress_rewind_check() {
|
||||
if ( Jetpack::is_active() &&
|
||||
Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) &&
|
||||
Jetpack::is_rewind_enabled()
|
||||
) {
|
||||
remove_submenu_page( 'jetpack', 'vaultpress' );
|
||||
|
||||
add_action( 'admin_notices', 'jetpack_vaultpress_rewind_enabled_notice' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'jetpack_vaultpress_rewind_check', 11 );
|
||||
133
backend/wordpress/wp-content/plugins/jetpack/3rd-party/woocommerce-services.php
vendored
Normal file
133
backend/wordpress/wp-content/plugins/jetpack/3rd-party/woocommerce-services.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class WC_Services_Installer {
|
||||
|
||||
/**
|
||||
* @var Jetpack
|
||||
**/
|
||||
private $jetpack;
|
||||
|
||||
/**
|
||||
* @var WC_Services_Installer
|
||||
**/
|
||||
private static $instance = null;
|
||||
|
||||
static function init() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new WC_Services_Installer();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->jetpack = Jetpack::init();
|
||||
|
||||
add_action( 'admin_init', array( $this, 'add_error_notice' ) );
|
||||
add_action( 'admin_init', array( $this, 'try_install' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the intent to install WooCommerce Services, and kick off installation.
|
||||
*/
|
||||
public function try_install() {
|
||||
if ( ! isset( $_GET['wc-services-action'] ) ) {
|
||||
return;
|
||||
}
|
||||
check_admin_referer( 'wc-services-install' );
|
||||
|
||||
$result = false;
|
||||
|
||||
switch ( $_GET['wc-services-action'] ) {
|
||||
case 'install':
|
||||
if ( current_user_can( 'install_plugins' ) ) {
|
||||
$this->jetpack->stat( 'jitm', 'wooservices-install-' . JETPACK__VERSION );
|
||||
$result = $this->install();
|
||||
if ( $result ) {
|
||||
$result = $this->activate();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'activate':
|
||||
if ( current_user_can( 'activate_plugins' ) ) {
|
||||
$this->jetpack->stat( 'jitm', 'wooservices-activate-' . JETPACK__VERSION );
|
||||
$result = $this->activate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$redirect = isset( $_GET['redirect'] ) ? admin_url( $_GET['redirect'] ) : wp_get_referer();
|
||||
|
||||
if ( $result ) {
|
||||
$this->jetpack->stat( 'jitm', 'wooservices-activated-' . JETPACK__VERSION );
|
||||
} else {
|
||||
$redirect = add_query_arg( 'wc-services-install-error', true, $redirect );
|
||||
}
|
||||
|
||||
wp_safe_redirect( $redirect );
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up installation error admin notice.
|
||||
*/
|
||||
public function add_error_notice() {
|
||||
if ( ! empty( $_GET['wc-services-install-error'] ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'error_notice' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the user that the installation of WooCommerce Services failed.
|
||||
*/
|
||||
public function error_notice() {
|
||||
?>
|
||||
<div class="notice notice-error is-dismissible">
|
||||
<p><?php _e( 'There was an error installing WooCommerce Services.', 'jetpack' ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and install the WooCommerce Services plugin.
|
||||
*
|
||||
* @return bool result of installation
|
||||
*/
|
||||
private function install() {
|
||||
include_once( ABSPATH . '/wp-admin/includes/admin.php' );
|
||||
include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' );
|
||||
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
||||
include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
|
||||
include_once( ABSPATH . '/wp-admin/includes/class-plugin-upgrader.php' );
|
||||
|
||||
$api = plugins_api( 'plugin_information', array( 'slug' => 'woocommerce-services' ) );
|
||||
|
||||
if ( is_wp_error( $api ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
|
||||
$result = $upgrader->install( $api->download_link );
|
||||
|
||||
return true === $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the WooCommerce Services plugin.
|
||||
*
|
||||
* @return bool result of activation
|
||||
*/
|
||||
private function activate() {
|
||||
$result = activate_plugin( 'woocommerce-services/woocommerce-services.php' );
|
||||
|
||||
// activate_plugin() returns null on success
|
||||
return is_null( $result );
|
||||
}
|
||||
}
|
||||
|
||||
WC_Services_Installer::init();
|
||||
95
backend/wordpress/wp-content/plugins/jetpack/3rd-party/woocommerce.php
vendored
Normal file
95
backend/wordpress/wp-content/plugins/jetpack/3rd-party/woocommerce.php
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* This file contains compatibility functions for WooCommerce to improve Jetpack feature support.
|
||||
*/
|
||||
add_action( 'woocommerce_init', 'jetpack_woocommerce_integration' );
|
||||
|
||||
function jetpack_woocommerce_integration() {
|
||||
/**
|
||||
* Double check WooCommerce exists - unlikely to fail due to the hook being used but better safe than sorry.
|
||||
*/
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_share', 'jetpack_woocommerce_social_share_icons', 10 );
|
||||
|
||||
/**
|
||||
* Wrap in function exists check since this requires WooCommerce 3.3+.
|
||||
*/
|
||||
if ( function_exists( 'wc_get_default_products_per_row' ) ) {
|
||||
add_filter( 'infinite_scroll_render_callbacks', 'jetpack_woocommerce_infinite_scroll_render_callback', 10 );
|
||||
add_action( 'wp_enqueue_scripts', 'jetpack_woocommerce_infinite_scroll_style', 10 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure the social sharing icons show up under the product's short description
|
||||
*/
|
||||
function jetpack_woocommerce_social_share_icons() {
|
||||
if ( function_exists( 'sharing_display' ) ) {
|
||||
remove_filter( 'the_content', 'sharing_display', 19 );
|
||||
remove_filter( 'the_excerpt', 'sharing_display', 19 );
|
||||
echo sharing_display();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sharing display from account, cart, and checkout pages in WooCommerce.
|
||||
*/
|
||||
function jetpack_woocommerce_remove_share() {
|
||||
/**
|
||||
* Double check WooCommerce exists - unlikely to fail due to the hook being used but better safe than sorry.
|
||||
*/
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_cart() || is_checkout() || is_account_page() ) {
|
||||
remove_filter( 'the_content', 'sharing_display', 19 );
|
||||
if ( class_exists( 'Jetpack_Likes' ) ) {
|
||||
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'loop_start', 'jetpack_woocommerce_remove_share' );
|
||||
|
||||
/**
|
||||
* Add a callback for WooCommerce product rendering in infinite scroll.
|
||||
*
|
||||
* @param array $callbacks
|
||||
* @return array
|
||||
*/
|
||||
function jetpack_woocommerce_infinite_scroll_render_callback( $callbacks ) {
|
||||
$callbacks[] = 'jetpack_woocommerce_infinite_scroll_render';
|
||||
return $callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a default renderer for WooCommerce products within infinite scroll.
|
||||
*/
|
||||
function jetpack_woocommerce_infinite_scroll_render() {
|
||||
if ( ! is_shop() && ! is_product_taxonomy() && ! is_product_category() && ! is_product_tag() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
woocommerce_product_loop_start();
|
||||
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
wc_get_template_part( 'content', 'product' );
|
||||
}
|
||||
|
||||
woocommerce_product_loop_end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic styling when infinite scroll is active only.
|
||||
*/
|
||||
function jetpack_woocommerce_infinite_scroll_style() {
|
||||
$custom_css = "
|
||||
.infinite-scroll .woocommerce-pagination {
|
||||
display: none;
|
||||
}";
|
||||
wp_add_inline_style( 'woocommerce-layout', $custom_css );
|
||||
}
|
||||
62
backend/wordpress/wp-content/plugins/jetpack/3rd-party/wpml.php
vendored
Normal file
62
backend/wordpress/wp-content/plugins/jetpack/3rd-party/wpml.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Only load these if WPML plugin is installed and active.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load routines only if WPML is loaded.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
function wpml_jetpack_init() {
|
||||
add_action( 'jetpack_widget_get_top_posts', 'wpml_jetpack_widget_get_top_posts', 10, 3 );
|
||||
add_filter( 'grunion_contact_form_field_html', 'grunion_contact_form_field_html_filter', 10, 3 );
|
||||
}
|
||||
add_action( 'wpml_loaded', 'wpml_jetpack_init' );
|
||||
|
||||
/**
|
||||
* Filter the Top Posts and Pages by language.
|
||||
*
|
||||
* @param array $posts Array of the most popular posts.
|
||||
* @param array $post_ids Array of Post IDs.
|
||||
* @param string $count Number of Top Posts we want to display.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wpml_jetpack_widget_get_top_posts( $posts, $post_ids, $count ) {
|
||||
global $sitepress;
|
||||
|
||||
foreach ( $posts as $k => $post ) {
|
||||
$lang_information = wpml_get_language_information( $post['post_id'] );
|
||||
if ( ! is_wp_error( $lang_information ) ) {
|
||||
$post_language = substr( $lang_information['locale'], 0, 2 );
|
||||
if ( $post_language !== $sitepress->get_current_language() ) {
|
||||
unset( $posts[ $k ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the HTML of the Contact Form and output the one requested by language.
|
||||
*
|
||||
* @param string $r Contact Form HTML output.
|
||||
* @param string $field_label Field label.
|
||||
* @param int|null $id Post ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function grunion_contact_form_field_html_filter( $r, $field_label, $id ){
|
||||
global $sitepress;
|
||||
|
||||
if ( function_exists( 'icl_translate' ) ) {
|
||||
if ( $sitepress->get_current_language() !== $sitepress->get_default_language() ) {
|
||||
$label_translation = icl_translate( 'jetpack ', $field_label . '_label', $field_label );
|
||||
$r = str_replace( $field_label, $label_translation, $r );
|
||||
}
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
Reference in New Issue
Block a user