wpessential/wpessential-sidebars

WPEssential Sidebars 帮助在WordPress中注册侧边栏。

2.0.1 2024-09-10 22:55 UTC

This package is auto-updated.

Last update: 2024-09-10 23:01:19 UTC


README

帮助注册WordPress中的侧边栏。

composer require wpessential/wpessential-sidebars

将单个侧边栏添加到WordPress注册表

$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();

将多个侧边栏添加到WordPress注册表

$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();

从WordPress注册表中删除单个侧边栏

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

从WordPress注册表中删除多个侧边栏

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