Changeset 51705
- Timestamp:
- 08/31/2021 07:57:20 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/upgrade.php
r51088 r51705 1774 1774 // Intentional fall-through to upgrade to the next version. 1775 1775 case 2: 1776 $sidebars_widgets = retrieve_widgets();1776 $sidebars_widgets = sync_registered_widgets(); 1777 1777 $sidebars_widgets['array_version'] = 3; 1778 1778 update_option( 'sidebars_widgets', $sidebars_widgets ); -
trunk/src/wp-admin/widgets-form.php
r51061 r51705 119 119 ); 120 120 121 retrieve_widgets();121 sync_registered_widgets(); 122 122 123 123 // We're saving a widget without JS. -
trunk/src/wp-includes/class-wp-customize-widgets.php
r51700 r51705 276 276 $this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset. 277 277 278 // retrieve_widgets() looks at the global $sidebars_widgets.278 // sync_registered_widgets() looks at the global $sidebars_widgets. 279 279 $sidebars_widgets = $this->old_sidebars_widgets; 280 $sidebars_widgets = retrieve_widgets( 'customize' );280 $sidebars_widgets = sync_registered_widgets( 'customize' ); 281 281 add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 ); 282 282 // Reset global cache var used by wp_get_sidebars_widgets(). … … 288 288 * 289 289 * When switching themes, filter the Customizer setting old_sidebars_widgets_data 290 * to supply initial $sidebars_widgets before they were overridden by retrieve_widgets().290 * to supply initial $sidebars_widgets before they were overridden by sync_registered_widgets(). 291 291 * The value for old_sidebars_widgets_data gets set in the old theme's sidebars_widgets 292 292 * theme_mod. … … 306 306 * Filters sidebars_widgets option for theme switch. 307 307 * 308 * When switching themes, the retrieve_widgets() function is run when the Customizer initializes,308 * When switching themes, the sync_registered_widgets() function is run when the Customizer initializes, 309 309 * and then the new sidebars_widgets here get supplied as the default value for the sidebars_widgets 310 310 * option. -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php
r51408 r51705 99 99 */ 100 100 public function get_items( $request ) { 101 retrieve_widgets();101 sync_registered_widgets(); 102 102 103 103 $data = array(); … … 138 138 */ 139 139 public function get_item( $request ) { 140 retrieve_widgets();140 sync_registered_widgets(); 141 141 142 142 $sidebar = $this->get_sidebar( $request['id'] ); -
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php
r51657 r51705 110 110 */ 111 111 public function get_items( $request ) { 112 retrieve_widgets();112 sync_registered_widgets(); 113 113 114 114 $prepared = array(); … … 152 152 */ 153 153 public function get_item( $request ) { 154 retrieve_widgets();154 sync_registered_widgets(); 155 155 156 156 $widget_id = $request['id']; … … 238 238 239 239 /* 240 * retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the240 * sync_registered_widgets() contains logic to move "hidden" or "lost" widgets to the 241 241 * wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global. 242 242 * … … 249 249 wp_get_sidebars_widgets(); 250 250 251 retrieve_widgets();251 sync_registered_widgets(); 252 252 253 253 $widget_id = $request['id']; … … 314 314 315 315 /* 316 * retrieve_widgets() contains logic to move "hidden" or "lost" widgets to the316 * sync_registered_widgets() contains logic to move "hidden" or "lost" widgets to the 317 317 * wp_inactive_widgets sidebar based on the contents of the $sidebars_widgets global. 318 318 * … … 325 325 wp_get_sidebars_widgets(); 326 326 327 retrieve_widgets();327 sync_registered_widgets(); 328 328 329 329 $widget_id = $request['id']; -
trunk/src/wp-includes/theme.php
r51578 r51705 806 806 } else { 807 807 /* 808 * Since retrieve_widgets() is called when initializing a theme in the Customizer,808 * Since sync_registered_widgets() is called when initializing a theme in the Customizer, 809 809 * we need to remove the theme mods to avoid overwriting changes made via 810 810 * the Customizer when accessing wp-admin/widgets.php. -
trunk/src/wp-includes/widgets.php
r51391 r51705 1252 1252 } 1253 1253 1254 retrieve_widgets( true ); 1255 } 1256 1257 /** 1258 * Look for "lost" widgets, this has to run at least on each theme change. 1254 sync_registered_widgets( true ); 1255 } 1256 1257 /** 1258 * Do not use, deprecated. 1259 * 1260 * Use sync_registered_widgets() instead. 1259 1261 * 1260 1262 * @since 2.8.0 1263 * @deprecated 5.8.1 Use sync_registered_widgets() 1264 * @see sync_registered_widgets() 1265 * 1266 * @param string|bool $theme_changed 1267 * @return array 1268 */ 1269 function retrieve_widgets( $theme_changed = false ) { 1270 return sync_registered_widgets( $theme_changed ); 1271 } 1272 1273 /** 1274 * Looks for "lost" widgets and Updates widgets-to-sidebars allocation. 1275 * This has to run at least on each theme change. 1276 * 1277 * @since 5.8.1 1261 1278 * 1262 1279 * @global array $wp_registered_sidebars Registered sidebars. … … 1268 1285 * @return array Updated sidebars widgets. 1269 1286 */ 1270 function retrieve_widgets( $theme_changed = false ) {1287 function sync_registered_widgets( $theme_changed = false ) { 1271 1288 global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; 1272 1289 -
trunk/tests/phpunit/tests/widgets.php
r51568 r51705 844 844 * Tests for when 'sidebars_widgets' theme mod is populated. 845 845 * 846 * @covers :: retrieve_widgets847 */ 848 function test_ retrieve_widgets_with_theme_mod() {846 * @covers ::sync_registered_widgets 847 */ 848 function test_sync_registered_widgets_with_theme_mod() { 849 849 global $sidebars_widgets, $_wp_sidebars_widgets; 850 850 … … 874 874 ); 875 875 876 $result = retrieve_widgets( true );876 $result = sync_registered_widgets( true ); 877 877 878 878 $this->assertIsArray( $result ); … … 907 907 * Tests for when sidebars widgets matches registered sidebars. 908 908 * 909 * @covers :: retrieve_widgets910 */ 911 function test_ retrieve_widgets_with_sidebars_widgets_matching_registered_sidebars() {909 * @covers ::sync_registered_widgets 910 */ 911 function test_sync_registered_widgets_with_sidebars_widgets_matching_registered_sidebars() { 912 912 global $sidebars_widgets; 913 913 … … 922 922 ); 923 923 924 $result = retrieve_widgets( true );924 $result = sync_registered_widgets( true ); 925 925 926 926 // $sidebars_widgets matches registered sidebars. … … 945 945 * Tests for when sidebars widgets doesn't match registered sidebars. 946 946 * 947 * @covers :: retrieve_widgets948 */ 949 function test_ retrieve_widgets_with_sidebars_widgets_not_matching_registered_sidebars() {947 * @covers ::sync_registered_widgets 948 */ 949 function test_sync_registered_widgets_with_sidebars_widgets_not_matching_registered_sidebars() { 950 950 global $sidebars_widgets, $_wp_sidebars_widgets; 951 951 … … 961 961 962 962 // Theme changed. 963 $result = retrieve_widgets( true );963 $result = sync_registered_widgets( true ); 964 964 965 965 $_wp_sidebars_widgets = array(); … … 1003 1003 1004 1004 // Theme did not change. 1005 $result = retrieve_widgets();1005 $result = sync_registered_widgets(); 1006 1006 1007 1007 $_wp_sidebars_widgets = array(); … … 1037 1037 * Tests for Customizer mode. 1038 1038 * 1039 * @covers :: retrieve_widgets1040 */ 1041 function test_ retrieve_widgets_for_customizer() {1039 * @covers ::sync_registered_widgets 1040 */ 1041 function test_sync_registered_widgets_for_customizer() { 1042 1042 global $sidebars_widgets, $_wp_sidebars_widgets; 1043 1043 … … 1054 1054 set_theme_mod( 'sidebars_widgets', $old_sidebars_widgets ); 1055 1055 1056 $result = retrieve_widgets( 'customize' );1056 $result = sync_registered_widgets( 'customize' ); 1057 1057 1058 1058 $_wp_sidebars_widgets = array(); … … 1083 1083 } 1084 1084 1085 function test_ retrieve_widgets_with_single_widget() {1085 function test_sync_registered_widgets_with_single_widget() { 1086 1086 global $sidebars_widgets; 1087 1087 … … 1100 1100 1101 1101 // Theme changed. 1102 $result = retrieve_widgets( true );1102 $result = sync_registered_widgets( true ); 1103 1103 1104 1104 $this->assertContains( 'single', $result['wp_inactive_widgets'] ); … … 1108 1108 * Tests for orphaned widgets being moved into inactive widgets. 1109 1109 * 1110 * @covers :: retrieve_widgets1111 */ 1112 function test_ retrieve_widgets_move_orphaned_widgets_to_inactive() {1110 * @covers ::sync_registered_widgets 1111 */ 1112 function test_sync_registered_widgets_move_orphaned_widgets_to_inactive() { 1113 1113 global $sidebars_widgets; 1114 1114 … … 1123 1123 ); 1124 1124 1125 retrieve_widgets();1125 sync_registered_widgets(); 1126 1126 1127 1127 $this->assertIsArray( $sidebars_widgets );
Note: See TracChangeset
for help on using the changeset viewer.