', self::render_attributes( $attributes ) ); $output .= ''; $output .= $walker->walk( $options, $field['flatten'] ? - 1 : 0 ); $output .= ''; $output .= self::get_select_all_html( $field ); return $output; } /** * Normalize parameters for field * * @param array $field * @return array */ public static function normalize( $field ) { $field = wp_parse_args( $field, array( 'js_options' => array(), 'placeholder' => 'Select an item', ) ); $field = parent::normalize( $field ); $field['js_options'] = wp_parse_args( $field['js_options'], array( 'allowClear' => true, 'width' => 'none', 'placeholder' => $field['placeholder'], ) ); return $field; } /** * Get the attributes for a field * * @param array $field * @param mixed $value * @return array */ public static function get_attributes( $field, $value = null ) { $attributes = parent::get_attributes( $field, $value ); $attributes = wp_parse_args( $attributes, array( 'data-options' => wp_json_encode( $field['js_options'] ), ) ); return $attributes; } }