summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2016-08-23 20:02:23 -0400
committerAnthony G. Basile <blueness@gentoo.org>2016-08-23 20:02:50 -0400
commitad3f35663e4e2b80a92166b590d3e2052b5aab91 (patch)
tree94f987efbdb50e1426956c1c04ac459a19c77e53 /plugins/jetpack/sync/class.jetpack-sync-module-updates.php
parentbin/update-wordpress: also update twentyfourteen twentyfifteen twentysixteen (diff)
downloadblogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.gz
blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.bz2
blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.zip
Update plugin jetpack to 4.2.2
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-module-updates.php')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-module-updates.php85
1 files changed, 85 insertions, 0 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-updates.php b/plugins/jetpack/sync/class.jetpack-sync-module-updates.php
new file mode 100644
index 00000000..f3f23774
--- /dev/null
+++ b/plugins/jetpack/sync/class.jetpack-sync-module-updates.php
@@ -0,0 +1,85 @@
+<?php
+
+class Jetpack_Sync_Module_Updates extends Jetpack_Sync_Module {
+ function name() {
+ return 'updates';
+ }
+
+ public function init_listeners( $callable ) {
+ add_action( 'set_site_transient_update_plugins', $callable, 10, 1 );
+ add_action( 'set_site_transient_update_themes', $callable, 10, 1 );
+ add_action( 'set_site_transient_update_core', $callable, 10, 1 );
+
+ add_filter( 'jetpack_sync_before_enqueue_set_site_transient_update_plugins', array(
+ $this,
+ 'filter_update_keys',
+ ), 10, 2 );
+ add_filter( 'jetpack_sync_before_enqueue_upgrader_process_complete', array(
+ $this,
+ 'filter_upgrader_process_complete',
+ ), 10, 2 );
+ }
+
+ public function init_full_sync_listeners( $callable ) {
+ add_action( 'jetpack_full_sync_updates', $callable );
+ }
+
+ public function init_before_send() {
+ // full sync
+ add_filter( 'jetpack_sync_before_send_jetpack_full_sync_updates', array( $this, 'expand_updates' ) );
+ }
+
+ public function enqueue_full_sync_actions( $config ) {
+ /**
+ * Tells the client to sync all updates to the server
+ *
+ * @since 4.2.0
+ *
+ * @param boolean Whether to expand updates (should always be true)
+ */
+ do_action( 'jetpack_full_sync_updates', true );
+
+ return 1; // The number of actions enqueued
+ }
+
+ public function estimate_full_sync_actions( $config ) {
+ return 1;
+ }
+
+ function get_full_sync_actions() {
+ return array( 'jetpack_full_sync_updates' );
+ }
+
+ public function get_all_updates() {
+ return array(
+ 'core' => get_site_transient( 'update_core' ),
+ 'plugins' => get_site_transient( 'update_plugins' ),
+ 'themes' => get_site_transient( 'update_themes' ),
+ );
+ }
+
+ // removes unnecessary keys from synced updates data
+ function filter_update_keys( $args ) {
+ $updates = $args[0];
+
+ if ( isset( $updates->no_update ) ) {
+ unset( $updates->no_update );
+ }
+
+ return $args;
+ }
+
+ function filter_upgrader_process_complete( $args ) {
+ array_shift( $args );
+
+ return $args;
+ }
+
+ public function expand_updates( $args ) {
+ if ( $args[0] ) {
+ return $this->get_all_updates();
+ }
+
+ return $args;
+ }
+}