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 / functions / customize.php

customize.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/codestar-framework/functions/customize.php

148 lines 4.7 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 // phpcs:ignoreFile WordPress.Security.EscapeOutput.OutputNotEscaped
3 /**
4 *
5 * WP Customize custom panel
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 *
10 */
11 if ( ! class_exists( 'WP_Customize_Panel_CSF' ) && class_exists( 'WP_Customize_Panel' ) ) {
12 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
13 class WP_Customize_Panel_CSF extends WP_Customize_Panel {
14 public $type = 'csf';
15 }
16 }
17
18 /**
19 *
20 * WP Customize custom section
21 *
22 * @since 1.0.0
23 * @version 1.0.0
24 *
25 */
26 if ( ! class_exists( 'WP_Customize_Section_CSF' ) && class_exists( 'WP_Customize_Section' ) ) {
27 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
28 class WP_Customize_Section_CSF extends WP_Customize_Section {
29 public $type = 'csf';
30 }
31 }
32
33 /**
34 *
35 * WP Customize custom control
36 *
37 * @since 1.0.0
38 * @version 1.0.0
39 *
40 */
41 if ( ! class_exists( 'WP_Customize_Control_CSF' ) && class_exists( 'WP_Customize_Control' ) ) {
42 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
43 class WP_Customize_Control_CSF extends WP_Customize_Control {
44
45 public $type = 'csf';
46 public $field = '';
47 public $unique = '';
48
49 public function render() {
50
51 $depend = '';
52 $visible = '';
53
54 if ( ! empty( $this->field['dependency'] ) ) {
55
56 $dependency = $this->field['dependency'];
57 $depend_visible = '';
58 $data_controller = '';
59 $data_condition = '';
60 $data_value = '';
61 $data_global = '';
62
63 if ( is_array( $dependency[0] ) ) {
64 $data_controller = implode( '|', array_column( $dependency, 0 ) );
65 $data_condition = implode( '|', array_column( $dependency, 1 ) );
66 $data_value = implode( '|', array_column( $dependency, 2 ) );
67 $data_global = implode( '|', array_column( $dependency, 3 ) );
68 $depend_visible = implode( '|', array_column( $dependency, 4 ) );
69 } else {
70 $data_controller = ( ! empty( $dependency[0] ) ) ? $dependency[0] : '';
71 $data_condition = ( ! empty( $dependency[1] ) ) ? $dependency[1] : '';
72 $data_value = ( ! empty( $dependency[2] ) ) ? $dependency[2] : '';
73 $data_global = ( ! empty( $dependency[3] ) ) ? $dependency[3] : '';
74 $depend_visible = ( ! empty( $dependency[4] ) ) ? $dependency[4] : '';
75 }
76
77 $depend .= ' data-controller="'. esc_attr( $data_controller ) .'"';
78 $depend .= ' data-condition="'. esc_attr( $data_condition ) .'"';
79 $depend .= ' data-value="'. esc_attr( $data_value ) .'"';
80 $depend .= ( ! empty( $data_global ) ) ? ' data-depend-global="true"' : '';
81
82 $visible = ' csf-dependency-control';
83 $visible .= ( ! empty( $depend_visible ) ) ? ' csf-depend-visible' : ' csf-depend-hidden';
84
85 }
86
87 $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
88 $class = 'customize-control customize-control-'. $this->type . $visible;
89
90 echo '<li id="'. esc_attr( $id ) .'" class="'. esc_attr( $class ) .'"'. $depend .'>';
91 $this->render_field_content();
92 echo '</li>';
93
94 }
95
96 public function render_field_content() {
97
98 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
99 $complex = apply_filters( 'csf_customize_complex_fields', array(
100 'accordion',
101 'background',
102 'border',
103 'button_set',
104 'checkbox',
105 'color_group',
106 'date',
107 'dimensions',
108 'fieldset',
109 'group',
110 'image_select',
111 'link',
112 'link_color',
113 'media',
114 'palette',
115 'repeater',
116 'sortable',
117 'sorter',
118 'spacing',
119 'switcher',
120 'tabbed',
121 'typography'
122 ) );
123
124 $field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : '';
125 $custom = ( ! empty( $this->field['customizer'] ) ) ? true : false;
126 $is_complex = ( in_array( $this->field['type'], $complex ) ) ? true : false;
127 $class = ( $is_complex || $custom ) ? ' csf-customize-complex' : '';
128 $atts = ( $is_complex || $custom ) ? ' data-unique-id="'. esc_attr( $this->unique ) .'" data-option-id="'. esc_attr( $field_id ) .'"' : '';
129
130 if ( ! $is_complex && ! $custom ) {
131 $this->field['attributes']['data-customize-setting-link'] = $this->settings['default']->id;
132 }
133
134 $this->field['name'] = $this->settings['default']->id;
135
136 $this->field['dependency'] = array();
137
138 echo '<div class="csf-customize-field'. esc_attr( $class ) .'"'. $atts .'>';
139
140 CSF::field( $this->field, $this->value(), $this->unique, 'customize' );
141
142 echo '</div>';
143
144 }
145
146 }
147 }
148