Create options screens that utilize Custom Field Suite
Author: | Jonathan Christopher (profile at wordpress.org) |
WordPress version required: | 3.9 |
WordPress version tested: | 5.9.0 |
Plugin version: | 1.2.7 |
Added to WordPress repository: | 24-07-2014 |
Last updated: | 10-02-2022
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 100 |
Rated by: | 2 |
Plugin URI: | http://wordpress.org/plugins/cfs-options-scre... |
Total downloads: | 5 660 |
Active installs: | 600+ |
Click to start download |
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.
FAQ
ChangeLog