WidgetAreas final class
Minn\Runtime\WidgetAreas · public/minn/src/Minn/Runtime/WidgetAreas.php · 184 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.
Constants and properties
| 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 | 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, list<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 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.