Sidebars
in package
Sidebars Registration class.
Enables the batch registration of sidebars, simplifying the process of adding multiple dynamic widget areas within a WordPress theme. Utilizes the Sidebar module for each sidebar's registration, ensuring that sidebars are registered in accordance with WordPress standards and best practices.
Tags
Table of Contents
Methods
- set() : void
- Registers multiple sidebars in bulk.
Methods
set()
Registers multiple sidebars in bulk.
public
static set([array<string|int, mixed> $sidebars = [] ]) : void
This method simplifies the registration of custom sidebars by accepting an array of sidebar definitions. Each definition specifies the sidebar's properties, such as ID, name, description, and widget wrappers, allowing for comprehensive and flexible sidebar creation.
Example usage:
Sidebars::set([
[
'id' => 'header-widget',
'name' => __('Header Widget Area', 'text-domain'),
'description' => __('A widget area for the site header.', 'text-domain'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
],
...
]);
Parameters
- $sidebars : array<string|int, mixed> = []
-
An array of sidebar definitions. Each definition is an associative array that includes the sidebar's properties, such as 'id', 'name', 'description', 'before_widget', 'after_widget', 'before_title', and 'after_title'.