summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sync')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-actions.php5
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-defaults.php2
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-functions.php68
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-listener.php38
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-callables.php4
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-posts.php53
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-terms.php1
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-themes.php82
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-updates.php3
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-woocommerce.php20
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-users.php2
11 files changed, 201 insertions, 77 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-actions.php b/plugins/jetpack/sync/class.jetpack-sync-actions.php
index 05a50778..a01d819a 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-actions.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-actions.php
@@ -113,6 +113,7 @@ class Jetpack_Sync_Actions {
}
static function send_data( $data, $codec_name, $sent_timestamp, $queue_id, $checkout_duration, $preprocess_duration ) {
+ require_once dirname( __FILE__ ) . '/class.jetpack-sync-functions.php';
Jetpack::load_xml_rpc_client();
$query_args = array(
@@ -120,8 +121,8 @@ class Jetpack_Sync_Actions {
'codec' => $codec_name, // send the name of the codec used to encode the data
'timestamp' => $sent_timestamp, // send current server time so we can compensate for clock differences
'queue' => $queue_id, // sync or full_sync
- 'home' => get_home_url(), // Send home url option to check for Identity Crisis server-side
- 'siteurl' => get_site_url(), // Send siteurl option to check for Identity Crisis server-side
+ 'home' => Jetpack_Sync_Functions::home_url(), // Send home url option to check for Identity Crisis server-side
+ 'siteurl' => Jetpack_Sync_Functions::site_url(), // Send siteurl option to check for Identity Crisis server-side
'cd' => sprintf( '%.4f', $checkout_duration), // Time spent retrieving queue items from the DB
'pd' => sprintf( '%.4f', $preprocess_duration), // Time spent converting queue items into data to send
);
diff --git a/plugins/jetpack/sync/class.jetpack-sync-defaults.php b/plugins/jetpack/sync/class.jetpack-sync-defaults.php
index 29a20f92..86afad61 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-defaults.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-defaults.php
@@ -146,6 +146,8 @@ class Jetpack_Sync_Defaults {
'ALTERNATE_WP_CRON',
'WP_CRON_LOCK_TIMEOUT',
'PHP_VERSION',
+ 'WP_MEMORY_LIMIT',
+ 'WP_MAX_MEMORY_LIMIT'
);
public static function get_constants_whitelist() {
diff --git a/plugins/jetpack/sync/class.jetpack-sync-functions.php b/plugins/jetpack/sync/class.jetpack-sync-functions.php
index 596af357..f8d76def 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-functions.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-functions.php
@@ -144,18 +144,53 @@ class Jetpack_Sync_Functions {
return false;
}
+ /**
+ * Helper function that is used when getting home or siteurl values. Decides
+ * whether to get the raw or filtered value.
+ *
+ * @return string
+ */
+ public static function get_raw_or_filtered_url( $url_type ) {
+ if (
+ ! Jetpack_Constants::is_defined( 'JETPACK_SYNC_USE_RAW_URL' ) ||
+ Jetpack_Constants::get_constant( 'JETPACK_SYNC_USE_RAW_URL' )
+ ) {
+ $url = self::get_raw_url( $url_type );
+ } else {
+ $url_function = ( 'home' == $url_type )
+ ? 'home_url'
+ : 'site_url';
+ $url = self::normalize_www_in_url( $url_type, $url_function );
+ $url = self::get_protocol_normalized_url( $url_function, $url );
+ }
+
+ return $url;
+ }
+
public static function home_url() {
- return self::get_protocol_normalized_url(
- 'home_url',
- self::normalize_www_in_url( 'home', 'home_url' )
- );
+ $url = self::get_raw_or_filtered_url( 'home' );
+
+ /**
+ * Allows overriding of the home_url value that is synced back to WordPress.com.
+ *
+ * @since 5.2
+ *
+ * @param string $home_url
+ */
+ return esc_url_raw( apply_filters( 'jetpack_sync_home_url', $url ) );
}
public static function site_url() {
- return self::get_protocol_normalized_url(
- 'site_url',
- self::normalize_www_in_url( 'siteurl', 'site_url' )
- );
+ $url = self::get_raw_or_filtered_url( 'siteurl' );
+
+ /**
+ * Allows overriding of the site_url value that is synced back to WordPress.com.
+ *
+ * @since 5.2
+ *
+ * @param string $site_url
+ */
+ return esc_url_raw( apply_filters( 'jetpack_sync_site_url', $url ) );
}
public static function main_network_site_url() {
@@ -184,6 +219,23 @@ class Jetpack_Sync_Functions {
return set_url_scheme( $new_value, $forced_scheme );
}
+ public static function get_raw_url( $option_name ) {
+ $value = null;
+ $constant = ( 'home' == $option_name )
+ ? 'WP_HOME'
+ : 'WP_SITEURL';
+
+ if ( Jetpack_Constants::is_defined( $constant ) ) {
+ $value = Jetpack_Constants::get_constant( $constant );
+ } else {
+ // Let's get the option from the database so that we can bypass filters. This will help
+ // ensure that we get more uniform values.
+ $value = Jetpack_Options::get_raw_option( $option_name );
+ }
+
+ return $value;
+ }
+
public static function normalize_www_in_url( $option, $url_function ) {
$url = wp_parse_url( call_user_func( $url_function ) );
$option_url = wp_parse_url( get_option( $option ) );
diff --git a/plugins/jetpack/sync/class.jetpack-sync-listener.php b/plugins/jetpack/sync/class.jetpack-sync-listener.php
index baafde54..e3fafdee 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-listener.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-listener.php
@@ -236,26 +236,24 @@ class Jetpack_Sync_Listener {
}
function get_actor() {
- $current_user = wp_get_current_user();
-
- $actor = array();
- if ( $current_user ) {
- $actor['display_name'] = $current_user->display_name;
- $actor['user_email'] = $current_user->user_email;
- $actor['user_roles'] = $current_user->roles; /* Since 5.0.0 */
- $actor['translated_role'] = Jetpack::translate_current_user_to_role(); /* Since 5.0.0 */
- }
-
- if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
- $actor[ 'ip' ] = $_SERVER['REMOTE_ADDR'];
- }
-
- $actor['is_cron'] = defined( 'DOING_CRON' ) ? DOING_CRON : false;
- $actor['is_wp_admin'] = is_admin();
- $actor['is_rest'] = defined( 'REST_API_REQUEST' ) ? REST_API_REQUEST : false;
- $actor['is_xmlrpc'] = defined( 'XMLRPC_REQUEST' ) ? XMLRPC_REQUEST : false;
- $actor['is_wp_rest'] = defined( 'REST_REQUEST' ) ? REST_REQUEST : false;
- $actor['is_ajax'] = defined( 'DOING_AJAX' ) ? DOING_AJAX : false;
+ $user = wp_get_current_user();
+ $translated_role = Jetpack::translate_current_user_to_role();
+
+ $actor = array(
+ 'wpcom_user_id' => null,
+ 'external_user_id' => isset( $user->ID ) ? $user->ID : null,
+ 'display_name' => isset( $user->display_name ) ? $user->display_name : null,
+ 'user_email' => isset( $user->user_email ) ? $user->user_email : null,
+ 'user_roles' => isset( $user->roles ) ? $user->roles : null,
+ 'translated_role' => $translated_role ? $translated_role : null,
+ 'is_cron' => defined( 'DOING_CRON' ) ? DOING_CRON : false,
+ 'is_rest' => defined( 'REST_API_REQUEST' ) ? REST_API_REQUEST : false,
+ 'is_xmlrpc' => defined( 'XMLRPC_REQUEST' ) ? XMLRPC_REQUEST : false,
+ 'is_wp_rest' => defined( 'REST_REQUEST' ) ? REST_REQUEST : false,
+ 'is_ajax' => defined( 'DOING_AJAX' ) ? DOING_AJAX : false,
+ 'ip' => isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null,
+ 'is_wp_admin' => is_admin(),
+ );
return $actor;
}
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-callables.php b/plugins/jetpack/sync/class.jetpack-sync-module-callables.php
index b0565213..917345b3 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-callables.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-callables.php
@@ -145,7 +145,7 @@ class Jetpack_Sync_Module_Callables extends Jetpack_Sync_Module {
return;
}
- $callable_checksums = (array) get_option( self::CALLABLES_CHECKSUM_OPTION_NAME, array() );
+ $callable_checksums = (array) Jetpack_Options::get_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, array() );
// only send the callables that have changed
foreach ( $callables as $name => $value ) {
@@ -166,7 +166,7 @@ class Jetpack_Sync_Module_Callables extends Jetpack_Sync_Module {
$callable_checksums[ $name ] = $checksum;
}
}
- update_option( self::CALLABLES_CHECKSUM_OPTION_NAME, $callable_checksums );
+ Jetpack_Options::update_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, $callable_checksums );
}
public function expand_callables( $args ) {
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-posts.php b/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
index 80815acb..3a5145bb 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-posts.php
@@ -46,7 +46,7 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
$this->init_meta_whitelist_handler( 'post', array( $this, 'filter_meta' ) );
add_action( 'export_wp', $callable );
- add_action( 'jetpack_sync_import_end', $callable );
+ add_action( 'jetpack_sync_import_end', $callable, 10, 2 );
// Movable type, RSS, Livejournal
add_action( 'import_done', array( $this, 'sync_import_done' ) );
@@ -60,14 +60,17 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
if ( $this->import_end ) {
return;
}
+
+ $importer_name = $this->get_importer_name( $importer );
+
/**
* Sync Event that tells that the import is finished
*
* @since 5.0.0
*
- * $param string $importer
+ * $param string $importer
*/
- do_action( 'jetpack_sync_import_end', $importer );
+ do_action( 'jetpack_sync_import_end', $importer, $importer_name );
$this->import_end = true;
}
@@ -78,8 +81,8 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
}
$this->import_end = true;
- $importer = 'unknown';
- $backtrace = wp_debug_backtrace_summary(null, 0, false );
+ $importer = 'unknown';
+ $backtrace = wp_debug_backtrace_summary( null, 0, false );
if ( $this->is_importer( $backtrace, 'Blogger_Importer' ) ) {
$importer = 'blogger';
}
@@ -92,19 +95,27 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
$importer = 'wordpress';
}
+ $importer_name = $this->get_importer_name( $importer );
+
/** This filter is already documented in sync/class.jetpack-sync-module-posts.php */
- do_action( 'jetpack_sync_import_end', $importer );
+ do_action( 'jetpack_sync_import_end', $importer, $importer_name );
+ }
+
+ private function get_importer_name( $importer ) {
+ $importers = get_importers();
+ return isset( $importers[ $importer ] ) ? $importers[ $importer ][0] : 'Unknown Importer';
}
-
+
private function is_importer( $backtrace, $class_name ) {
foreach ( $backtrace as $trace ) {
if ( strpos( $trace, $class_name ) !== false ) {
return true;
}
}
+
return false;
}
-
+
public function init_full_sync_listeners( $callable ) {
add_action( 'jetpack_full_sync_posts', $callable ); // also sends post meta
}
@@ -154,7 +165,13 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
* @return array
*/
function expand_wp_insert_post( $args ) {
- return array( $args[0], $this->filter_post_content_and_add_links( $args[1] ), $args[2], $args[3] );
+ $post_id = $args[0];
+ $post = $args[1];
+ $update = $args[2];
+ $is_auto_save = isset( $args[3] ) ? $args[3] : false; //See https://github.com/Automattic/jetpack/issues/7372
+ $just_published = isset( $args[4] ) ? $args[4] : false; //Preventative in light of above issue
+
+ return array( $post_id, $this->filter_post_content_and_add_links( $post ), $update, $is_auto_save, $just_published );
}
function filter_blacklisted_post_types( $args ) {
@@ -311,7 +328,7 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
}
}
- public function wp_insert_post( $post_ID, $post = null , $update = null ) {
+ public function wp_insert_post( $post_ID, $post = null, $update = null ) {
if ( ! is_numeric( $post_ID ) || is_null( $post ) ) {
return;
}
@@ -322,7 +339,13 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
$is_auto_save = false;
}
- call_user_func( $this->action_handler, $post_ID, $post, $update, $is_auto_save );
+ if ( ! in_array( $post_ID, $this->just_published ) ) {
+ $just_published = false;
+ } else {
+ $just_published = true;
+ }
+
+ call_user_func( $this->action_handler, $post_ID, $post, $update, $is_auto_save, $just_published );
$this->send_published( $post_ID, $post );
$this->send_trashed( $post_ID, $post );
}
@@ -337,6 +360,10 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
return;
}
+ $post_flags = array(
+ 'post_type' => $post->post_type
+ );
+
/**
* Filter that is used to add to the post flags ( meta data ) when a post gets published
*
@@ -345,7 +372,7 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
* @param mixed array post flags that are added to the post
* @param mixed $post WP_POST object
*/
- $flags = apply_filters( 'jetpack_published_post_flags', array(), $post );
+ $flags = apply_filters( 'jetpack_published_post_flags', $post_flags, $post );
/**
* Action that gets synced when a post type gets published.
@@ -377,7 +404,7 @@ class Jetpack_Sync_Module_Posts extends Jetpack_Sync_Module {
*
* @param int $post_ID
*/
- do_action( 'jetpack_trashed_post', $post_ID );
+ do_action( 'jetpack_trashed_post', $post_ID, $post->post_type );
$this->just_trashed = array_diff( $this->just_trashed, array( $post_ID ) );
}
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-terms.php b/plugins/jetpack/sync/class.jetpack-sync-module-terms.php
index c8068101..7f47ebab 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-terms.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-terms.php
@@ -85,6 +85,7 @@ class Jetpack_Sync_Module_Terms extends Jetpack_Sync_Module {
* @param object the Term object
*/
do_action( 'jetpack_sync_add_term', $term_object );
+ return;
}
/**
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-themes.php b/plugins/jetpack/sync/class.jetpack-sync-module-themes.php
index e36743fd..2fbb810f 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-themes.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-themes.php
@@ -12,7 +12,7 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
add_action( 'jetpack_installed_theme', $callable, 10, 2 );
add_action( 'jetpack_updated_theme', $callable, 10, 2 );
add_action( 'delete_site_transient_update_themes', array( $this, 'detect_theme_deletion') );
- add_action( 'jetpack_deleted_theme', $callable );
+ add_action( 'jetpack_deleted_theme', $callable, 10, 2 );
add_filter( 'wp_redirect', array( $this, 'detect_theme_edit' ) );
add_action( 'jetpack_edited_theme', $callable, 10, 2 );
add_action( 'update_site_option_allowedthemes', array( $this, 'sync_network_allowed_themes_change' ), 10, 4 );
@@ -32,6 +32,10 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
}
public function sync_widget_edit( $instance, $new_instance, $old_instance, $widget_object ) {
+ if ( empty( $old_instance ) ) {
+ return $instance;
+ }
+
$widget = array(
'name' => $widget_object->name,
'id' => $widget_object->id,
@@ -41,7 +45,7 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
*
* @since 5.0.0
*
- * @param string $widget_name, Name of edited widget
+ * @param string $widget_name , Name of edited widget
*/
do_action( 'jetpack_widget_edited', $widget );
@@ -52,6 +56,13 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
$all_enabled_theme_slugs = array_keys( $value );
if ( count( $old_value ) > count( $value ) ) {
+
+ //Suppress jetpack_network_disabled_themes sync action when theme is deleted
+ $delete_theme_call = $this->get_delete_theme_call();
+ if ( ! empty( $delete_theme_call ) ) {
+ return;
+ }
+
$newly_disabled_theme_names = array_keys( array_diff_key( $old_value, $value ) );
$newly_disabled_themes = $this->get_theme_details_for_slugs( $newly_disabled_theme_names );
/**
@@ -132,19 +143,19 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
}
public function detect_theme_deletion() {
- $backtrace = debug_backtrace();
- $delete_theme_call = null;
- foreach ( $backtrace as $call ) {
- if ( isset( $call['function'] ) && 'delete_theme' === $call['function'] ) {
- $delete_theme_call = $call;
- break;
- }
- }
+ $delete_theme_call = $this->get_delete_theme_call();
if ( empty( $delete_theme_call ) ) {
return;
}
$slug = $delete_theme_call['args'][0];
+ $theme = wp_get_theme( $slug );
+ $theme_data = array(
+ 'name' => $theme->get('Name'),
+ 'version' => $theme->get('Version'),
+ 'uri' => $theme->get( 'ThemeURI' ),
+ 'slug' => $slug,
+ );
/**
* Signals to the sync listener that a theme was deleted and a sync action
@@ -153,8 +164,9 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
* @since 5.0.0
*
* @param string $slug Theme slug
+ * @param array $theme_data Theme info Since 5.3
*/
- do_action( 'jetpack_deleted_theme', $slug );
+ do_action( 'jetpack_deleted_theme', $slug, $theme_data );
}
public function check_upgrader( $upgrader, $details) {
@@ -264,6 +276,11 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
$moved_to_sidebar = array();
$sidebar_name = $this->get_sidebar_name( $sidebar );
+ //Don't sync jetpack_widget_added if theme was switched
+ if ( $this->is_theme_switch() ) {
+ return array();
+ }
+
foreach ( $added_widgets as $added_widget ) {
$moved_to_sidebar[] = $added_widget;
$added_widget_name = $this->get_widget_name( $added_widget );
@@ -342,13 +359,12 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
}
function sync_sidebar_widgets_actions( $old_value, $new_value ) {
-
// Don't really know how to deal with different array_values yet.
if ( $old_value['array_version'] !== 3 || $new_value['array_version'] !== 3 ) {
return;
}
- $moved_to_inactive = array();
+ $moved_to_inactive_ids = array();
$moved_to_sidebar = array();
foreach ( $new_value as $sidebar => $new_widgets ) {
@@ -359,8 +375,12 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
? $old_value[ $sidebar ]
: array();
+ if ( ! is_array( $new_widgets ) ) {
+ $new_widgets = array();
+ }
+
$moved_to_inactive_recently = $this->sync_remove_widgets_from_sidebar( $new_widgets, $old_widgets, $sidebar, $new_value['wp_inactive_widgets'] );
- $moved_to_inactive_ids = array_merge( $moved_to_inactive, $moved_to_inactive_recently );
+ $moved_to_inactive_ids = array_merge( $moved_to_inactive_ids, $moved_to_inactive_recently );
$moved_to_sidebar_recently = $this->sync_add_widgets_to_sidebar( $new_widgets, $old_widgets, $sidebar );
$moved_to_sidebar = array_merge( $moved_to_sidebar, $moved_to_sidebar_recently );
@@ -369,6 +389,11 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
}
+ //Don't sync either jetpack_widget_moved_to_inactive or jetpack_cleared_inactive_widgets if theme was switched
+ if ( $this->is_theme_switch() ) {
+ return;
+ }
+
// Treat inactive sidebar a bit differently
if ( ! empty( $moved_to_inactive_ids ) ) {
$moved_to_inactive_name = array_map( array( $this, 'get_widget_name' ), $moved_to_inactive_ids );
@@ -406,9 +431,34 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module {
}
$theme = wp_get_theme();
- $theme_support['name'] = $theme->name;
- $theme_support['version'] = $theme->version;
+ $theme_support['name'] = $theme->get('Name');
+ $theme_support['version'] = $theme->get('Version');
+ $theme_support['slug'] = $theme->get_stylesheet();
+ $theme_support['uri'] = $theme->get('ThemeURI');
+
return $theme_support;
}
+
+ private function get_delete_theme_call() {
+ $backtrace = debug_backtrace();
+ $delete_theme_call = null;
+ foreach ( $backtrace as $call ) {
+ if ( isset( $call['function'] ) && 'delete_theme' === $call['function'] ) {
+ $delete_theme_call = $call;
+ break;
+ }
+ }
+ return $delete_theme_call;
+ }
+
+ private function is_theme_switch() {
+ $backtrace = debug_backtrace();
+ foreach ( $backtrace as $call ) {
+ if ( isset( $call['args'][0] ) && 'after_switch_theme' === $call['args'][0] ) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-updates.php b/plugins/jetpack/sync/class.jetpack-sync-module-updates.php
index 91969a1c..95cbd195 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-updates.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-updates.php
@@ -200,6 +200,9 @@ class Jetpack_Sync_Module_Updates extends Jetpack_Sync_Module {
}
public function expand_themes( $args ) {
+ if ( ! isset( $args[0], $args[0]->response ) ) {
+ return $args;
+ }
foreach ( $args[0]->response as $stylesheet => &$theme_data ) {
$theme = wp_get_theme( $stylesheet );
$theme_data['name'] = $theme->name;
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-woocommerce.php b/plugins/jetpack/sync/class.jetpack-sync-module-woocommerce.php
index 0eac6e1b..9604a518 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-module-woocommerce.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-woocommerce.php
@@ -81,7 +81,8 @@ class Jetpack_Sync_Module_WooCommerce extends Jetpack_Sync_Module {
}
public function filter_order_item( $args ) {
- $args[1] = $this->build_order_item( $args[1] );
+ // Make sure we always have all the data - prior to WooCommerce 3.0 we only have the user supplied data in the second argument and not the full details
+ $args[1] = $this->build_order_item( $args[0] );
return $args;
}
@@ -102,20 +103,9 @@ class Jetpack_Sync_Module_WooCommerce extends Jetpack_Sync_Module {
);
}
- public function build_order_item( $order_item ) {
- if ( is_numeric( $order_item ) ) {
- global $wpdb;
- return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->order_item_table_name WHERE order_item_id = %d", $order_item ) );
- } elseif ( is_array( $order_item ) ) {
- return $order_item;
- } else {
- return (object)array(
- 'order_item_id' => $order_item->get_id(),
- 'order_item_type' => $order_item->get_type(),
- 'order_item_name' => $order_item->get_name(),
- 'order_id' => $order_item->get_order_id(),
- );
- }
+ public function build_order_item( $order_item_id ) {
+ global $wpdb;
+ return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->order_item_table_name WHERE order_item_id = %d", $order_item_id ) );
}
public function enqueue_full_sync_actions( $config, $max_items_to_enqueue, $state ) {
diff --git a/plugins/jetpack/sync/class.jetpack-sync-users.php b/plugins/jetpack/sync/class.jetpack-sync-users.php
index 69d4e3c5..16b78d46 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-users.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-users.php
@@ -41,7 +41,7 @@ class Jetpack_Sync_Users {
}
static function get_signed_role( $user_id ) {
- return Jetpack::sign_role( self::get_role( $user_id ) );
+ return Jetpack::sign_role( self::get_role( $user_id ), $user_id );
}
static function update_role_on_com( $user_id ) {