PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.0
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.0
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / functions / customize.php

customize.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.0, at admin/ta-framework/functions/customize.php

141 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * WP Customize custom panel
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Customize_Panel' ) && class_exists( 'WP_Customize_Panel' ) ) {
11 class DRK_LITE_Customize_Panel extends WP_Customize_Panel {
12 public $type = 'drk_lite';
13 }
14 }
15
16 /**
17 *
18 * WP Customize custom section
19 *
20 * @since 1.0.0
21 * @version 1.0.0
22 */
23 if ( ! class_exists( 'DRK_LITE_Customize_Section' ) && class_exists( 'WP_Customize_Section' ) ) {
24 class DRK_LITE_Customize_Section extends WP_Customize_Section {
25 public $type = 'drk_lite';
26 }
27 }
28
29 /**
30 *
31 * WP Customize custom control
32 *
33 * @since 1.0.0
34 * @version 1.0.0
35 */
36 if ( ! class_exists( 'DRK_LITE_Customize_Control' ) && class_exists( 'WP_Customize_Control' ) ) {
37 class DRK_LITE_Customize_Control extends WP_Customize_Control {
38
39 public $type = 'drk_lite';
40 public $field = '';
41 public $unique = '';
42
43 public function render() {
44
45 $depend = '';
46 $visible = '';
47
48 if ( ! empty( $this->field['dependency'] ) ) {
49
50 $dependency = $this->field['dependency'];
51 $depend_visible = '';
52 $data_controller = '';
53 $data_condition = '';
54 $data_value = '';
55 $data_global = '';
56
57 if ( is_array( $dependency[0] ) ) {
58 $data_controller = implode( '|', array_column( $dependency, 0 ) );
59 $data_condition = implode( '|', array_column( $dependency, 1 ) );
60 $data_value = implode( '|', array_column( $dependency, 2 ) );
61 $data_global = implode( '|', array_column( $dependency, 3 ) );
62 $depend_visible = implode( '|', array_column( $dependency, 4 ) );
63 } else {
64 $data_controller = ( ! empty( $dependency[0] ) ) ? $dependency[0] : '';
65 $data_condition = ( ! empty( $dependency[1] ) ) ? $dependency[1] : '';
66 $data_value = ( ! empty( $dependency[2] ) ) ? $dependency[2] : '';
67 $data_global = ( ! empty( $dependency[3] ) ) ? $dependency[3] : '';
68 $depend_visible = ( ! empty( $dependency[4] ) ) ? $dependency[4] : '';
69 }
70
71 $depend .= ' data-controller="' . esc_attr( $data_controller ) . '"';
72 $depend .= ' data-condition="' . esc_attr( $data_condition ) . '"';
73 $depend .= ' data-value="' . esc_attr( $data_value ) . '"';
74 $depend .= ( ! empty( $data_global ) ) ? ' data-depend-global="true"' : '';
75
76 $visible = ' drk_lite-dependency-control';
77 $visible .= ( ! empty( $depend_visible ) ) ? ' drk_lite-depend-visible' : ' drk_lite-depend-hidden';
78
79 }
80
81 $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
82 $class = 'customize-control customize-control-' . $this->type . $visible;
83
84 echo '<li id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '"' . wp_kses_post($depend) . '>';
85 $this->render_field_content();
86 echo '</li>';
87 }
88
89 public function render_field_content() {
90
91 $complex = apply_filters(
92 'drk_lite_customize_complex_fields',
93 array(
94 'accordion',
95 'background',
96 'border',
97 'button_set',
98 'checkbox',
99 'color_group',
100 'date',
101 'dimensions',
102 'fieldset',
103 'group',
104 'image_select',
105 'link',
106 'link_color',
107 'media',
108 'palette',
109 'repeater',
110 'sortable',
111 'sorter',
112 'spacing',
113 'switcher',
114 'tabbed',
115 'typography',
116 )
117 );
118
119 $field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
120 $custom = ( ! empty( $this->field['customizer'] ) ) ? true : false;
121 $is_complex = ( in_array( $this->field['type'], $complex ) ) ? true : false;
122 $class = ( $is_complex || $custom ) ? ' drk_lite-customize-complex' : '';
123 $atts = ( $is_complex || $custom ) ? ' data-unique-id="' . esc_attr( $this->unique ) . '" data-option-id="' . esc_attr( $field_id ) . '"' : '';
124
125 if ( ! $is_complex && ! $custom ) {
126 $this->field['attributes']['data-customize-setting-link'] = $this->settings['default']->id;
127 }
128
129 $this->field['name'] = $this->settings['default']->id;
130
131 $this->field['dependency'] = array();
132
133 echo '<div class="drk_lite-customize-field' . esc_attr( $class ) . '"' . wp_kses_post( $atts ) . '>';
134
135 DRK_LITE::field( $this->field, $this->value(), $this->unique, 'customize' );
136
137 echo '</div>';
138 }
139 }
140 }
141