Layers_Customizer_Defaults

Customizer Default Settings File.

Defined (1)

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

/core/customizer/defaults.php  
  1. class Layers_Customizer_Defaults { 
  2.  
  3. public $prefix; 
  4.  
  5. public $config; 
  6.  
  7. private static $instance; // stores singleton class 
  8.  
  9. /** 
  10. * Get Instance creates a singleton class that's cached to stop duplicate instances 
  11. */ 
  12. public static function get_instance() { 
  13. if ( ! self::$instance ) { 
  14. self::$instance = new self(); 
  15. self::$instance->init(); 
  16. return self::$instance; 
  17.  
  18. /** 
  19. * Construct empty on purpose 
  20. */ 
  21.  
  22. public function __construct() {} 
  23.  
  24. /** 
  25. * Init behaves like, and replaces, construct 
  26. */ 
  27.  
  28. public function init() { 
  29.  
  30. global $layers_customizer_defaults; 
  31.  
  32. // Setup prefix to use 
  33. $this->prefix = LAYERS_THEME_SLUG . '-'; 
  34.  
  35.  
  36. // Grab the customizer config 
  37. $this->config = Layers_Customizer_Config::get_instance(); 
  38.  
  39. foreach( $this->config->controls as $section_key => $controls ) { 
  40.  
  41. foreach( $controls as $control_key => $control_data ) { 
  42.  
  43. // Set key to use for the default 
  44. $setting_key = $this->prefix . $control_key; 
  45.  
  46. // Register default 
  47. $this->register_control_defaults( $setting_key, $control_data[ 'type' ], ( isset( $control_data['default'] ) ? $control_data['default'] : NULL ) ); 
  48.  
  49. $layers_customizer_defaults = apply_filters( 'layers_customizer_defaults', $layers_customizer_defaults ); 
  50.  
  51. /** 
  52. * Register Control Defaults 
  53. */ 
  54.  
  55. public function register_control_defaults( $key = NULL , $type = NULL, $value = NULL ) { 
  56.  
  57. global $layers_customizer_defaults; 
  58.  
  59. if( !isset( $layers_customizer_defaults ) ) $layers_customizer_defaults = array(); 
  60.  
  61. if( NULL != $key ) { 
  62. $layers_customizer_defaults[ $key ] = array( 
  63. 'value' => esc_attr( $value ),  
  64. 'type' =>$type 
  65. ); 
  66.