Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /*
  2. * Must have CFS_Options_Screens plugin installed - https://wordpress.org/plugins/cfs-options-screens/
  3. * CFS Field Groups must have no placement rules
  4. * Names of the fields should be placed in the array
  5. * EX: $sb_option_screen_field_group_titles = array( 'Interior Header Images' , 'Menu Resources' );
  6. * The above example should be placed in functions.php
  7. * Make sure to uncommented the add_filter below
  8. */
  9. if ( ! function_exists( 'sb_cfs_options_screen' ) ) {
  10. function sb_cfs_options_screen( $screens ) {
  11. global $sb_option_screen_field_group_titles;
  12.  
  13. // Check to see if global list of options screens exists
  14. if ( ! isset( $sb_option_screen_field_group_titles ) || empty( $sb_option_screen_field_group_titles ) ) {
  15. return $screens;
  16. }
  17.  
  18. // Creates an array containing the post ids of the chosen field groups
  19. $cfs_field_ids = array_map( function( $post_title ) {
  20. $cfs_post = get_page_by_title( $post_title, OBJECT, 'cfs' );
  21. if ( ! is_null( $cfs_post ) ) {
  22. return $cfs_post->ID;
  23. }
  24. }, $sb_option_screen_field_group_titles );
  25.  
  26. // Adds this option screen
  27. $screens[] = array(
  28. 'name' => 'options',
  29. 'menu_title' => __( 'Site Options' ),
  30. 'page_title' => __( 'Options' ),
  31. 'menu_position' => 100,
  32. 'icon' => 'dashicons-admin-generic', // optional, dashicons-admin-generic is the default
  33. 'field_groups' => $cfs_field_ids, // post ID(s) of CFS Field Group to use on this page
  34. );
  35. return $screens;
  36. }
  37. add_filter( 'cfs_options_screens', 'sb_cfs_options_screen');
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement