PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.1.3
Adminify – White Label, Admin Menu Editor, Login Customizer v4.1.3
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 / Libs / adminify-framework / classes / setup.class.php

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

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