-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2052 from Automattic/add/jetpack-9.6
Add Jetpack 9.6 subtree
- Loading branch information
Showing
1,734 changed files
with
309,128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Compatibility files for third-party plugins. | ||
* This is used to improve compatibility of specific Jetpack features with third-party plugins. | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
namespace Automattic\Jetpack; | ||
|
||
/** | ||
* Loads the individual 3rd-party compat files. | ||
*/ | ||
function load_3rd_party() { | ||
// Array of third-party compat files to always require. | ||
$compat_files = array( | ||
'bbpress.php', | ||
'beaverbuilder.php', | ||
'bitly.php', | ||
'buddypress.php', | ||
'class.jetpack-amp-support.php', | ||
'class-jetpack-crm-data.php', | ||
'class-jetpack-modules-overrides.php', // Special case. Tools to be used to override module settings. | ||
'creative-mail.php', | ||
'debug-bar.php', | ||
'class-domain-mapping.php', | ||
'crowdsignal.php', | ||
'qtranslate-x.php', | ||
'vaultpress.php', | ||
'web-stories.php', | ||
'wpml.php', | ||
'woocommerce.php', | ||
'woocommerce-services.php', | ||
); | ||
|
||
foreach ( $compat_files as $file ) { | ||
if ( file_exists( JETPACK__PLUGIN_DIR . '/3rd-party/' . $file ) ) { | ||
require_once JETPACK__PLUGIN_DIR . '/3rd-party/' . $file; | ||
} | ||
} | ||
} | ||
|
||
load_3rd_party(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* Compatibility functions for bbpress. | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
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( 'bbpress' ) ) { | ||
return; | ||
} | ||
|
||
/** | ||
* Add compatibility layer for REST API. | ||
* | ||
* @since 8.5.0 Moved from root-level file and check_rest_api_compat() | ||
*/ | ||
require_once 'class-jetpack-bbpress-rest-api.php'; | ||
Jetpack_BbPress_REST_API::instance(); | ||
|
||
// Adds sharing buttons to bbPress items. | ||
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 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Beaverbuilder Compatibility. | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Third_Party; | ||
|
||
add_action( 'init', __NAMESPACE__ . '\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' ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Fixes issues with the Official Bitly for WordPress | ||
* https://wordpress.org/plugins/bitly/ | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
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 ); | ||
} | ||
} | ||
|
||
/** | ||
* Adds bitly OG tags. | ||
*/ | ||
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 ) ) ); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* 3rd Party Integration for BuddyPress. | ||
* | ||
* @package automattic/jetpack. | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Third_Party; | ||
|
||
add_filter( 'bp_core_pre_avatar_handle_upload', __NAMESPACE__ . '\blobphoto' ); | ||
|
||
/** | ||
* Adds filters for skipping photon during pre_avatar_handle_upload. | ||
* | ||
* @param bool $bool Passthrough of filter's original content. No changes made. | ||
* | ||
* @return bool | ||
*/ | ||
function blobphoto( $bool ) { | ||
add_filter( 'jetpack_photon_skip_image', '__return_true' ); | ||
|
||
return $bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
/** | ||
* Domain Mapping 3rd Party | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Third_Party; | ||
|
||
use Automattic\Jetpack\Constants; | ||
|
||
/** | ||
* Class Automattic\Jetpack\Third_Party\Domain_Mapping. | ||
* | ||
* This class contains methods that are used to provide compatibility between Jetpack sync and domain mapping plugins. | ||
*/ | ||
class Domain_Mapping { | ||
|
||
/** | ||
* Singleton holder. | ||
* | ||
* @var 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 | ||
*/ | ||
public static $test_methods = array( | ||
'hook_wordpress_mu_domain_mapping', | ||
'hook_wpmu_dev_domain_mapping', | ||
); | ||
|
||
/** | ||
* Singleton constructor. | ||
* | ||
* @return Domain_Mapping|null | ||
*/ | ||
public static function init() { | ||
if ( is_null( self::$instance ) ) { | ||
self::$instance = new Domain_Mapping(); | ||
} | ||
|
||
return self::$instance; | ||
} | ||
|
||
/** | ||
* Class Automattic\Jetpack\Third_Party\Domain_Mapping constructor. | ||
*/ | ||
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. | ||
*/ | ||
public function attempt_to_hook_domain_mapping_plugins() { | ||
if ( ! 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 | ||
*/ | ||
public function hook_wordpress_mu_domain_mapping() { | ||
if ( ! 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 | ||
*/ | ||
public 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. | ||
*/ | ||
|
||
/** | ||
* Checks if a method exists. | ||
* | ||
* @param string $class Class name. | ||
* @param string $method Method name. | ||
* | ||
* @return bool Returns function_exists() without modification. | ||
*/ | ||
public function method_exists( $class, $method ) { | ||
return method_exists( $class, $method ); | ||
} | ||
|
||
/** | ||
* Checks if a class exists. | ||
* | ||
* @param string $class Class name. | ||
* | ||
* @return bool Returns class_exists() without modification. | ||
*/ | ||
public function class_exists( $class ) { | ||
return class_exists( $class ); | ||
} | ||
|
||
/** | ||
* Checks if a function exists. | ||
* | ||
* @param string $function Function name. | ||
* | ||
* @return bool Returns function_exists() without modification. | ||
*/ | ||
public function function_exists( $function ) { | ||
return function_exists( $function ); | ||
} | ||
|
||
/** | ||
* Returns the Domain_Map::utils() instance. | ||
* | ||
* @see https://github.com/wpmudev/domain-mapping/blob/master/classes/Domainmap/Utils.php | ||
* @return Domainmap_Utils | ||
*/ | ||
public function get_domain_mapping_utils_instance() { | ||
return \domain_map::utils(); | ||
} | ||
} | ||
|
||
Domain_Mapping::init(); |
Oops, something went wrong.