[wp-trac] [WordPress Trac] #53811: Rename `retrieve_widgets` to `recover_lost_widgets`
WordPress Trac
noreply at wordpress.org
Wed Jul 28 12:27:14 UTC 2021
#53811: Rename `retrieve_widgets` to `recover_lost_widgets`
-------------------------------------------------+-------------------------
Reporter: zieladam | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests 2nd- | Focuses:
opinion |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests 2nd-
opinion
Comment:
The `retrieve_widgets` function does more than retrieve hidden or lost
widgets. In essence, it is rebuilding the global `$sidebars_widgets` by:
- Remapping widgets (in each sidebar) against the widget registry ->
`_wp_remove_unregistered_widgets()`
- Remapping sidebars against the sidebar registry ->
`wp_map_sidebars_widgets()`
- Finding all hidden or lost widgets and assigning them to the inactive
sidebar
- Updating the database with the new `$sidebars_widgets` configuration
- Returning `$sidebars_widgets`
It does retrieve all of the widgets but in that retrieval process it's
doing a validation process, finding all of lost widgets, and updating
state and the db.
The middle chunk of the function that finds the hidden and lost widgets
could be moved to a private function named `_wp_recover_lost_widgets`.
Then the `retrieve_widgets` function would be more of a task runner by
invoking more specific granular tasks that are encapsulated in separate
functions.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53811#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list