PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.1.6
Adminify – White Label, Admin Menu Editor, Login Customizer v3.1.6
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 / abstract.class.php

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

105 lines 3.6 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 * Abstract Class
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'ADMINIFY_Abstract' ) ) {
11 abstract class ADMINIFY_Abstract {
12
13 public $abstract = '';
14 public $output_css = '';
15
16 public function __construct() {
17
18 // Collect output css and typography
19 if ( ! empty( $this->args['output_css'] ) || ! empty( $this->args['enqueue_webfont'] ) ) {
20 add_action( 'wp_enqueue_scripts', [ $this, 'collect_output_css_and_typography' ], 10 );
21 ADMINIFY::$css = apply_filters( "adminify_{$this->unique}_output_css", ADMINIFY::$css, $this );
22 }
23 }
24
25 public function collect_output_css_and_typography() {
26 $this->recursive_output_css( $this->pre_fields );
27 }
28
29 public function recursive_output_css( $fields = [], $combine_field = [] ) {
30 if ( ! empty( $fields ) ) {
31 foreach ( $fields as $field ) {
32 $field_id = ( ! empty( $field['id'] ) ) ? $field['id'] : '';
33 $field_type = ( ! empty( $field['type'] ) ) ? $field['type'] : '';
34 $field_output = ( ! empty( $field['output'] ) ) ? $field['output'] : '';
35 $field_check = ( $field_type === 'typography' || $field_output ) ? true : false;
36 $field_class = 'ADMINIFY_Field_' . $field_type;
37
38 if ( $field_type && $field_id ) {
39 if ( $field_type === 'fieldset' ) {
40 if ( ! empty( $field['fields'] ) ) {
41 $this->recursive_output_css( $field['fields'], $field );
42 }
43 }
44
45 if ( $field_type === 'accordion' ) {
46 if ( ! empty( $field['accordions'] ) ) {
47 foreach ( $field['accordions'] as $accordion ) {
48 $this->recursive_output_css( $accordion['fields'], $field );
49 }
50 }
51 }
52
53 if ( $field_type === 'tabbed' ) {
54 if ( ! empty( $field['tabs'] ) ) {
55 foreach ( $field['tabs'] as $accordion ) {
56 $this->recursive_output_css( $accordion['fields'], $field );
57 }
58 }
59 }
60
61 if ( class_exists( $field_class ) ) {
62 if ( method_exists( $field_class, 'output' ) || method_exists( $field_class, 'enqueue_google_fonts' ) ) {
63 $field_value = '';
64
65 if ( $field_check && ( $this->abstract === 'options' || $this->abstract === 'customize' ) ) {
66 if ( ! empty( $combine_field ) ) {
67 $field_value = ( isset( $this->options[ $combine_field['id'] ][ $field_id ] ) ) ? $this->options[ $combine_field['id'] ][ $field_id ] : '';
68 } else {
69 $field_value = ( isset( $this->options[ $field_id ] ) ) ? $this->options[ $field_id ] : '';
70 }
71 } elseif ( $field_check && ( $this->abstract === 'metabox' && is_singular() || $this->abstract === 'taxonomy' && is_archive() ) ) {
72 if ( ! empty( $combine_field ) ) {
73 $meta_value = $this->get_meta_value( $combine_field );
74 $field_value = ( isset( $meta_value[ $field_id ] ) ) ? $meta_value[ $field_id ] : '';
75 } else {
76 $meta_value = $this->get_meta_value( $field );
77 $field_value = ( isset( $meta_value ) ) ? $meta_value : '';
78 }
79 }
80
81 $instance = new $field_class( $field, $field_value, $this->unique, 'wp/enqueue', $this );
82
83 // typography enqueue and embed google web fonts
84 if ( $field_type === 'typography' && $this->args['enqueue_webfont'] && ! empty( $field_value['font-family'] ) ) {
85 $method = ( ! empty( $this->args['async_webfont'] ) ) ? 'async' : 'enqueue';
86
87 $instance->enqueue_google_fonts( $method );
88 }
89
90 // output css
91 if ( $field_output && $this->args['output_css'] ) {
92 ADMINIFY::$css .= $instance->output();
93 }
94
95 unset( $instance );
96 }
97 }
98 }
99 }
100 }
101 }
102
103 }
104 }
105