twindigital/wordpress-settings-api-class

WordPress 设置 API 抽象类

v1.3 2016-09-27 06:52 UTC

This package is auto-updated.

Last update: 2024-09-22 23:18:08 UTC


README

这是一个 PHP 类包装器,用于处理 WordPress 的 设置 API。提供了一种非常方便的方式来构建主题或插件选项面板。

包安装(通过 Composer)

要安装此包,请编辑您的 composer.json 文件

{
    "require": {
        "tareq1988/wordpress-settings-api-class": "dev-master"
    }
}

现在运行

$ composer install

使用示例

请检查 示例 文件夹中的 OOP 和过程示例。它们在 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 = getOption( $section );

    if ( isset( $options[$option] ) ) {
        return $options[$option];
    }

    return $default;
}

屏幕截图

Option Panel

常见问题

这个插件是做什么用的?

这是一个主要演示设置 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 ;)