diff --git a/src/SettingsAPI.php b/src/SettingsAPI.php index 72940d0..9230941 100644 --- a/src/SettingsAPI.php +++ b/src/SettingsAPI.php @@ -361,6 +361,7 @@ public function admin_enqueue_scripts() { wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-datepicker' ); wp_enqueue_script( 'jquery-ui-timepicker' ); + wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( 'sbsa' ); $data = array( @@ -996,6 +997,43 @@ public function generate_radio_field( $args ) { $this->generate_description( $args['desc'] ); } + /** + * Generate: Sortable list + * @param array $args Field arguments. + */ + public function generate_sortable_list_field( $args ) { + + $args['value'] = esc_html( esc_attr( $args['value'] ) ); + $sortable_choices = $args['choices']; + + + if( ! empty( $args['value'] ) ) { + $sbsa_list_order = explode(",", $args['value'] ); + $new_order = array(); + foreach ($sbsa_list_order as $key) { + if (array_key_exists($key, $sortable_choices)) { + $new_order[$key] = $sortable_choices[$key]; + } + } + $sortable_choices = $new_order; + + } + ?> +