PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.0.2
Adminify – White Label, Admin Menu Editor, Login Customizer v3.0.2
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 / classes / setup.class.php

setup.class.php in Adminify – White Label, Admin Menu Editor, Login Customizer 3.0.2, at lib/adminify-framework/classes/setup.class.php

785 lines 25.7 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;
3 } // Cannot access directly.
4 /**
5 *
6 * Setup Class
7 *
8 * @since 1.0.0
9 * @version 1.0.0
10 *
11 */
12 if (!class_exists('ADMINIFY')) {
13 class ADMINIFY
14 {
15
16 // Default constants
17 public static $premium = true;
18 public static $version = '2.2.6';
19 public static $dir = '';
20 public static $url = '';
21 public static $css = '';
22 public static $file = '';
23 public static $enqueue = false;
24 public static $webfonts = array();
25 public static $subsets = array();
26 public static $inited = array();
27 public static $fields = array();
28 public static $args = array(
29 'admin_options' => array(),
30 'customize_options' => array(),
31 'metabox_options' => array(),
32 'nav_menu_options' => array(),
33 'profile_options' => array(),
34 'taxonomy_options' => array(),
35 'widget_options' => array(),
36 'comment_options' => array(),
37 'shortcode_options' => array(),
38 );
39
40 // Shortcode instances
41 public static $shortcode_instances = array();
42
43 private static $instance = null;
44
45 public static function init($file = __FILE__)
46 {
47
48 // Set file constant
49 self::$file = $file;
50
51 // Set constants
52 self::constants();
53
54 // Include files
55 self::includes();
56
57 if (is_null(self::$instance)) {
58 self::$instance = new self();
59 }
60
61 return self::$instance;
62 }
63
64 // Initalize
65 public function __construct()
66 {
67
68 // Init action
69 do_action('adminify_init');
70
71 // Setup textdomain
72 self::textdomain();
73
74 add_action('after_setup_theme', array('ADMINIFY', 'setup'));
75 add_action('init', array('ADMINIFY', 'setup'));
76 add_action('switch_theme', array('ADMINIFY', 'setup'));
77 add_action('admin_enqueue_scripts', array('ADMINIFY', 'add_admin_enqueue_scripts'));
78 add_action('wp_enqueue_scripts', array('ADMINIFY', 'add_typography_enqueue_styles'), 80);
79 add_action('wp_head', array('ADMINIFY', 'add_custom_css'), 80);
80 add_filter('admin_body_class', array('ADMINIFY', 'add_admin_body_class'));
81 }
82
83 // Setup frameworks
84 public static function setup()
85 {
86
87 // Welcome page
88 self::include_plugin_file('views/welcome.php');
89
90 // Setup admin option framework
91 $params = array();
92 if (class_exists('ADMINIFY_Options') && !empty(self::$args['admin_options'])) {
93 foreach (self::$args['admin_options'] as $key => $value) {
94 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
95
96 $params['args'] = $value;
97 $params['sections'] = self::$args['sections'][$key];
98 self::$inited[$key] = true;
99
100 ADMINIFY_Options::instance($key, $params);
101
102 if (!empty($value['show_in_customizer'])) {
103 $value['output_css'] = false;
104 $value['enqueue_webfont'] = false;
105 self::$args['customize_options'][$key] = $value;
106 self::$inited[$key] = null;
107 }
108 }
109 }
110 }
111
112 // Setup customize option framework
113 $params = array();
114 if (class_exists('ADMINIFY_Customize_Options') && !empty(self::$args['customize_options'])) {
115 foreach (self::$args['customize_options'] as $key => $value) {
116 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
117
118 $params['args'] = $value;
119 $params['sections'] = self::$args['sections'][$key];
120 self::$inited[$key] = true;
121
122 ADMINIFY_Customize_Options::instance($key, $params);
123 }
124 }
125 }
126
127 // Setup metabox option framework
128 $params = array();
129 if (class_exists('ADMINIFY_Metabox') && !empty(self::$args['metabox_options'])) {
130 foreach (self::$args['metabox_options'] as $key => $value) {
131 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
132
133 $params['args'] = $value;
134 $params['sections'] = self::$args['sections'][$key];
135 self::$inited[$key] = true;
136
137 ADMINIFY_Metabox::instance($key, $params);
138 }
139 }
140 }
141
142 // Setup nav menu option framework
143 $params = array();
144 if (class_exists('ADMINIFY_Nav_Menu_Options') && !empty(self::$args['nav_menu_options'])) {
145 foreach (self::$args['nav_menu_options'] as $key => $value) {
146 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
147
148 $params['args'] = $value;
149 $params['sections'] = self::$args['sections'][$key];
150 self::$inited[$key] = true;
151
152 ADMINIFY_Nav_Menu_Options::instance($key, $params);
153 }
154 }
155 }
156
157 // Setup profile option framework
158 $params = array();
159 if (class_exists('ADMINIFY_Profile_Options') && !empty(self::$args['profile_options'])) {
160 foreach (self::$args['profile_options'] as $key => $value) {
161 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
162
163 $params['args'] = $value;
164 $params['sections'] = self::$args['sections'][$key];
165 self::$inited[$key] = true;
166
167 ADMINIFY_Profile_Options::instance($key, $params);
168 }
169 }
170 }
171
172 // Setup taxonomy option framework
173 $params = array();
174 if (class_exists('ADMINIFY_Taxonomy_Options') && !empty(self::$args['taxonomy_options'])) {
175 $taxonomy = (isset($_GET['taxonomy'])) ? sanitize_text_field(wp_unslash($_GET['taxonomy'])) : '';
176 foreach (self::$args['taxonomy_options'] as $key => $value) {
177 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
178
179 $params['args'] = $value;
180 $params['sections'] = self::$args['sections'][$key];
181 self::$inited[$key] = true;
182
183 ADMINIFY_Taxonomy_Options::instance($key, $params);
184 }
185 }
186 }
187
188 // Setup widget option framework
189 if (class_exists('ADMINIFY_Widget') && class_exists('WP_Widget_Factory') && !empty(self::$args['widget_options'])) {
190 $wp_widget_factory = new WP_Widget_Factory();
191 global $wp_widget_factory;
192 foreach (self::$args['widget_options'] as $key => $value) {
193 if (!isset(self::$inited[$key])) {
194
195 self::$inited[$key] = true;
196 $wp_widget_factory->register(ADMINIFY_Widget::instance($key, $value));
197 }
198 }
199 }
200
201 // Setup comment option framework
202 $params = array();
203 if (class_exists('ADMINIFY_Comment_Metabox') && !empty(self::$args['comment_options'])) {
204 foreach (self::$args['comment_options'] as $key => $value) {
205 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
206
207 $params['args'] = $value;
208 $params['sections'] = self::$args['sections'][$key];
209 self::$inited[$key] = true;
210
211 ADMINIFY_Comment_Metabox::instance($key, $params);
212 }
213 }
214 }
215
216 // Setup shortcode option framework
217 $params = array();
218 if (class_exists('ADMINIFY_Shortcoder') && !empty(self::$args['shortcode_options'])) {
219 foreach (self::$args['shortcode_options'] as $key => $value) {
220 if (!empty(self::$args['sections'][$key]) && !isset(self::$inited[$key])) {
221
222 $params['args'] = $value;
223 $params['sections'] = self::$args['sections'][$key];
224 self::$inited[$key] = true;
225
226 ADMINIFY_Shortcoder::instance($key, $params);
227 }
228 }
229
230 // Once editor setup for gutenberg and media buttons
231 if (class_exists('ADMINIFY_Shortcoder') && !empty(self::$shortcode_instances)) {
232 foreach (self::$shortcode_instances as $instance) {
233 if (!empty($instance['show_in_editor'])) {
234 ADMINIFY_Shortcoder::once_editor_setup();
235 break;
236 }
237 }
238 }
239 }
240
241 do_action('adminify_loaded');
242 }
243
244 // Create options
245 public static function createOptions($id, $args = array())
246 {
247 self::$args['admin_options'][$id] = $args;
248 }
249
250 // Create customize options
251 public static function createCustomizeOptions($id, $args = array())
252 {
253 self::$args['customize_options'][$id] = $args;
254 }
255
256 // Create metabox options
257 public static function createMetabox($id, $args = array())
258 {
259 self::$args['metabox_options'][$id] = $args;
260 }
261
262 // Create menu options
263 public static function createNavMenuOptions($id, $args = array())
264 {
265 self::$args['nav_menu_options'][$id] = $args;
266 }
267
268 // Create shortcoder options
269 public static function createShortcoder($id, $args = array())
270 {
271 self::$args['shortcode_options'][$id] = $args;
272 }
273
274 // Create taxonomy options
275 public static function createTaxonomyOptions($id, $args = array())
276 {
277 self::$args['taxonomy_options'][$id] = $args;
278 }
279
280 // Create profile options
281 public static function createProfileOptions($id, $args = array())
282 {
283 self::$args['profile_options'][$id] = $args;
284 }
285
286 // Create widget
287 public static function createWidget($id, $args = array())
288 {
289 self::$args['widget_options'][$id] = $args;
290 self::set_used_fields($args);
291 }
292
293 // Create comment metabox
294 public static function createCommentMetabox($id, $args = array())
295 {
296 self::$args['comment_options'][$id] = $args;
297 }
298
299 // Create section
300 public static function createSection($id, $sections)
301 {
302 self::$args['sections'][$id][] = $sections;
303 self::set_used_fields($sections);
304 }
305
306 // Set directory constants
307 public static function constants()
308 {
309
310 // We need this path-finder code for set URL of framework
311 $dirname = str_replace('//', '/', wp_normalize_path(dirname(dirname(self::$file))));
312 $theme_dir = str_replace('//', '/', wp_normalize_path(get_parent_theme_file_path()));
313 $plugin_dir = str_replace('//', '/', wp_normalize_path(WP_PLUGIN_DIR));
314 $plugin_dir = str_replace('/opt/bitnami', '/bitnami', $plugin_dir);
315 $located_plugin = (preg_match('#' . self::sanitize_dirname($plugin_dir) . '#', self::sanitize_dirname($dirname))) ? true : false;
316 $directory = ($located_plugin) ? $plugin_dir : $theme_dir;
317 $directory_uri = ($located_plugin) ? WP_PLUGIN_URL : get_parent_theme_file_uri();
318 $foldername = str_replace($directory, '', $dirname);
319 $protocol_uri = (is_ssl()) ? 'https' : 'http';
320 $directory_uri = set_url_scheme($directory_uri, $protocol_uri);
321
322 self::$dir = $dirname;
323 self::$url = $directory_uri . $foldername;
324 }
325
326 // Include file helper
327 public static function include_plugin_file($file, $load = true)
328 {
329
330 $path = '';
331 $file = ltrim($file, '/');
332 $override = apply_filters('adminify_override', 'adminify-override');
333
334 if (file_exists(get_parent_theme_file_path($override . '/' . $file))) {
335 $path = get_parent_theme_file_path($override . '/' . $file);
336 } elseif (file_exists(get_theme_file_path($override . '/' . $file))) {
337 $path = get_theme_file_path($override . '/' . $file);
338 } elseif (file_exists(self::$dir . '/' . $override . '/' . $file)) {
339 $path = self::$dir . '/' . $override . '/' . $file;
340 } elseif (file_exists(self::$dir . '/' . $file)) {
341 $path = self::$dir . '/' . $file;
342 }
343
344 if (!empty($path) && !empty($file) && $load) {
345
346 global $wp_query;
347
348 if (is_object($wp_query) && function_exists('load_template')) {
349
350 load_template($path, true);
351 } else {
352
353 require_once($path);
354 }
355 } else {
356
357 return self::$dir . '/' . $file;
358 }
359 }
360
361 // Is active plugin helper
362 public static function is_active_plugin($file = '')
363 {
364 return in_array($file, (array) get_option('active_plugins', array()));
365 }
366
367 // Sanitize dirname
368 public static function sanitize_dirname($dirname)
369 {
370 return preg_replace('/[^A-Za-z]/', '', $dirname);
371 }
372
373 // Set url constant
374 public static function include_plugin_url($file)
375 {
376 return esc_url(self::$url) . '/' . ltrim($file, '/');
377 }
378
379 // Include files
380 public static function includes()
381 {
382
383 // Helpers
384 self::include_plugin_file('functions/actions.php');
385 self::include_plugin_file('functions/helpers.php');
386 self::include_plugin_file('functions/sanitize.php');
387 self::include_plugin_file('functions/validate.php');
388
389 // Includes free version classes
390 self::include_plugin_file('classes/abstract.class.php');
391 self::include_plugin_file('classes/fields.class.php');
392 self::include_plugin_file('classes/admin-options.class.php');
393
394 // Includes premium version classes
395 if (self::$premium) {
396 self::include_plugin_file('classes/customize-options.class.php');
397 self::include_plugin_file('classes/metabox-options.class.php');
398 self::include_plugin_file('classes/nav-menu-options.class.php');
399 self::include_plugin_file('classes/profile-options.class.php');
400 self::include_plugin_file('classes/shortcode-options.class.php');
401 self::include_plugin_file('classes/taxonomy-options.class.php');
402 self::include_plugin_file('classes/widget-options.class.php');
403 self::include_plugin_file('classes/comment-options.class.php');
404 }
405
406 // Include all framework fields
407 $fields = apply_filters('adminify_fields', array(
408 'accordion',
409 'background',
410 'backup',
411 'border',
412 'button_set',
413 'callback',
414 'checkbox',
415 'code_editor',
416 'color',
417 'color_group',
418 'content',
419 'date',
420 'datetime',
421 'dimensions',
422 'fieldset',
423 'gallery',
424 'group',
425 'heading',
426 'icon',
427 'image_select',
428 'link',
429 'link_color',
430 'map',
431 'media',
432 'notice',
433 'number',
434 'palette',
435 'radio',
436 'repeater',
437 'select',
438 'slider',
439 'sortable',
440 'sorter',
441 'spacing',
442 'spinner',
443 'subheading',
444 'submessage',
445 'switcher',
446 'tabbed',
447 'text',
448 'textarea',
449 'typography',
450 'upload',
451 'wp_editor',
452 ));
453
454 if (!empty($fields)) {
455 foreach ($fields as $field) {
456 if (!class_exists('ADMINIFY_Field_' . $field) && class_exists('ADMINIFY_Fields')) {
457 self::include_plugin_file('fields/' . $field . '/' . $field . '.php');
458 }
459 }
460 }
461 }
462
463 // Setup textdomain
464 public static function textdomain()
465 {
466 load_textdomain('adminify', self::$dir . '/languages/' . get_locale() . '.mo');
467 }
468
469 // Set all of used fields
470 public static function set_used_fields($sections)
471 {
472
473 if (!empty($sections['fields'])) {
474
475 foreach ($sections['fields'] as $field) {
476
477 if (!empty($field['fields'])) {
478 self::set_used_fields($field);
479 }
480
481 if (!empty($field['tabs'])) {
482 self::set_used_fields(array('fields' => $field['tabs']));
483 }
484
485 if (!empty($field['accordions'])) {
486 self::set_used_fields(array('fields' => $field['accordions']));
487 }
488
489 if (!empty($field['type'])) {
490 self::$fields[$field['type']] = $field;
491 }
492 }
493 }
494 }
495
496 // Enqueue admin and fields styles and scripts
497 public static function add_admin_enqueue_scripts()
498 {
499
500 if (!self::$enqueue) {
501
502 // Loads scripts and styles only when needed
503 $wpscreen = get_current_screen();
504
505 if (!empty(self::$args['admin_options'])) {
506 foreach (self::$args['admin_options'] as $argument) {
507 if (substr($wpscreen->id, -strlen($argument['menu_slug'])) === $argument['menu_slug']) {
508 self::$enqueue = true;
509 }
510 }
511 }
512
513 if (!empty(self::$args['metabox_options'])) {
514 foreach (self::$args['metabox_options'] as $argument) {
515 if (in_array($wpscreen->post_type, (array) $argument['post_type'])) {
516 self::$enqueue = true;
517 }
518 }
519 }
520
521 if (!empty(self::$args['taxonomy_options'])) {
522 foreach (self::$args['taxonomy_options'] as $argument) {
523 if (in_array($wpscreen->taxonomy, (array) $argument['taxonomy'])) {
524 self::$enqueue = true;
525 }
526 }
527 }
528
529 if (!empty(self::$shortcode_instances)) {
530 foreach (self::$shortcode_instances as $argument) {
531 if (($argument['show_in_editor'] && $wpscreen->base === 'post') || $argument['show_in_custom']) {
532 self::$enqueue = true;
533 }
534 }
535 }
536
537 if (!empty(self::$args['widget_options']) && ($wpscreen->id === 'widgets' || $wpscreen->id === 'customize')) {
538 self::$enqueue = true;
539 }
540
541 if (!empty(self::$args['customize_options']) && $wpscreen->id === 'customize') {
542 self::$enqueue = true;
543 }
544
545 if (!empty(self::$args['nav_menu_options']) && $wpscreen->id === 'nav-menus') {
546 self::$enqueue = true;
547 }
548
549 if (!empty(self::$args['profile_options']) && ($wpscreen->id === 'profile' || $wpscreen->id === 'user-edit')) {
550 self::$enqueue = true;
551 }
552
553 if (!empty(self::$args['comment_options']) && $wpscreen->id === 'comment') {
554 self::$enqueue = true;
555 }
556
557 if ($wpscreen->id === 'tools_page_adminify-welcome') {
558 self::$enqueue = true;
559 }
560 }
561
562 if (!apply_filters('adminify_enqueue_assets', self::$enqueue)) {
563 return;
564 }
565
566 // Check for developer mode
567 $min = (self::$premium && SCRIPT_DEBUG) ? '' : '.min';
568
569 // Admin utilities
570 wp_enqueue_media();
571
572 // Wp color picker
573 wp_enqueue_style('wp-color-picker');
574 wp_enqueue_script('wp-color-picker');
575
576 // Font awesome 4 and 5 loader
577 if (apply_filters('adminify_fa4', false)) {
578 wp_enqueue_style('adminify-fa', 'https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome' . $min . '.css', array(), '4.7.0', 'all');
579 } else {
580 wp_enqueue_style('adminify-fa5', 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/all' . $min . '.css', array(), '5.15.5', 'all');
581 wp_enqueue_style('adminify-fa5-v4-shims', 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/v4-shims' . $min . '.css', array(), '5.15.5', 'all');
582 }
583
584 // Main style
585 wp_enqueue_style('adminify', self::include_plugin_url('assets/css/style' . $min . '.css'), array(), self::$version, 'all');
586
587 // Main RTL styles
588 if (is_rtl()) {
589 wp_enqueue_style('adminify-rtl', self::include_plugin_url('assets/css/style-rtl' . $min . '.css'), array(), self::$version, 'all');
590 }
591
592 // Main scripts
593 wp_enqueue_script('adminify-plugins', self::include_plugin_url('assets/js/plugins' . $min . '.js'), array(), self::$version, true);
594 wp_enqueue_script('adminify', self::include_plugin_url('assets/js/main' . $min . '.js'), array('adminify-plugins'), self::$version, true);
595
596 // Main variables
597 wp_localize_script('adminify', 'adminify_vars', array(
598 'color_palette' => apply_filters('adminify_color_palette', array()),
599 'i18n' => array(
600 'confirm' => esc_html__('Are you sure?', 'adminify'),
601 'typing_text' => esc_html__('Please enter %s or more characters', 'adminify'),
602 'searching_text' => esc_html__('Searching...', 'adminify'),
603 'no_results_text' => esc_html__('No results found.', 'adminify'),
604 ),
605 ));
606
607 // Enqueue fields scripts and styles
608 $enqueued = array();
609
610 if (!empty(self::$fields)) {
611 foreach (self::$fields as $field) {
612 if (!empty($field['type'])) {
613 $classname = 'ADMINIFY_Field_' . $field['type'];
614 if (class_exists($classname) && method_exists($classname, 'enqueue')) {
615 $instance = new $classname($field);
616 if (method_exists($classname, 'enqueue')) {
617 $instance->enqueue();
618 }
619 unset($instance);
620 }
621 }
622 }
623 }
624
625 do_action('adminify_enqueue');
626 }
627
628 // Add typography enqueue styles to front page
629 public static function add_typography_enqueue_styles()
630 {
631
632 if (!empty(self::$webfonts)) {
633
634 if (!empty(self::$webfonts['enqueue'])) {
635
636 $query = array();
637 $fonts = array();
638
639 foreach (self::$webfonts['enqueue'] as $family => $styles) {
640 $fonts[] = $family . ((!empty($styles)) ? ':' . implode(',', $styles) : '');
641 }
642
643 if (!empty($fonts)) {
644 $query['family'] = implode('%7C', $fonts);
645 }
646
647 if (!empty(self::$subsets)) {
648 $query['subset'] = implode(',', self::$subsets);
649 }
650
651 $query['display'] = 'swap';
652
653 wp_enqueue_style('adminify-google-web-fonts', esc_url(add_query_arg($query, '//fonts.googleapis.com/css')), array(), null);
654 }
655
656 if (!empty(self::$webfonts['async'])) {
657
658 $fonts = array();
659
660 foreach (self::$webfonts['async'] as $family => $styles) {
661 $fonts[] = $family . ((!empty($styles)) ? ':' . implode(',', $styles) : '');
662 }
663
664 wp_enqueue_script('adminify-google-web-fonts', esc_url('//ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js'), array(), null);
665
666 wp_localize_script('adminify-google-web-fonts', 'WebFontConfig', array('google' => array('families' => $fonts)));
667 }
668 }
669 }
670
671 // Add admin body class
672 public static function add_admin_body_class($classes)
673 {
674
675 if (apply_filters('adminify_fa4', false)) {
676 $classes .= 'adminify-fa5-shims';
677 }
678
679 return $classes;
680 }
681
682 // Add custom css to front page
683 public static function add_custom_css()
684 {
685
686 if (!empty(self::$css)) {
687 echo '<style type="text/css">' . wp_strip_all_tags(self::$css) . '</style>';
688 }
689 }
690
691 // Add a new framework field
692 public static function field($field = array(), $value = '', $unique = '', $where = '', $parent = '')
693 {
694
695 // Check for unallow fields
696 if (!empty($field['_notice'])) {
697
698 $field_type = $field['type'];
699
700 $field = array();
701 $field['content'] = esc_html__('Oops! Not allowed.', 'adminify') . ' <strong>(' . $field_type . ')</strong>';
702 $field['type'] = 'notice';
703 $field['style'] = 'danger';
704 }
705
706 $depend = '';
707 $visible = '';
708 $unique = (!empty($unique)) ? $unique : '';
709 $class = (!empty($field['class'])) ? ' ' . esc_attr($field['class']) : '';
710 $is_pseudo = (!empty($field['pseudo'])) ? ' adminify-pseudo-field' : '';
711 $field_type = (!empty($field['type'])) ? esc_attr($field['type']) : '';
712
713 if (!empty($field['dependency'])) {
714
715 $dependency = $field['dependency'];
716 $depend_visible = '';
717 $data_controller = '';
718 $data_condition = '';
719 $data_value = '';
720 $data_global = '';
721
722 if (is_array($dependency[0])) {
723 $data_controller = implode('|', array_column($dependency, 0));
724 $data_condition = implode('|', array_column($dependency, 1));
725 $data_value = implode('|', array_column($dependency, 2));
726 $data_global = implode('|', array_column($dependency, 3));
727 $depend_visible = implode('|', array_column($dependency, 4));
728 } else {
729 $data_controller = (!empty($dependency[0])) ? $dependency[0] : '';
730 $data_condition = (!empty($dependency[1])) ? $dependency[1] : '';
731 $data_value = (!empty($dependency[2])) ? $dependency[2] : '';
732 $data_global = (!empty($dependency[3])) ? $dependency[3] : '';
733 $depend_visible = (!empty($dependency[4])) ? $dependency[4] : '';
734 }
735
736 $depend .= ' data-controller="' . esc_attr($data_controller) . '"';
737 $depend .= ' data-condition="' . esc_attr($data_condition) . '"';
738 $depend .= ' data-value="' . esc_attr($data_value) . '"';
739 $depend .= (!empty($data_global)) ? ' data-depend-global="true"' : '';
740
741 $visible = (!empty($depend_visible)) ? ' adminify-depend-visible' : ' adminify-depend-hidden';
742 }
743
744 // These attributes has been sanitized above.
745 echo '<div class="adminify-field adminify-field-' . $field_type . $is_pseudo . $class . $visible . '"' . $depend . '>';
746
747 if (!empty($field_type)) {
748
749 if (!empty($field['fancy_title'])) {
750 echo '<div class="adminify-fancy-title">' . $field['fancy_title'] . '</div>';
751 }
752
753 if (!empty($field['title'])) {
754 echo '<div class="adminify-title">';
755 echo '<h4>' . $field['title'] . '</h4>';
756 echo (!empty($field['subtitle'])) ? '<div class="adminify-subtitle-text">' . $field['subtitle'] . '</div>' : '';
757 echo '</div>';
758 }
759
760 echo (!empty($field['title']) || !empty($field['fancy_title'])) ? '<div class="adminify-fieldset">' : '';
761
762 $value = (!isset($value) && isset($field['default'])) ? $field['default'] : $value;
763 $value = (isset($field['value'])) ? $field['value'] : $value;
764
765 $classname = 'ADMINIFY_Field_' . $field_type;
766
767 if (class_exists($classname)) {
768 $instance = new $classname($field, $value, $unique, $where, $parent);
769 $instance->render();
770 } else {
771 echo '<p>' . esc_html__('Field not found!', 'adminify') . '</p>';
772 }
773 } else {
774 echo '<p>' . esc_html__('Field not found!', 'adminify') . '</p>';
775 }
776
777 echo (!empty($field['title']) || !empty($field['fancy_title'])) ? '</div>' : '';
778 echo '<div class="clear"></div>';
779 echo '</div>';
780 }
781 }
782 }
783
784 ADMINIFY::init(__FILE__);
785