CFS Options Screens

CFS Options Screens Install Statistics

0
100%
Today: 0 Yesterday: 0 All-time: 5,638 downloads
CFS Options Screens Icon

Try plugin: CFS Options Screens

We'll create fresh WordPress site with CFS Options Screens installed. You have 20 minutes to test the plugin after that site we'll be deleted.

Takes ~10 seconds to install.

About CFS Options Screens

Create options screens that utilize Custom Field Suite

2


0


0


0


0

updated: 2 years ago
since: 10 years ago

Description

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.