[wordpress插件] CFS Options ScreensCFS选项屏幕

wordpress 插件 文章 2020-03-21 08:50 419 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Build any number of options screens based on Custom Field Suite.

基于自定义字段套件构建任意数量的选项屏幕。

For Example

例如

Begin by creating Field Group(s) you want to include on your options screen.

首先创建要包括在选项屏幕中的字段组。

Be sure to set NO Placement Rules. Once it’s created, note the post ID it uses.

请确保设置“无放置规则”。创建后,记下它使用的帖子ID。

You can then register any number of options screens like so:

然后,您可以注册任意数量的选项屏幕,如下所示:

function my_cfs_options_screens( $screens ) {    

  function my_cfs_options_screens($ screens){    

$screens[] = array(        

$ screens [] = array(        

'name' => 'options',        

'名称'=>'选项',        

'menu_title' => __( 'Site Options' ),        

'menu_title'=> __('站点选项'),        

'page_title' => __( 'Customize Site Options' ),        

'page_title'=> __('自定义网站选项'),        

'menu_position' => 100,        

'menu_position'=> 100,        

'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default        

'icon'=>'dashicons-admin-generic',//可选,dashicons-admin-generic是默认值        

'field_groups' => array( 'My Field Group' ), // Field Group name(s) of CFS Field Group to use on this page (can also be post IDs)    

'field_groups'=> array('My Field Group'),//要在此页面上使用的CFS字段组的字段组名称(也可以是帖子ID)    

);    

);    

return $screens;

返回$ screens;

}

}

add_filter( 'cfs_options_screens', 'my_cfs_options_screens' );

add_filter('cfs_options_screens','my_cfs_options_screens');

Retrieve your options like so:

像这样检索您的选项:

$value = cfs_get_option( 'options_screen_name', 'cfs_field_name_from_field_group' );

  $ value = cfs_get_option('options_screen_name','cfs_field_name_from_field_group');

You can set up multiple top level and/or children options pages by adding a parent argument when registering your screen:

您可以通过在注册屏幕时添加 parent 自变量来设置多个顶级和/或子级选项页:

function my_cfs_options_screens( $screens ) {    

  function my_cfs_options_screens($ screens){    

// Parent    

//父级    

$screens[] = array(        

$ screens [] = array(        

'name' => 'options',        

'名称'=>'选项',        

'field_groups' => array( 'My Parent Field Group Name' ),    

'field_groups'=> array('我的父字段组名称'),    

);    

);    

// Child    

//孩子    

$screens[] = array(        

$ screens [] = array(        

'name' => 'options-nav',        

'名称'=>'选项导航',        

'parent' => 'options', // name of the parent        

'parent'=>'options',//父母的名字        

'field_groups' => array( 'My Child Field Group Name' ),    

'field_groups'=> array('我的子字段组名称'),    

);    

);    

return $screens; 

返回$ screens; 

add_filter( 'cfs_options_screens', 'my_cfs_options_screens' );

add_filter('cfs_options_screens','my_cfs_options_screens');

You can also use CFS Options Screens to set up Field Group ‘defaults’, allowing a Field Group to appear both on a CFS Options Screen and a post edit screen.

您还可以使用CFS选项屏幕设置字段组“默认值”,从而允许字段组同时出现在CFS选项屏幕和后期编辑屏幕上。

The CFS Options Screen will act as the default/fallback and the post edit screen will override those defaults.

CFS选项屏幕将充当默认值/后备,而帖子编辑屏幕将覆盖这些默认值。

function my_cfs_options_screens( $screens ) {    

  function my_cfs_options_screens($ screens){    

$screens[] = array(        

$ screens [] = array(        

'name' => 'options',        

'名称'=>'选项',        

'menu_title' => __( 'Site Options' ),        

'menu_title'=> __('站点选项'),        

'page_title' => __( 'Customize Site Options' ),        

'page_title'=> __('自定义网站选项'),        

'menu_position' => 100,        

'menu_position'=> 100,        

'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default        

'icon'=>'dashicons-admin-generic',//可选,dashicons-admin-generic是默认值        

'field_groups' => array(            

'field_groups'=>数组(            

array(                

数组(                

'title' => 'My CFS Field Group Name',                

'title'=>'我的CFS字段组名称',                

'has_overrides' => true,            

'has_overrides'=>是,            

),        

),        

),    

),    

);    

);    

return $screens;

返回$ screens;

}

}

add_filter( 'cfs_options_screens', 'my_cfs_options_screens' );

add_filter('cfs_options_screens','my_cfs_options_screens');

Check out the cfs_options_screens_override_note_default and cfs_options_screens_override_note_override filters to customize the messaging for CFS Options Screens overrides.

签出 cfs_options_screens_override_note_default cfs_options_screens_override_note_override 过滤器,以自定义CFS选项屏幕替代消息。

安装步骤

    1. Upload cfs-options-screens to the /wp-content/plugins/ directory
    2. cfs-options-screens 上载到 / wp-content / plugins / 目录

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

    5. Register your options screen(s) using the code snippets from this readme
    6. 使用本自述文件中的代码段注册您的选项屏幕

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

AI助手支持GPT4.0