PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.4.9
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.4.9
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 / Classes / abstract.class.php

abstract.class.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.4.9, at src/Admin/Framework/Classes/abstract.class.php

187 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use ThemeAtelier\Darkify\Admin\Framework\Classes\Darkify;
4
5 if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
6 /**
7 *
8 * Abstract Class
9 *
10 * @since 1.0.0
11 * @version 1.0.0
12 *
13 */
14 if ( ! class_exists( 'DarkifyAbstract' ) ) {
15 abstract class DarkifyAbstract {
16
17 public $abstract = '';
18 public $output_css = '';
19
20 public function __construct() {}
21
22 public function recursive_output_css( $fields = array(), $combine_field = array() ) {
23
24 if ( ! empty( $fields ) ) {
25
26 foreach ( $fields as $field ) {
27
28 $field_id = ( ! empty( $field['id'] ) ) ? $field['id'] : '';
29 $field_type = ( ! empty( $field['type'] ) ) ? $field['type'] : '';
30 $field_output = ( ! empty( $field['output'] ) ) ? $field['output'] : '';
31 $field_check = ( $field_type === 'typography' || $field_output ) ? true : false;
32 $field_class = 'DarkifyField_' . $field_type;
33
34 if ( $field_type && $field_id ) {
35
36 if( $field_type === 'fieldset' ) {
37 if ( ! empty( $field['fields'] ) ) {
38 $this->recursive_output_css( $field['fields'], $field );
39 }
40 }
41
42 if( $field_type === 'accordion' ) {
43 if ( ! empty( $field['accordions'] ) ) {
44 foreach ( $field['accordions'] as $accordion ) {
45 $this->recursive_output_css( $accordion['fields'], $field );
46 }
47 }
48 }
49
50 if( $field_type === 'tabbed' ) {
51 if ( ! empty( $field['tabs'] ) ) {
52 foreach ( $field['tabs'] as $accordion ) {
53 $this->recursive_output_css( $accordion['fields'], $field );
54 }
55 }
56 }
57
58 if( $field_type === 'section_tab' ) {
59 if ( ! empty( $field['tabs'] ) ) {
60 foreach ( $field['tabs'] as $accordion ) {
61 $this->recursive_output_css( $accordion['fields'], $field );
62 }
63 }
64 }
65 if( $field_type === 'section_inner_tab' ) {
66 if ( ! empty( $field['tabs'] ) ) {
67 foreach ( $field['tabs'] as $accordion ) {
68 $this->recursive_output_css( $accordion['fields'], $field );
69 }
70 }
71 }
72
73 if ( class_exists( $field_class ) ) {
74
75 if ( method_exists( $field_class, 'output' ) || method_exists( $field_class, 'enqueue_google_fonts' ) ) {
76
77 $field_value = '';
78
79 if ( $field_check && ( $this->abstract === 'options' || $this->abstract === 'customize' ) ) {
80
81 if( ! empty( $combine_field ) ) {
82
83 $field_value = ( isset( $this->options[$combine_field['id']][$field_id] ) ) ? $this->options[$combine_field['id']][$field_id] : '';
84
85 } else {
86
87 $field_value = ( isset( $this->options[$field_id] ) ) ? $this->options[$field_id] : '';
88
89 }
90
91 } else if ( $field_check && ( $this->abstract === 'metabox' && is_singular() || $this->abstract === 'taxonomy' && is_archive() ) ) {
92
93 if( ! empty( $combine_field ) ) {
94
95 $meta_value = $this->get_meta_value( $combine_field );
96 $field_value = ( isset( $meta_value[$field_id] ) ) ? $meta_value[$field_id] : '';
97
98 } else {
99
100 $meta_value = $this->get_meta_value( $field );
101 $field_value = ( isset( $meta_value ) ) ? $meta_value : '';
102
103 }
104
105 }
106
107 $instance = new $field_class( $field, $field_value, $this->unique, 'wp/enqueue', $this );
108
109 // output css
110 if ( $field_output && $this->args['output_css'] ) {
111 Darkify::$css .= $instance->output();
112 }
113
114 unset( $instance );
115
116 }
117 }
118 }
119 }
120 }
121 }
122
123 public function pre_tabs( $sections ) {
124
125 $count = 100;
126 $result = array();
127 $parents = array();
128
129 foreach ( $sections as $key => $section ) {
130 if ( ! empty( $section['parent'] ) ) {
131 $section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
132 $parents[$section['parent']][] = $section;
133 unset( $sections[$key] );
134 }
135 $count++;
136 }
137
138 foreach ( $sections as $key => $section ) {
139 $section['priority'] = ( isset( $section['priority'] ) ) ? $section['priority'] : $count;
140 if ( ! empty( $section['id'] ) && ! empty( $parents[$section['id']] ) ) {
141 $section['subs'] = wp_list_sort( $parents[$section['id']], array( 'priority' => 'ASC' ), 'ASC', true );
142 }
143 $result[] = $section;
144 $count++;
145 }
146
147 return wp_list_sort( $result, array( 'priority' => 'ASC' ), 'ASC', true );
148
149 }
150
151 public function pre_sections( $sections ) {
152
153 $result = array();
154
155 foreach ( $this->pre_tabs( $sections ) as $section ) {
156 if ( ! empty( $section['subs'] ) ) {
157 foreach ( $section['subs'] as $sub ) {
158 $sub['ptitle'] = ( ! empty( $section['title'] ) ) ? $section['title'] : '';
159 $result[] = $sub;
160 }
161 }
162 if ( empty( $section['subs'] ) ) {
163 $result[] = $section;
164 }
165 }
166
167 return $result;
168 }
169
170 public function pre_fields( $sections ) {
171
172 $result = array();
173
174 foreach ( $sections as $key => $section ) {
175 if ( ! empty( $section['fields'] ) ) {
176 foreach ( $section['fields'] as $field ) {
177 $result[] = $field;
178 }
179 }
180 }
181
182 return $result;
183 }
184
185 }
186 }
187