'option', 'option_name' => $args['opt_name'], ) ); } public static function setSection( $config_id, $args = array() ) { if ( ! isset( $args['fields'] ) || ! isset( $args['subsection'] ) || ( isset( $args['subsection'] ) && ! $args['subsection'] ) ) { // This is a panel Kirki::$panels[] = array( 'id' => isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyz-_' ), 0, 7 ), 'title' => isset( $args['title'] ) ? $args['title'] : '', 'priority' => ( isset( $args['priority'] ) ) ? $args['priority'] : 10, 'description' => ( isset( $args['desc'] ) ) ? $args['desc'] : '', ); } else { // This is a section // Get the section ID if ( isset( $args['subsection'] ) && $args['subsection'] ) { $panel = end( array_values( Kirki::$panels ) ); $panel_id = $panel['id']; } Kirki::$sections[] = array( 'id' => isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyz-_' ), 0, 7 ), 'title' => $args['title'], 'priority' => ( isset( $args['priority'] ) ) ? $args['priority'] : 10, 'panel' => ( isset( $panel_id ) ) ? $panel_id : '', 'description' => ( isset( $args['desc'] ) ) ? $args['desc'] : '', ); foreach ( $args['fields'] as $field ) { $field['section'] = isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyz-_' ), 0, 7 ); $field['settings'] = $field['id']; $field['help'] = ( isset( $field['desc'] ) ) ? $field['desc'] : ''; $field['description'] = ( isset( $field['subtitle'] ) ) ? $field['subtitle'] : ''; $field['choices'] = ( isset( $field['options'] ) ) ? $field['options'] : ''; $field['label'] = ( isset( $field['title'] ) ) ? $field['title'] : ''; switch ( $field['type'] ) { case 'ace_editor': $field['type'] = 'textarea'; break; case 'button_set': $field['type'] = 'radio-buttonset'; break; case 'checkbox': if ( isset( $field['options'] ) && is_array( $field['options'] ) ) { $field['type'] = 'multicheck'; } case 'color_rgba': $field['type'] = 'color-alpha'; if ( isset( $field['default'] ) && is_array( $field['default'] ) ) { $field['default']['color'] = isset( $field['default']['color'] ) ? Kirki_Color::sanitize_hex( $field['default']['color'], true ) : '#ffffff'; $field['default']['alpha'] = isset( $field['default']['alpha'] ) ? $field['default']['alpha'] : '1'; $field['default'] = Kirki_Color::get_rgba( $field['default']['color'], $field['default']['alpha'] ); } break; case 'image_select': $field['type'] = 'radio-image'; break; case 'info': $field['label'] = ''; $field['help'] = ''; $field['type'] = 'custom'; $background_color = '#fcf8e3'; $border_color = '#faebcc'; $text_color = '#8a6d3b'; if ( isset( $field['style'] ) ) { if ( 'success' == $field['style'] ) { $background_color = '#dff0d8'; $border_color = '#d6e9c6'; $text_color = '#3c763d'; } elseif ( 'critical' == $field['style'] ) { $background_color = '#f2dede'; $border_color = '#ebccd1'; $text_color = '#a94442'; } } $field['default'] = '