ardent.intent/wp-settings-adapter
最新稳定版本:0.3.1
Composer 安装命令:
composer require ardent.intent/wp-settings-adapter
包简介
An abstraction layer to ease the use of the Wordpress settings API.
README 文档
README
The Adapter is a declarative facade for the Wordpress Settings API. It is designed to handle the complexities behind the scenes and get out of your way so you can focus on what's really important.
Disregard the tangled, putrid spaghetti and optionalize your theme or plugin with ease!
Usage Example
use \ArdentIntent\WpSettingsAdapter\Adapter; global $pluginOptions; ($pluginOptions = Adapter::createPage( 'Theme Options', 'Not spaghetti.', 'manage_options', 'adapter-test', 'general', 'dashicons-flag', 2 ))->withSections([ ($general = $pluginOptions->createSection('general'))->withSettings([ $general->createSetting( 'test-1', 'An example text setting description.' )->ofType()->text(), $general->createSetting('test-2')->ofType()->color(), $general->createSetting('test-5')->ofType()->text(), ]), ($special = $pluginOptions->createSection('special'))->withSettings([ $special->createSetting( 'test-6', 'A short description of this setting.' )->ofType()->text(), $special->createSetting( 'test-3', 'An example select setting.' )->ofType()->select()->withValues([ 'apple' => 'Apple', 'pear' => 'Pear', 'pineapple' => 'Pineapple' ]), $special->createSetting('test-4')->ofType()->toggle(), ]) ])->withSubPages([ ($subPageOne = $pluginOptions->createSubPage( 'Subpage One', 'An example sub-page.', 'manage_options', 'adapter-test-sub-one', 'general', 1 ))->withSections([ ($general = $subPageOne->createSection('general'))->withSettings([ $general->createSetting('general-1')->ofType()->toggle(), $general->createSetting('general-2')->ofType()->select()->withValues([ 'go', 'touch', 'grass' ]) ]), ($social = $subPageOne->createSection('social'))->withSettings([ $general->createSetting('social-1', 'Social link 1.')->ofType()->text(), $general->createSetting('social-2', 'Social link 2.')->ofType()->text(), $general->createSetting('social-3')->ofType()->select()->withValues([ 'on' => 'On', 'off' => 'Off' ]) ]) ]), ($subPageTwo = $pluginOptions->createSubPage( 'Subpage Two', 'An example sub-page.', 'manage_options', 'adapter-test-sub-two', 'general', 2 ))->withSections([ ($whatever = $subPageTwo->createSection('whatever'))->withSettings([ $whatever->createSetting('what', 'Life is suffering.')->ofType()->toggle(), $whatever->createSetting('ever', 'No one understands me.')->ofType()->toggle() ]) ]) ])->register();
Development Mode
You may enable development mode by invoking the following method. Adapter::enableDevMode();
Enabling dev mode will result in the options being rendered with paste-able snippets that get the value of their respective option.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2022-10-04