| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Creates and validates field parameters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package     Kirki | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @category    Core | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author      Aristeides Stathopoulos | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @copyright   Copyright (c) 2017, Aristeides Stathopoulos | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @since       1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * Please do not use this class directly. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * You should instead extend it per-field-type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class Kirki_Field { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 * An array of the field arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	protected $args = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 * The ID of the kirki_config we're using. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	 * @see Kirki_Config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	protected $kirki_config = 'global'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 * Thje capability required so that users can edit this field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	protected $capability = 'edit_theme_options'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	 * If we're using options instead of theme_mods | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * and we want them serialized, this is the option that | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 * will saved in the db. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	protected $option_name = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 * Custom input attributes (defined as an array). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	protected $input_attrs = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * Use "theme_mod" or "option". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	protected $option_type = 'theme_mod'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	 * The name of this setting (id for the db). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * @var string|array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	protected $settings = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	 * Set to true if you want to disable all CSS output for this field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	protected $disable_output = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	 * The field type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	protected $type = 'kirki-generic'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	 * Some fields require options to be set. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	 * We're whitelisting the property here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	 * and suggest you validate this in a child class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	protected $choices = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	 * Assign this field to a section. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * Fields not assigned to a section will not be displayed in the customizer. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	protected $section = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	 * The default value for this field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	 * @var string|array|bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	protected $default = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	 * Priority determines the position of a control inside a section. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	 * Lower priority numbers move the control to the top. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 	 * @var int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 	protected $priority = 10; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 	 * Unique ID for this field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	 * This is auto-calculated from the $settings argument. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	protected $id = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * Use if you want to automatically generate CSS from this field's value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	 * @see https://kirki.org/docs/arguments/output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	protected $output = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	 * Use to automatically generate postMessage scripts. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	 * Not necessary to use if you use 'transport' => 'auto' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	 * and have already set an array for the 'output' argument. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	 * @see https://kirki.org/docs/arguments/js_vars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	protected $js_vars = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	 * If you want to use a CSS compiler, then use this to set the variable names. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * @see https://kirki.org/docs/arguments/variables | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	protected $variables = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	 * Text that will be used in a tooltip to provide extra info for this field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	protected $tooltip = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 * A custom callback to determine if the field should be visible or not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 	 * @var string|array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	protected $active_callback = '__return_true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 	 * A custom sanitize callback that will be used to properly save the values. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	 * @var string|array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	protected $sanitize_callback = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 * Use 'refresh', 'postMessage' or 'auto'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 	 * 'auto' will automatically geberate any 'js_vars' from the 'output' argument. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 	 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 	protected $transport = 'refresh'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	 * Define dependencies to show/hide this field based on the values of other fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	protected $required = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	 * Partial Refreshes array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 	protected $partial_refresh = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	 * The class constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 * Parses and sanitizes all field arguments. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	 * Then it adds the field to Kirki::$fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 	 * @param string $config_id    The ID of the config we want to use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 	 *                             Defaults to "global". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	 *                             Configs are handled by the Kirki_Config class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	 * @param array  $args         The arguments of the field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	public function __construct( $config_id = 'global', $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 			/* translators: %s represents the field ID where the error occurs. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 			$args['settings'] = $args['setting']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 			unset( $args['setting'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		// In case the user only provides 1 argument, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 		// assume that the provided argument is $args and set $config_id = 'global'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 		if ( is_array( $config_id ) && empty( $args ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 			$args = $config_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 			$config_id = 'global'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 		$args['kirki_config'] = $config_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		$this->kirki_config = trim( esc_attr( $config_id ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 		if ( '' === $config_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 			$this->kirki_config = 'global'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 		// Get defaults from the class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		$defaults = get_class_vars( __CLASS__ ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 		// Get the config arguments, and merge them with the defaults. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 		$config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 		if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 			$config_defaults = Kirki::$config[ $this->kirki_config ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		$config_defaults = ( is_array( $config_defaults ) ) ? $config_defaults : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 		foreach ( $config_defaults as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			if ( isset( $defaults[ $key ] ) && ! empty( $value ) && $value !== $defaults[ $key ] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 				$defaults[ $key ] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 		// Merge our args with the defaults. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		// Set the class properties using the parsed args. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 		foreach ( $args as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 			$this->$key = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 		$this->args = $args; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 		$this->set_field(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 	 * Processes the field arguments | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 	protected function set_field() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 		$properties = get_class_vars( __CLASS__ ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 		// Some things must run before the others. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 		$this->set_option_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 		$this->set_option_type(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		$this->set_settings(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		// Sanitize the properties, skipping the ones that have already run above. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		foreach ( $properties as $property => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 			if ( in_array( $property, array( 'option_name', 'option_type', 'settings' ), true ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 			if ( method_exists( $this, 'set_' . $property ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 				$method_name = 'set_' . $property; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 				$this->$method_name(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 		// Get all arguments with their values. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		$args = get_object_vars( $this ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		foreach ( array_keys( $args ) as $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 			$args[ $key ] = $this->$key; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 		// Add the field to the static $fields variable properly indexed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 		Kirki::$fields[ $this->settings ] = $args; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 	 * Gets the classname from a property. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 	 * @access private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 	 * @since 3.0.10 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 	 * @param string $property The property. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 	 * @return string          A classname derived from the property. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 	private function get_property_classname( $property ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 		$property_parts = (array) $property; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		if ( false !== strpos( $property, '-' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 			$property_parts = explode( '-', $property ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		if ( false !== strpos( $property, '_' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 			$property_parts = explode( '_', $property ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		foreach ( $property_parts as $property_part_k => $property_part_v ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 			$property_parts[ $property_part_k ] = ucfirst( $property_part_v ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		return 'Kirki_Field_Property_' . implode( '_', $property_parts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 	 * Escape $kirki_config. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 	protected function set_kirki_config() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 		$this->kirki_config = esc_attr( $this->kirki_config ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 	 * Escape $option_name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 	protected function set_option_name() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 		$this->option_name = esc_attr( $this->option_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 	 * Escape the $section. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 	protected function set_section() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		$this->section = sanitize_key( $this->section ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 	 * Escape the $section. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 	protected function set_input_attrs() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 		if ( ! is_array( $this->input_attrs ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 			$this->input_attrs = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 	 * Checks the capability chosen is valid. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 	 * If not, then falls back to 'edit_theme_options' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 	protected function set_capability() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		// Early exit if we're using 'edit_theme_options'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 		if ( 'edit_theme_options' === $this->capability ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 		// Escape & trim the capability. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 		$this->capability = trim( esc_attr( $this->capability ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 	 * Make sure we're using the correct option_type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 	protected function set_option_type() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		// Take care of common typos. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		if ( 'options' === $this->option_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 			$this->option_type = 'option'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		// Take care of common typos. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 		if ( 'theme_mods' === $this->option_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 			/* translators: %1$s represents the field ID where the error occurs. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - "theme_mods" vs "theme_mod"', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 			$this->option_type = 'theme_mod'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 	 * Modifications for partial refreshes. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 	protected function set_partial_refresh() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		if ( ! is_array( $this->partial_refresh ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 			$this->partial_refresh = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		foreach ( $this->partial_refresh as $id => $args ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 			if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 				/* translators: %1$s represents the field ID where the error occurs. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 				_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 				unset( $this->partial_refresh[ $id ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 		if ( ! empty( $this->partial_refresh ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			$this->transport = 'postMessage'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 	 * Sets the settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 	 * If we're using serialized options it makes sure that settings are properly formatted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 	 * We'll also be escaping all setting names here for consistency. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 	 * @access protected | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 447 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 448 |  |  | 	protected function set_settings() { | 
            
                                                                        
                            
            
                                    
            
            
                | 449 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 450 |  |  | 		// If settings is not an array, temporarily convert it to an array. | 
            
                                                                        
                            
            
                                    
            
            
                | 451 |  |  | 		// This is just to allow us to process everything the same way and avoid code duplication. | 
            
                                                                        
                            
            
                                    
            
            
                | 452 |  |  | 		// if settings is not an array then it will not be set as an array in the end. | 
            
                                                                        
                            
            
                                    
            
            
                | 453 |  |  | 		if ( ! is_array( $this->settings ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 454 |  |  | 			$this->settings = array( | 
            
                                                                        
                            
            
                                    
            
            
                | 455 |  |  | 				'kirki_placeholder_setting' => $this->settings, | 
            
                                                                        
                            
            
                                    
            
            
                | 456 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 457 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 458 |  |  | 		$settings = array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 459 |  |  | 		foreach ( $this->settings as $setting_key => $setting_value ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 460 |  |  | 			$settings[ $setting_key ] = $setting_value; | 
            
                                                                        
                            
            
                                    
            
            
                | 461 |  |  | 			// If we're using serialized options then we need to spice this up. | 
            
                                                                        
                            
            
                                    
            
            
                | 462 |  |  | 			if ( 'option' === $this->option_type && '' !== $this->option_name && ( false === strpos( $setting_key, '[' ) ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 463 |  |  | 				$settings[ $setting_key ] = "{$this->option_name}[{$setting_value}]"; | 
            
                                                                        
                            
            
                                    
            
            
                | 464 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 465 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 466 |  |  | 		$this->settings = $settings; | 
            
                                                                        
                            
            
                                    
            
            
                | 467 |  |  | 		if ( isset( $this->settings['kirki_placeholder_setting'] ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 468 |  |  | 			$this->settings = $this->settings['kirki_placeholder_setting']; | 
            
                                                                        
                            
            
                                    
            
            
                | 469 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 470 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	 * Escapes the tooltip messages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 	protected function set_tooltip() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 		if ( '' !== $this->tooltip ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 			$this->tooltip = wp_strip_all_tags( $this->tooltip ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 	 * Sets the active_callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 	 * If we're using the $required argument, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 	 * Then this is where the switch is made to our evaluation method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 	protected function set_active_callback() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 		if ( is_array( $this->active_callback ) && ! is_callable( $this->active_callback ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 			if ( isset( $this->active_callback[0] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 				$this->required = $this->active_callback; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 		if ( ! empty( $this->required ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 			$this->active_callback = array( 'Kirki_Active_Callback', 'evaluate' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		// No need to proceed any further if we're using the default value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		if ( '__return_true' === $this->active_callback ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  | 		// Make sure the function is callable, otherwise fallback to __return_true. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		if ( ! is_callable( $this->active_callback ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 			$this->active_callback = '__return_true'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 	 * Sets the control type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 	protected function set_type() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 		// Escape the control type (it doesn't hurt to be sure). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 		$this->type = esc_attr( $this->type ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 	 * Sets the $id. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 	 * Setting the ID should happen after the 'settings' sanitization. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 	 * This way we can also properly handle cases where the option_type is set to 'option' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 	 * and we're using an array instead of individual options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 	protected function set_id() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 		$this->id = sanitize_key( str_replace( '[', '-', str_replace( ']', '', $this->settings ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 	 * Sets the $choices. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 	protected function set_choices() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 		if ( ! is_array( $this->choices ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 			$this->choices = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 	 * Escapes the $disable_output. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 	protected function set_disable_output() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 		$this->disable_output = (bool) $this->disable_output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 	 * Sets the $sanitize_callback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 	protected function set_output() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 		if ( empty( $this->output ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		if ( ! is_array( $this->output ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			/* translators: The field ID where the error occurs. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			$this->output = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 				array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 					'element' => $this->output, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 		// Convert to array of arrays if needed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 		if ( isset( $this->output['element'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 			/* translators: The field ID where the error occurs. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			_doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			$this->output = array( $this->output ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 		foreach ( $this->output as $key => $output ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 			if ( empty( $output ) || ! isset( $output['element'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 				unset( $this->output[ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 				$this->output[ $key ]['sanitize_callback'] = $output['callback']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 			// Convert element arrays to strings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 			if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 				$this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 				sort( $this->output[ $key ]['element'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 				$this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 	 * Sets the $js_vars | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 	protected function set_js_vars() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 		if ( ! is_array( $this->js_vars ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 			$this->js_vars = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 		// Check if transport is set to auto. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 		// If not, then skip the auto-calculations and exit early. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 		if ( 'auto' !== $this->transport ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 		// Set transport to refresh initially. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 		// Serves as a fallback in case we failt to auto-calculate js_vars. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 		$this->transport = 'refresh'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 		$js_vars = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		// Try to auto-generate js_vars. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		// First we need to check if js_vars are empty, and that output is not empty. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 		if ( empty( $this->js_vars ) && ! empty( $this->output ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 			// Start going through each item in the $output array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 			foreach ( $this->output as $output ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 				$output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 				// If 'element' or 'property' are not defined, skip this. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 				if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 				if ( is_array( $output['element'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 					$output['element'] = implode( ',', $output['element'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 				// If there's a sanitize_callback defined skip this, unless we also have a js_callback defined. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 				if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 				// If we got this far, it's safe to add this. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  | 				$js_vars[] = $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  | 			// Did we manage to get all the items from 'output'? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 			// If not, then we're missing something so don't add this. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  | 			if ( count( $js_vars ) !== count( $this->output ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 				return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  | 			$this->js_vars   = $js_vars; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 			$this->transport = 'postMessage'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 	 * Sets the $variables | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 	protected function set_variables() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 		if ( ! is_array( $this->variables ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  | 			$variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  | 			$this->variables = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  | 			if ( $variable && empty( $this->variables ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  | 				$this->variables[0]['name'] = $variable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 	 * Sets the $transport | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 	protected function set_transport() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 		if ( 'postmessage' === trim( strtolower( $this->transport ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 			$this->transport = 'postMessage'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  | 	 * Sets the $required | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 	protected function set_required() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 		if ( ! is_array( $this->required ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 			$this->required = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 	 * Sets the $priority | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 	 * @access protected | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 	protected function set_priority() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 		$this->priority = absint( $this->priority ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 711 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 712 |  |  |  |