Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Must have CFS_Options_Screens plugin installed - https://wordpress.org/plugins/cfs-options-screens/
- * CFS Field Groups must have no placement rules
- * Names of the fields should be placed in the array
- * EX: $sb_option_screen_field_group_titles = array( 'Interior Header Images' , 'Menu Resources' );
- * The above example should be placed in functions.php
- * Make sure to uncommented the add_filter below
- */
- if ( ! function_exists( 'sb_cfs_options_screen' ) ) {
- function sb_cfs_options_screen( $screens ) {
- global $sb_option_screen_field_group_titles;
- // Check to see if global list of options screens exists
- if ( ! isset( $sb_option_screen_field_group_titles ) || empty( $sb_option_screen_field_group_titles ) ) {
- return $screens;
- }
- // Creates an array containing the post ids of the chosen field groups
- $cfs_field_ids = array_map( function( $post_title ) {
- $cfs_post = get_page_by_title( $post_title, OBJECT, 'cfs' );
- if ( ! is_null( $cfs_post ) ) {
- return $cfs_post->ID;
- }
- }, $sb_option_screen_field_group_titles );
- // Adds this option screen
- $screens[] = array(
- 'name' => 'options',
- 'menu_title' => __( 'Site Options' ),
- 'page_title' => __( 'Options' ),
- 'menu_position' => 100,
- 'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default
- 'field_groups' => $cfs_field_ids, // post ID(s) of CFS Field Group to use on this page
- );
- return $screens;
- }
- add_filter( 'cfs_options_screens', 'sb_cfs_options_screen');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement