monsterinsights_get_registered_settings_types

Flattens the set of registered settings and their type so we can easily sanitize all the settings in a much cleaner set of logic in monsterinsights_settings_sanitize.

Description

(array) monsterinsights_get_registered_settings_types( (string) $section = '' ); 

Returns (array)

Key is the setting ID, value is the type of setting it is registered as

Parameters (1)

0. $section — Optional. (string) => ''
The section.

Usage

  1. if ( !function_exists( 'monsterinsights_get_registered_settings_types' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/settings/settings-api.php'; 
  3.  
  4. // The section. 
  5. $section = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = monsterinsights_get_registered_settings_types($section); 
  9.  

Defined (1)

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

/includes/admin/settings/settings-api.php  
  1. function monsterinsights_get_registered_settings_types( $section = '' ) { 
  2. $setting_types = array(); 
  3. if ( ! empty( $section ) ) { 
  4. if ( ! empty( $settings[$section] ) ) { 
  5. foreach ( $settings[$section] as $setting ) { 
  6. if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) { 
  7. $setting_types[ $setting['id'] ] = $setting['type']; 
  8. } else { 
  9. foreach ( $settings as $tab ) { 
  10. foreach ( $tab as $setting ) { 
  11. if ( is_array( $setting ) && array_key_exists( 'type', $setting ) ) { 
  12. $setting_types[ $setting['id'] ] = $setting['type']; 
  13. return $setting_types;