PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.2.5
StreamCast – bring live radio to your site with a sleek player v2.2.5
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / admin / codestar-framework / fields / sortable / sortable.php

sortable.php in StreamCast – bring live radio to your site with a sleek player 2.2.5, at admin/codestar-framework/fields/sortable/sortable.php

88 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: sortable
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_sortable' ) ) {
11 class CSF_Field_sortable extends CSF_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 echo $this->field_before();
20
21 echo '<div class="csf-sortable" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
22
23 $pre_sortby = array();
24 $pre_fields = array();
25
26 // Add array-keys to defined fields for sort by
27 foreach ( $this->field['fields'] as $key => $field ) {
28 $pre_fields[$field['id']] = $field;
29 }
30
31 // Set sort by by saved-value or default-value
32 if ( ! empty( $this->value ) ) {
33
34 foreach ( $this->value as $key => $value ) {
35 $pre_sortby[$key] = $pre_fields[$key];
36 }
37
38 $diff = array_diff_key( $pre_fields, $this->value );
39
40 if( ! empty( $diff ) ) {
41 $pre_sortby = array_merge( $pre_sortby, $diff );
42 }
43
44 } else {
45
46 foreach ( $pre_fields as $key => $value ) {
47 $pre_sortby[$key] = $value;
48 }
49
50 }
51
52 foreach ( $pre_sortby as $key => $field ) {
53
54 echo '<div class="csf-sortable-item">';
55
56 echo '<div class="csf-sortable-content">';
57
58 $field_default = ( isset( $this->field['default'][$key] ) ) ? $this->field['default'][$key] : '';
59 $field_value = ( isset( $this->value[$key] ) ) ? $this->value[$key] : $field_default;
60 $unique_id = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']' : $this->field['id'];
61
62 CSF::field( $field, $field_value, $unique_id, 'field/sortable' );
63
64 echo '</div>';
65
66 echo '<div class="csf-sortable-helper"><i class="fas fa-arrows-alt"></i></div>';
67
68 echo '</div>';
69
70 }
71
72 echo '</div>';
73
74 echo $this->field_after();
75
76 }
77
78 public function enqueue() {
79
80 if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
81 wp_enqueue_script( 'jquery-ui-sortable' );
82 }
83
84 }
85
86 }
87 }
88