[wordpress插件] Custom Options自订选项

wordpress 插件 文章 2020-04-08 20:30 484 0 全屏看文

AI助手支持GPT4.0

评分
20
描述

Allows you to create custom options that you can easily update via the Options administration panel and also allows you to use mentioned options in your theme using a simple PHP function:

允许您创建自定义选项,可以通过 Options 管理面板轻松更新这些选项,还可以使用简单的PHP函数在主题中使用上述选项:

get_custom_option ( $slug [, $default_value, $field ] )

  get_custom_option($ slug [,$ default_value,$ field])

By default, only Administrators can change Custom Options, however you can use the filter gsp_custom_options_capability to change that.

默认情况下,只有管理员可以更改“自定义选项”,但是您可以使用过滤器 gsp_custom_options_capability 进行更改。

For example, if you wish to allow Editors to use Custom Options you can add this to your functions.php file:

例如,如果您希望允许编辑者使用“自定义选项”,则可以将其添加到functions.php文件中:

function custom_options_capability ($capability) {    

  function custom_options_capability($ capability){    

return 'publish_pages';

返回'publish_pages';

}

}

add_filter ( 'gsp_custom_options_capability', 'custom_options_capability' );

add_filter('gsp_custom_options_capability','custom_options_capability');

Very simple, yet efficient.

非常简单,但高效。

安装步骤

    1. Upload the folder custom-options to the /wp-content/plugins/ directory
    2. 将文件夹 custom-options 上载到 / wp-content / plugins / 目录

    3. Activate the plugin through the Plugins menu in WordPress
    4. 通过WordPress中的 Plugins 菜单激活插件

    5. Update the plugin through the Options menu in WordPress
    6. 通过WordPress中的 Options 菜单更新插件

    7. Use Custom Options in your theme through the PHP function get_custom_option( $slug, $default_value )
    8. 通过PHP函数 get_custom_option($ slug,$ default_value) 在主题中使用自定义选项

    9. Don’t forget to precede the function by an echo if you want to output it
    10. 如果要输出该功能,请不要忘记在该功能之前加上 echo

下载地址
https://downloads.wordpress.org/plugin/custom-options.zip
-EOF-

AI助手支持GPT4.0