PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.7
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.7
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / lib / adminify-framework / fields / sortable / sortable.php

sortable.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.7, at lib/adminify-framework/fields/sortable/sortable.php

88 lines 2.2 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( 'ADMINIFY_Field_sortable' ) ) {
11 class ADMINIFY_Field_sortable extends ADMINIFY_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="adminify-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="adminify-sortable-item">';
55
56 echo '<div class="adminify-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 ADMINIFY::field( $field, $field_value, $unique_id, 'field/sortable' );
63
64 echo '</div>';
65
66 echo '<div class="adminify-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