Make WordPress Core


Ignore:
Timestamp:
08/31/2021 07:57:20 PM (3 years ago)
Author:
hellofromTonya
Message:

Widgets: Rename and soft deprecate retrieve_widgets().

The original name retrieve_widgets() was unclear as it suggested it was a getter, i.e. getting the widgets. This function does more than get: finds orphaned widgets, assigns them to the inactive sidebar, and updates the database.

The new name is sync_registered_widgets() which better represents what happens when this function is invoked.

The original retrieve_widgets() function is soft deprecated to avoid unnecessary code churn downstream for developers that support more than the latest version of WordPress.

Follow-up to [18630].

Props zieladam, timothyblynjacobs, andraganescu, hellofromTonya.
See #53811.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r51391 r51705  
    12521252    }
    12531253
    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.
    12591261 *
    12601262 * @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 */
     1269function 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
    12611278 *
    12621279 * @global array $wp_registered_sidebars Registered sidebars.
     
    12681285 * @return array Updated sidebars widgets.
    12691286 */
    1270 function retrieve_widgets( $theme_changed = false ) {
     1287function sync_registered_widgets( $theme_changed = false ) {
    12711288    global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
    12721289
Note: See TracChangeset for help on using the changeset viewer.