Create options screens that utilize Custom Field Suite
评级
5
最后更新
February 10, 2022
版本
1.2.7
活跃安装
600

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. You can then register any number of options screens like so:

function my_cfs_options_screens( $screens ) { $screens[] = array( 'name' => 'options', 'menu_title' => __( 'Site Options' ), 'page_title' => __( 'Customize Site Options' ), 'menu_position' => 100, 'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default 'field_groups' => array( 'My Field Group' ), // Field Group name(s) of CFS Field Group to use on this page (can also be post IDs) ); return $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' );

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

function my_cfs_options_screens( $screens ) { // Parent $screens[] = array( 'name' => 'options', 'field_groups' => array( 'My Parent Field Group Name' ), ); // Child $screens[] = array( 'name' => 'options-nav', 'parent' => 'options', // name of the parent 'field_groups' => array( 'My Child Field Group Name' ), ); return $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. The CFS Options Screen will act as the default/fallback and the post edit screen will override those defaults.

function my_cfs_options_screens( $screens ) { $screens[] = array( 'name' => 'options', 'menu_title' => __( 'Site Options' ), 'page_title' => __( 'Customize Site Options' ), 'menu_position' => 100, 'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default 'field_groups' => array( array( 'title' => 'My CFS Field Group Name', 'has_overrides' => true, ), ), ); return $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.

免费使用Creator套餐
活跃安装
600
目前已测试版本
5.9.0
此插件可供下载,可用于您的 WordPress 自托管安装。