get_config(); self::$config[ $config_args['id'] ] = $config_args; } /** * Create a new panel. * * @static * @access public * @param string $id The ID for this panel. * @param array $args The panel arguments. */ public static function add_panel( $id = '', $args = array() ) { $args['id'] = $id; if ( ! isset( $args['description'] ) ) { $args['description'] = ''; } if ( ! isset( $args['priority'] ) ) { $args['priority'] = 10; } if ( ! isset( $args['type'] ) ) { $args['type'] = 'default'; } if ( false === strpos( $args['type'], 'kirki-' ) ) { $args['type'] = 'kirki-' . $args['type']; } self::$panels[ $id ] = $args; } /** * Remove a panel. * * @static * @access public * @since 3.0.17 * @param string $id The ID for this panel. */ public static function remove_panel( $id = '' ) { if ( ! in_array( $id, self::$panels_to_remove, true ) ) { self::$panels_to_remove[] = $id; } } /** * Create a new section. * * @static * @access public * @param string $id The ID for this section. * @param array $args The section arguments. */ public static function add_section( $id, $args ) { $args['id'] = $id; if ( ! isset( $args['description'] ) ) { $args['description'] = ''; } if ( ! isset( $args['priority'] ) ) { $args['priority'] = 10; } if ( ! isset( $args['type'] ) ) { $args['type'] = 'default'; } if ( false === strpos( $args['type'], 'kirki-' ) ) { $args['type'] = 'kirki-' . $args['type']; } self::$sections[ $id ] = $args; } /** * Remove a section. * * @static * @access public * @since 3.0.17 * @param string $id The ID for this panel. */ public static function remove_section( $id = '' ) { if ( ! in_array( $id, self::$sections_to_remove, true ) ) { self::$sections_to_remove[] = $id; } } /** * Create a new field. * * @static * @access public * @param string $config_id The configuration ID for this field. * @param array $args The field arguments. */ 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' ); } parent::maybe_show_fontawesome_nag( $args ); // Early exit if 'type' is not defined. if ( ! isset( $args['type'] ) ) { return; } $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); if ( class_exists( $classname ) ) { new $classname( $config_id, $args ); return; } if ( false !== strpos( $classname, 'Kirki_Field_Kirki_' ) ) { $classname = str_replace( 'Kirki_Field_Kirki_', 'Kirki_Field_', $classname ); if ( class_exists( $classname ) ) { new $classname( $config_id, $args ); return; } } new Kirki_Field( $config_id, $args ); } /** * Remove a control. * * @static * @access public * @since 3.0.17 * @param string $id The field ID. */ public static function remove_control( $id ) { if ( ! in_array( $id, self::$controls_to_remove, true ) ) { self::$controls_to_remove[] = $id; } } /** * Gets a parameter for a config-id. * * @static * @access public * @since 3.0.10 * @param string $id The config-ID. * @param string $param The parameter we want. * @return string */ public static function get_config_param( $id, $param ) { if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) { return ''; } return self::$config[ $id ][ $param ]; } }