args = $args; /** * Create the settings. */ new Kirki_Settings( $this->args ); /** * Check if we're on the customizer. * If we are, then we will create the controls, * add the scripts needed for the customizer * and any other tweaks that this field may require. */ if ( $this->wp_customize ) { /** * Create the control */ new Kirki_Control( $this->args ); /** * Create the scripts for postMessage to properly work */ Kirki_Customizer_Scripts_PostMessage::generate_script( $this->args ); /** * Create the scripts for tooltips. */ Kirki_Customizer_Scripts_Tooltips::generate_script( $this->args ); } } public static function add_field( $config_id = 'global', $args = array() ) { /** * Sanitize $config_id */ $config_id = self::sanitize_config_id( $config_id, $args ); $args['kirki_config'] = $config_id; /** * Get the config arguments */ $config = Kirki::$config[ $config_id ]; /** * Sanitize option_name */ $args['option_name'] = self::sanitize_option_name( $config_id, $args ); /** * If we've set an option in the configuration * then make sure we're using options and not theme_mods */ if ( isset( $config['option_name'] ) && ! empty( $config['option_name'] ) ) { $args['option_type'] = 'option'; } /** * Sanitize option_type */ $args['option_type'] = self::sanitize_option_type( $config_id, $args ); /** * Sanitize capability */ $args['capability'] = self::sanitize_capability( $config_id, $args ); /** * Get the 'disable_output' argument from the config */ $args['disable_output'] = $config['disable_output']; /** * Sanitize settings */ $args['settings'] = self::sanitize_settings( $config_id, $args ); /** * Sanitize tooltip messages */ $args['tooltip'] = self::sanitize_tooltip( $config_id, $args ); /** * Sanitize active_callback */ $args['active_callback'] = self::sanitize_active_callback( $config_id, $args ); /** * Sanitize control type */ $args['type'] = self::sanitize_control_type( $config_id, $args ); /** * If no choices have been defined, use an empty array */ $args['choices'] = ( isset( $args['choices'] ) ) ? $args['choices'] : array(); /** * Tweaks for simple controls */ if ( 'kirki-text' == $args['type'] ) { $args['type'] = 'kirki-generic'; $args['choices']['element'] = 'input'; $args['choices']['type'] = 'text'; if ( ! isset( $args['sanitize_callback'] ) ) { $args['sanitize_callback'] = 'wp_kses_post'; } } elseif ( 'kirki-textarea' == $args['type'] ) { $args['type'] = 'kirki-generic'; $args['choices']['element'] = 'textarea'; $args['choices']['rows'] = '5'; if ( ! isset( $args['sanitize_callback'] ) ) { $args['sanitize_callback'] = 'wp_kses_post'; } } if ( 'kirki-generic' == $args['type'] && ! isset( $args['choices']['element'] ) ) { $args['choices']['element'] = 'input'; } /** * Sanitize the sanitize_callback argument. */ $args['sanitize_callback'] = self::sanitize_callback( $config_id, $args ); /** * set choices for color controls */ if ( 'kirki-color' == $args['type'] ) { $args['choices']['alpha'] = false; $args['type'] = 'color-alpha'; } elseif ( 'color-alpha' == $args['type'] ) { $args['choices']['alpha'] = true; } /** * If no output argument has been defined, use an empty array */ $args['output'] = isset( $args['output'] ) ? $args['output'] : array(); /** * If "variables" has not been defined, set to null. */ $args['variables'] = ( isset( $args['variables'] ) && is_array( $args['variables'] ) ) ? $args['variables'] : null; /** * Sanitize the id (for internal use) */ $args['id'] = self::sanitize_id( $config_id, $args ); /** * Make sure the "multiple" argument is properly formatted for