PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.3
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.3
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 / src / Admin / Framework / functions / customize.php

customize.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.3, at src/Admin/Framework/functions/customize.php

140 lines 4.1 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( 'DarkifyCustomize_Panel' ) && class_exists( 'WP_Customize_Panel' ) ) {
11 class DarkifyCustomize_Panel extends WP_Customize_Panel {
12 public $type = 'darkify';
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( 'DarkifyCustomize_Section' ) && class_exists( 'WP_Customize_Section' ) ) {
24 class DarkifyCustomize_Section extends WP_Customize_Section {
25 public $type = 'darkify';
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( 'DarkifyCustomize_Control' ) && class_exists( 'WP_Customize_Control' ) ) {
37 class DarkifyCustomize_Control extends WP_Customize_Control {
38
39 public $type = 'darkify';
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 = ' darkify-dependency-control';
77 $visible .= ( ! empty( $depend_visible ) ) ? ' darkify-depend-visible' : ' darkify-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 'darkify_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 )
116 );
117
118 $field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
119 $custom = ( ! empty( $this->field['customizer'] ) ) ? true : false;
120 $is_complex = ( in_array( $this->field['type'], $complex ) ) ? true : false;
121 $class = ( $is_complex || $custom ) ? ' darkify-customize-complex' : '';
122 $atts = ( $is_complex || $custom ) ? ' data-unique-id="' . esc_attr( $this->unique ) . '" data-option-id="' . esc_attr( $field_id ) . '"' : '';
123
124 if ( ! $is_complex && ! $custom ) {
125 $this->field['attributes']['data-customize-setting-link'] = $this->settings['default']->id;
126 }
127
128 $this->field['name'] = $this->settings['default']->id;
129
130 $this->field['dependency'] = array();
131
132 echo '<div class="darkify-customize-field' . esc_attr( $class ) . '"' . wp_kses_post( $atts ) . '>';
133
134 Darkify::field( $this->field, $this->value(), $this->unique, 'customize' );
135
136 echo '</div>';
137 }
138 }
139 }
140