WidgetAreas final class
Minn\Runtime\WidgetAreas · public/minn/src/Minn/Runtime/WidgetAreas.php · 331 lines
The widgets helper functions as the reference answers them (probe widget-helpers): a widget id split into its base and number, a sidebar by id (the inactive widgets are a sidebar too, with a name and nothing else), finding and moving a widget between sidebars, one widget rendered in its sidebar as dynamic_sidebar renders each (an unregistered widget renders nothing), and the sidebars with every registered one present; the stored sidebars read and written, and which are registered.
Constants and properties
| private | DEFAULT_WIDGETS = array ( 0 => 'WP_Widget_Pages', 1 => 'WP_Widget_Calendar', 2 => 'WP_Widget_Archives', 3 => 'WP_Widget_Media_Audio', 4 => 'WP_Widget_Media_Image', 5 => 'WP_Widget_Media_Gallery', 6 => 'WP_Widget_Media_Video', 7 => 'WP_Widget_Meta', 8 => 'WP_Widget_Search', 9 => 'WP_Widget_Text', 10 => 'WP_Widget_Categories', 11 => 'WP_Widget_Recent_Posts', 12 => 'WP_Widget_Recent_Comments', 13 => 'WP_Widget_RSS', 14 => 'WP_Widget_Tag_Cloud', 15 => 'WP_Nav_Menu_Widget', 16 => 'WP_Widget_Custom_HTML', 17 => 'WP_Widget_Block', ) | The widgets the engine provides. |
| const | INACTIVE = 'wp_inactive_widgets' | |
| private | MAPPING_GROUPS = array ( 0 => array ( 0 => 'sidebar', 1 => 'primary', 2 => 'main', 3 => 'right', ), 1 => array ( 0 => 'second', 1 => 'left', ), 2 => array ( 0 => 'sidebar-2', 1 => 'footer', 2 => 'bottom', ), 3 => array ( 0 => 'header', 1 => 'top', ), ) | The id fragments a theme switch matches sidebars by, group by group (probe sidebars-mapping). |
Public
| static | registerDefaults(): void# | The widgets the engine provides registered, then widgets_init for plugin and theme code (wp_widgets_init); the Links widget only while the link manager is on. The block widget is the one every modern sidebar is made of, so it is registered before the action runs. | ||||||||||||
| static | show(mixed $widget, mixed $instance = array ( ), mixed $args = array ( )): void# | A registered widget shown outside a sidebar (the_widget), in a div with its class unless the arguments say otherwise. | ||||||||||||
| static | stored(mixed $deprecated = true): mixed# | The stored sidebars and their widgets (wp_get_sidebars_widgets), as sidebars_widgets leaves them. @return array<string, mixed> | ||||||||||||
| static | convertSettings(string $base, mixed $settings): array# | A widget's settings in the numbered form (wp_convert_widget_settings, probe blocks-rest-widget-doubts): settings that are empty or not keyed by number are a single widget's, made number 2, and the sidebars this request holds name it by its new id; every result is marked a multi-widget's. Nothing is stored. @return array<int|string, mixed> | ||||||||||||
| static | convertStoredSettings(string $base, string $option, mixed $settings): array# | The same conversion as the admin makes it: a single widget's new id goes into the stored sidebars (not this request's), and the settings are stored under their option either way. @return array<int|string, mixed> | ||||||||||||
| static | store(mixed $sidebars): void# | The sidebars stored (wp_set_sidebars_widgets), at array version 3. | ||||||||||||
| static | current(mixed $themeChanged = false): array# | The sidebars with every registered one present and the widgets that lost theirs inactive (retrieve_widgets), stored; before widgets_init, the stored ones with the registered areas filled in empty. @return array<string, mixed> | ||||||||||||
| static | isRegistered(mixed $id): bool# | Whether a sidebar is registered (is_registered_sidebar). | ||||||||||||
| static | parse(string $id): array# | wp_parse_widget_id: ['id_base' => ..., 'number' => n], or the id alone as its base. @return array{id_base: string, number?: int} @return array{id_base: string, number?: int} | ||||||||||||
| static | sidebar(string $id): ?array# | wp_get_sidebar: a registered sidebar, the inactive widgets, or null. @return array<string, mixed>|null @return array<string, mixed>|null | ||||||||||||
| static | find(string $widgetId): ?string# | wp_find_widgets_sidebar: the sidebar holding a widget, or null. | ||||||||||||
| static | assign(string $widgetId, string $sidebarId): void# | wp_assign_widget_to_sidebar: out of every sidebar, then onto the end of one ('' leaves it in none). | ||||||||||||
| static | render(string $widgetId, string $sidebarId): string# | wp_render_widget: a registered widget as its sidebar wraps it, through dynamic_sidebar_params; '' otherwise. | ||||||||||||
| static | control(string $widgetId): ?string# | wp_render_widget_control: a registered widget's settings form, or null. | ||||||||||||
| static | retrieve(array $stored, array $areas, array $registered): array# | retrieve_widgets (probe widgets-remaining): the inactive list, then every registered sidebar, holding only widgets that are registered. The inactive list takes, in order, the registered widgets no list mentions (the -1 placeholders aside, in the order they were registered), the widgets already inactive, and the widgets of sidebars no longer registered, which go.
@return array<string, array<int, string>> | ||||||||||||
| static | map(array $existing, array $areas, array $stored, array $registered): array# | The old theme's widget lists fitted to the new theme's sidebars (probe sidebars-mapping). One old sidebar and one new map straight across. Otherwise a sidebar of the same id keeps its widgets; then, group by group, the new sidebars whose ids hold one of the group's fragments take, in order, the old ones that do (a new sidebar may take from several groups); what is left goes after the inactive widgets. When nothing is inactive then, the stored inactive widgets that are registered and placed nowhere come back, keys kept.
@return array<string, array<array-key, mixed>> |
Internals 4
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | numbered(mixed $settings): array# | @return array{0: array<int|string, mixed>, 1: bool} the settings numbered and marked, and whether they were a single widget's | ||||||
| private | renamed(array $sidebars, string $base): array# |
| ||||||
| private | inGroup(string $id, array $fragments): bool# |
| ||||||
| private | unmentioned(array $stored, array $registered): array# | Registered widgets no stored list mentions, the -1 placeholders aside.
@return list<string> |
Nothing matches.