PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 1.2.4
Forumax – AI Powered Advanced Community Forum Plugin v1.2.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / includes / admin / settings / csf / classes / setup.class.php

setup.class.php in Forumax – AI Powered Advanced Community Forum Plugin 1.2.4, at includes/admin/settings/csf/classes/setup.class.php

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