SidebarsController final readonly class
Minn\Rest\SidebarsController · public/minn/src/Minn/Rest/SidebarsController.php · 206 lines
wp/v2/sidebars and wp/v2/widget-types as the reference answers them (probe rest-widgets), for anyone who can edit theme options. A sidebar is a registered one or the inactive widgets, with its wrapping markup, the registered widgets it holds, and its status: active when registered under a classic theme (a block theme renders none). Saving a sidebar's widgets takes them from any other sidebar and sends the ones it drops to the inactive widgets. The widget types are the registered widgets by id base, in id order.
Constants and properties
| private | BODY = array ( 'widgets' => array ( 'description' => 'Nested widgets.', 'type' => 'array', 'items' => array ( 'type' => array ( 0 => 'object', 1 => 'string', ), ), 'required' => false, ), ) | |
| private | REFUSAL = 'Sorry, you are not allowed to manage widgets on this site.' | |
| private | readonly Minn\Rest\RestUrl $url | Promoted from the constructor. |
| private | readonly Minn\Rest\Caller $caller | Promoted from the constructor. |
Public
| new | __construct(Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)# | |
| method | sidebars(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/sidebars (public)# | Every sidebar: those the sidebars option lists, then any other registered one. Someone who cannot edit theme options sees only the sidebars shown in REST, and is refused when there are none (probe rest-sidebar-classes). |
| method | sidebar(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/sidebars/{id:[\w-]+} (public)# | One sidebar: anyone's to read when it is shown in REST, otherwise for someone who can edit theme options. |
| method | save(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/sidebars/{id:[\w-]+} (cap edit_theme_options)PUT /wp/v2/sidebars/{id:[\w-]+} (cap edit_theme_options)PATCH /wp/v2/sidebars/{id:[\w-]+} (cap edit_theme_options)# | Saves a sidebar's widgets, in the order given. |
| method | types(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/widget-types (cap edit_theme_options)# | The registered widget types, by id base. |
| method | widgetType(Minn\Http\Request $request, string $id): Minn\Http\ResponseGET /wp/v2/widget-types/{id:[a-zA-Z0-9_-]+} (cap edit_theme_options)# | One widget type. |
| method | encode(Minn\Http\Request $request, string $id): Minn\Http\ResponsePOST /wp/v2/widget-types/{id:[a-zA-Z0-9_-]+}/encode (cap edit_theme_options)# | A widget type's form and preview for settings that are not saved: the settings sent (encoded with their hash) updated from the form's fields, the form for them (number -1 unless one is sent), the widget as the_widget shows it, and the settings encoded again. |
| static | ready(): void# | The widgets are registered on init; a runtime that stopped short of it registers them now. Without the runtime there are no widgets to serve. |
Internals 4
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.