register_field_group

The Advanced Custom Fields register field group function.

Description

register_field_group( $array ); 

Parameters (1)

0. $array
The array.

Usage

  1. if ( !function_exists( 'register_field_group' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-custom-fields/core/api.php'; 
  3.  
  4. // The array. 
  5. $array = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = register_field_group($array); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/api.php  
  1. function register_field_group( $array ) 
  2. // add id 
  3. if( !isset($array['id']) ) 
  4. $array['id'] = uniqid(); 
  5.  
  6.  
  7. // 3.2.5 - changed show_on_page option 
  8. if( !isset($array['options']['hide_on_screen']) && isset($array['options']['show_on_page']) ) 
  9. $show_all = array('the_content', 'discussion', 'custom_fields', 'comments', 'slug', 'author'); 
  10. $array['options']['hide_on_screen'] = array_diff($show_all, $array['options']['show_on_page']); 
  11. unset( $array['options']['show_on_page'] ); 
  12.  
  13.  
  14. // 4.0.4 - changed location rules architecture 
  15. if( isset($array['location']['rules']) ) 
  16. // vars 
  17. $groups = array(); 
  18. $group_no = 0; 
  19.  
  20.  
  21. if( is_array($array['location']['rules']) ) 
  22. foreach( $array['location']['rules'] as $rule ) 
  23. $rule['group_no'] = $group_no; 
  24.  
  25. // sperate groups? 
  26. if( $array['location']['allorany'] == 'any' ) 
  27. $group_no++; 
  28.  
  29.  
  30. // add to group 
  31. $groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule; 
  32.  
  33.  
  34. // sort rules 
  35. ksort( $groups[ $rule['group_no'] ] ); 
  36.  
  37.  
  38. // sort groups 
  39. ksort( $groups ); 
  40.  
  41. $array['location'] = $groups; 
  42.  
  43.  
  44. $GLOBALS['acf_register_field_group'][] = $array;