| 开发者 | jchristopher |
|---|---|
| 更新时间 | 2022年2月11日 01:11 |
| 捐献地址: | 去捐款 |
| PHP版本: | 3.9 及以上 |
| WordPress版本: | 5.9.0 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
$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.
cfs-options-screens to the /wp-content/plugins/ directoryYou must specify the Field Group Title(s) in the field_groups parameter when using the cfs_options_screens hook
$value = cfs_get_option( 'options_screen_name', 'field_name_from_field_group' );
cfs_get_optioncfs_options_screens_post_type_argscfs_get_options() function to retrieve all CFS data for an options screen