PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-sync/src/modules/class-themes.php +21 -13 13.7.2 → 16.3-beta View file →
@@ -6,8 +6,12 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Sync\Modules;
9 9
10 +if ( ! defined( 'ABSPATH' ) ) {
11 + exit( 0 );
12 +}
13 +
10 14 /**
11 15 * Class to handle sync for themes.
12 16 */
13 17 class Themes extends Module {
@@ -82,9 +86,9 @@
82 86
83 87 $widget = array(
84 88 'name' => $widget_object->name,
85 89 'id' => $widget_object->id,
86 - 'title' => isset( $new_instance['title'] ) ? $new_instance['title'] : '',
90 + 'title' => $new_instance['title'] ?? '',
87 91 );
88 92 /**
89 93 * Trigger action to alert $callable sync listener that a widget was edited.
90 94 *
@@ -182,9 +186,9 @@
182 186 public function detect_theme_edit( $redirect_url ) {
183 187 $url = wp_parse_url( admin_url( $redirect_url ) );
184 188 $theme_editor_url = wp_parse_url( admin_url( 'theme-editor.php' ) );
185 189
186 - if ( $theme_editor_url['path'] !== $url['path'] ) {
190 + if ( ! isset( $url['query'] ) || $theme_editor_url['path'] !== $url['path'] ) {
187 191 return $redirect_url;
188 192 }
189 193
190 194 $query_params = array();
@@ -508,19 +512,25 @@
508 512 *
509 513 * @access public
510 514 *
511 515 * @param array $config Full sync configuration for this sync module.
516 + * @param array $status This module Full Sync status.
512 517 * @param int $send_until The timestamp until the current request can send.
513 - * @param array $state This module Full Sync status.
518 + * @param int $started The timestamp when the full sync started.
514 519 *
515 520 * @return array This module Full Sync status.
516 521 */
517 - public function send_full_sync_actions( $config, $send_until, $state ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
522 + public function send_full_sync_actions( $config, $status, $send_until, $started ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
518 523 // we call this instead of do_action when sending immediately.
519 - $this->send_action( 'jetpack_full_sync_theme_data', array( true ) );
524 + $result = $this->send_action( 'jetpack_full_sync_theme_data', array( true ) );
520 525
521 - // The number of actions enqueued, and next module state (true == done).
522 - return array( 'finished' => true );
526 + if ( is_wp_error( $result ) ) {
527 + $status['error'] = true;
528 + return $status;
529 + }
530 + $status['finished'] = true;
531 + $status['sent'] = $status['total'];
532 + return $status;
523 533 }
524 534
525 535 /**
526 536 * Retrieve an estimated number of actions that will be enqueued.
@@ -527,9 +537,9 @@
527 537 *
528 538 * @access public
529 539 *
530 540 * @param array $config Full sync configuration for this sync module.
531 - * @return array Number of items yet to be enqueued.
541 + * @return int Number of items yet to be enqueued.
532 542 */
533 543 public function estimate_full_sync_actions( $config ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
534 544 return 1;
535 545 }
@@ -734,22 +744,20 @@
734 744 }
735 745
736 746 $moved_to_inactive_ids = array();
737 747 $moved_to_sidebar = array();
748 + $new_inactive_widgets = $new_value['wp_inactive_widgets'] ?? array();
738 749
739 750 foreach ( $new_value as $sidebar => $new_widgets ) {
740 751 if ( in_array( $sidebar, array( 'array_version', 'wp_inactive_widgets' ), true ) ) {
741 752 continue;
742 753 }
743 - $old_widgets = isset( $old_value[ $sidebar ] )
744 - ? $old_value[ $sidebar ]
745 - : array();
754 + $old_widgets = $old_value[ $sidebar ] ?? array();
746 755
747 756 if ( ! is_array( $new_widgets ) ) {
748 757 $new_widgets = array();
749 758 }
750 -
751 - $moved_to_inactive_recently = $this->sync_remove_widgets_from_sidebar( $new_widgets, $old_widgets, $sidebar, $new_value['wp_inactive_widgets'] );
759 + $moved_to_inactive_recently = $this->sync_remove_widgets_from_sidebar( $new_widgets, $old_widgets, $sidebar, $new_inactive_widgets );
752 760 $moved_to_inactive_ids = array_merge( $moved_to_inactive_ids, $moved_to_inactive_recently );
753 761
754 762 $moved_to_sidebar_recently = $this->sync_add_widgets_to_sidebar( $new_widgets, $old_widgets, $sidebar );
755 763 $moved_to_sidebar = array_merge( $moved_to_sidebar, $moved_to_sidebar_recently );