PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / codestar-framework / classes / abstract.class.php

abstract.class.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/classes/abstract.class.php

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