wenprise / wordpress-settings-api
WordPress 设置 API 抽象类
1.3
2022-06-28 03:15 UTC
Requires
- php: >=5.2.4
This package is auto-updated.
Last update: 2024-09-26 05:51:52 UTC
README
这是一个处理 WordPress 设置 API 的 PHP 类封装器。它为构建主题或插件选项面板提供了一个非常便捷的方式。
包安装(通过 Composer)
要安装此包,请编辑您的 composer.json
文件
{ "require": { "wenprise/wordpress-settings-api": "dev-master" } }
现在运行
$ composer install
使用示例
请检查 示例 文件夹,其中包含面向对象和过程式示例。它们在 plugin.php 文件中调用。
更详细的教程可以在这里找到:这里。
检索已保存的选项
/** * Get the value of a settings field * * @param string $option settings field name * @param string $section the section name this field belongs to * @param string $default default text if it's not found * * @return mixed */ function prefix_get_option( $option, $section, $default = '' ) { $options = get_option( $section ); if ( isset( $options[$option] ) ) { return $options[$option]; } return $default; }
截图
常见问题解答
这个插件是用来做什么的?
这是一个主要演示设置 API PHP 类的插件
有什么功能?
插件或主题开发者可以轻松地使用设置 API 构建他们的选项面板
什么是设置 API?
设置 API 是 WordPress 中的一个功能,帮助开发者轻松且安全地保存他们的选项数据。更多关于 设置 API 的信息。
变更日志
v1.3 (27 September, 2016)
------------------------
- [new] Placeholder support for text and textarea input
- [new] min, max and step support for number field
- [fix] Empty multicheck saving warning
- [improved] Don't show the navigation if only one section exists
v1.1 (23 April, 2015)
------------------------
- [new] Folder structure updated
- [new] composer support added
- [new] Number field added
- [new] URL field added
- [improved] wysiwyg field responsive support. Allow to pass options to wp_editor
- [new] WP Media uploader added
v1.0 (16 July, 2014)
------------------------
- [new] color, password and wysiwyg example added on plugin settings
- [new] Color Picker added
- [improved] Allow to set description for section
- Some other old fixes ;)