packages/kirki-framework/core/src/Kirki.php
public static function add_field( $config_id, $args = [] ) {
		if ( doing_action( 'customize_register' ) ) {
			_doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' );
		}

		// Early exit if 'type' is not defined.
		if ( ! isset( $args['type'] ) ) {
			return;
		}

		// If the field is font-awesome, enqueue the icons on the frontend.
		if ( class_exists( '\Kirki\Modules\CSS\Module' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) {
			\Kirki\Modules\CSS\Module::add_fontawesome_script();
		}

		$str       = str_replace( [ '-', '_' ], ' ', $args['type'] );
		$classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) );

		$config = Config::get_instance( $config_id )->get_config();
		$args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id;
		unset( $config['id'] );
		$args = wp_parse_args( $args, $config );

		if ( class_exists( $classname ) ) {
			new $classname( $args );
			return;
		}
		new Field( $args );
	}
public static function add_field( $config_id, $args = [] ) {
		if ( doing_action( 'customize_register' ) ) {
			_doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' );
		}

		// Early exit if 'type' is not defined.
		if ( ! isset( $args['type'] ) ) {
			return;
		}

		// If the field is font-awesome, enqueue the icons on the frontend.
		if ( class_exists( '\Kirki\Modules\CSS\Module' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) {
			\Kirki\Modules\CSS\Module::add_fontawesome_script();
		}

		$str       = str_replace( [ '-', '_' ], ' ', $args['type'] );
		$classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) );

		$config = Config::get_instance( $config_id )->get_config();
		$args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id;
		unset( $config['id'] );
		$args = wp_parse_args( $args, $config );

		if ( class_exists( $classname ) ) {
			new $classname( $args );
			return;
		}
		new Field( $args );
	}
public static function add_field ( $ config_id , $ args = [ ] ) { if ( doing_action ( 'customize_register' ) ) { _doing_it_wrong ( __METHOD__ , esc_html__ ( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.' , 'kirki' ) , '3.0.10' ) ; } // Early exit if 'type' is not defined. if ( ! isset ( $ args [ 'type' ] ) ) { return ; } // If the field is font-awesome, enqueue the icons on the frontend. if ( class_exists ( '\Kirki\Modules\CSS\Module' ) && ( 'fontawesome' === $ args [ 'type' ] || 'kirki-fontawesome' === $ args [ 'type' ] ) ) { \ Kirki \ Modules \ CSS \ Module :: add_fontawesome_script ( ) ; } $ str = str_replace ( [ '-' , '_' ] , ' ' , $ args [ 'type' ] ) ; $ classname = '\Kirki\Field\\' . str_replace ( ' ' , '_' , ucwords ( $ str ) ) ; $ config = Config :: get_instance ( $ config_id ) -> get_config ( ) ; $ args [ 'kirki_config' ] = isset ( $ args [ 'kirki_config' ] ) ? $ args [ 'kirki_config' ] : $ config_id ; unset ( $ config [ 'id' ] ) ; $ args = wp_parse_args ( $ args , $ config ) ; if ( class_exists ( $ classname ) ) { new $ classname ( $ args ) ; return ; } new Field ( $ args ) ; }
Create a new field.

@static
@access public
@param string $config_id The configuration ID for this field.
@param array  $args      The field arguments.
Create a new field .