diff options
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-module-themes.php')
-rw-r--r-- | plugins/jetpack/sync/class.jetpack-sync-module-themes.php | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-module-themes.php b/plugins/jetpack/sync/class.jetpack-sync-module-themes.php index 50ece939..be44c9a8 100644 --- a/plugins/jetpack/sync/class.jetpack-sync-module-themes.php +++ b/plugins/jetpack/sync/class.jetpack-sync-module-themes.php @@ -10,7 +10,7 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { add_action( 'jetpack_sync_current_theme_support', $callable ); add_action( 'upgrader_process_complete', array( $this, 'check_upgrader'), 10, 2 ); add_action( 'jetpack_installed_theme', $callable, 10, 2 ); - add_action( 'jetpack_updated_theme', $callable, 10, 2 ); + add_action( 'jetpack_updated_themes', $callable, 10, 2 ); add_action( 'delete_site_transient_update_themes', array( $this, 'detect_theme_deletion') ); add_action( 'jetpack_deleted_theme', $callable, 10, 2 ); add_filter( 'wp_redirect', array( $this, 'detect_theme_edit' ) ); @@ -235,6 +235,7 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { if ( false === $file_pointer ) { return; } + fclose( $file_pointer ); $theme_data = array( 'name' => $theme->get('Name'), @@ -276,7 +277,7 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { do_action( 'jetpack_deleted_theme', $slug, $theme_data ); } - public function check_upgrader( $upgrader, $details) { + public function check_upgrader( $upgrader, $details ) { if ( ! isset( $details['type'] ) || 'theme' !== $details['type'] || is_wp_error( $upgrader->skin->result ) || @@ -285,17 +286,17 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { return; } - $theme = $upgrader->theme_info(); - if ( ! $theme instanceof WP_Theme ) { - return; - } - $theme_info = array( - 'name' => $theme->get( 'Name' ), - 'version' => $theme->get( 'Version' ), - 'uri' => $theme->get( 'ThemeURI' ), - ); - if ( 'install' === $details['action'] ) { + $theme = $upgrader->theme_info(); + if ( ! $theme instanceof WP_Theme ) { + return; + } + $theme_info = array( + 'name' => $theme->get( 'Name' ), + 'version' => $theme->get( 'Version' ), + 'uri' => $theme->get( 'ThemeURI' ), + ); + /** * Signals to the sync listener that a theme was installed and a sync action * reflecting the installation and the theme info should be sent @@ -309,17 +310,42 @@ class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { } if ( 'update' === $details['action'] ) { + $themes = array(); + + if ( empty( $details['themes'] ) && isset ( $details['theme'] ) ) { + $details['themes'] = array( $details['theme'] ); + } + + foreach ( $details['themes'] as $theme_slug ) { + $theme = wp_get_theme( $theme_slug ); + + if ( ! $theme instanceof WP_Theme ) { + continue; + } + + $themes[ $theme_slug ] = array( + 'name' => $theme->get( 'Name' ), + 'version' => $theme->get( 'Version' ), + 'uri' => $theme->get( 'ThemeURI' ), + 'stylesheet' => $theme->stylesheet, + ); + } + + if ( empty( $themes ) ) { + return; + } + /** - * Signals to the sync listener that a theme was updated and a sync action + * Signals to the sync listener that one or more themes was updated and a sync action * reflecting the update and the theme info should be sent * - * @since 4.9.0 + * @since 6.2.0 * - * @param string $theme->theme_root Text domain of the theme - * @param mixed $theme_info Array of abbreviated theme info + * @param mixed $themes Array of abbreviated theme info */ - do_action( 'jetpack_updated_theme', $theme->stylesheet, $theme_info ); + do_action( 'jetpack_updated_themes', $themes ); } + } public function init_full_sync_listeners( $callable ) { |