layers_insert_config_elements_after

The Layers layers insert config elements after function.

Description

layers_insert_config_elements_after( $key, $config, $new_elements ); 

Parameters (3)

0. $key
The key.
1. $config
The config.
2. $new_elements
The new elements.

Usage

  1. if ( !function_exists( 'layers_insert_config_elements_after' ) ) { 
  2. require_once '/core/helpers/controls.php'; 
  3.  
  4. // The key. 
  5. $key = null; 
  6.  
  7. // The config. 
  8. $config = null; 
  9.  
  10. // The new elements. 
  11. $new_elements = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = layers_insert_config_elements_after($key, $config, $new_elements); 
  15.  

Defined (1)

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

/core/helpers/controls.php  
  1. function layers_insert_config_elements_after( $key, $config, $new_elements ) { 
  2.  
  3. if ( isset( $config[$key] ) ) { 
  4.  
  5. /** 
  6. * This case is for one-dimentional config arrays e.g. Sections, Panels 
  7. */ 
  8. $offset = ( array_search( $key, array_keys( $config ) ) ) + 1; 
  9.  
  10. $config = array_slice( $config, 0, $offset, true ) + 
  11. $new_elements + 
  12. array_slice( $config, $offset, count( $config ) - 1, true ); 
  13. else { 
  14.  
  15. /** 
  16. * This case is for multi-dimentional config arrays e.g. Controls 
  17. */ 
  18. foreach ( $config as $group_key => $group_array ) { 
  19.  
  20. if ( isset( $group_array[$key] ) ) { 
  21.  
  22. $offset = ( array_search( $key, array_keys( $group_array ) ) ) + 1; 
  23.  
  24. $group_array = array_slice( $group_array, 0, $offset, true ) + 
  25. $new_elements + 
  26. array_slice( $group_array, $offset, count( $group_array ) - 1, true ); 
  27.  
  28. $config[$group_key] = $group_array; 
  29.  
  30. return $config;