wpessential/wpessential-sidebars

WPEssential Sidebars helping in registry of sidebars in WordPress.

2.0.2 2025-03-19 14:03 UTC

This package is auto-updated.

Last update: 2025-05-19 14:20:10 UTC


README

Help to register the sidebars in WordPress.

composer require wpessential/wpessential-sidebars

Add the single sidebar to WordPress registry

$sidebar = \WPEssential\Library\Sidebars::make();
$sidebar->add([
	'id'		=>'main-sidebar',
        'name'          => esc_html__( 'WPEssential: Main Sidebar', 'wpessential' ),
        'description'   => esc_html__( 'Widgets in this area will be shown on all posts and pages.', 'wpessential' ),
        'title_tag' 	=> 'h2'
]);
$sidebar->init();

Add the multiple sidebars to WordPress registry

$sidebar = \WPEssential\Library\Sidebars::make();
$sidebar->adds([
    	'main-sidebar'   => [
        'name'          => esc_html__( 'WPEssential: Main Sidebar', 'wpessential' ),
        'description'   => esc_html__( 'Widgets in this area will be shown on all posts and pages.', 'wpessential' ),
        'title_tag' 	=> 'h2'
    ]
]);
$sidebar->init();

Remove the single sidebar from WordPress registry

$sidebar = \WPEssential\Library\Sidebars::make();
$sidebar->remove('main-sidebar');
$sidebar->init();

Remove the multiple sidebars from WordPress registry

$sidebar = \WPEssential\Library\Sidebars::make();
$sidebar->removes(['main-sidebar']);
$sidebar->init();