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 / fields / border / border.php

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

188 lines 7.5 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 // phpcs:ignoreFile WordPress.Security.EscapeOutput.OutputNotEscaped
5 /**
6 *
7 * Field: border
8 *
9 * @since 1.0.0
10 * @version 1.0.0
11 */
12 if ( ! class_exists( 'CSF_Field_border' ) ) {
13 class CSF_Field_border extends CSF_Fields {
14
15
16 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
17
18 parent::__construct( $field, $value, $unique, $where, $parent );
19 }
20
21 public function render() {
22
23 // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
24 $args = wp_parse_args(
25 $this->field,
26 array(
27 'top_icon' => '<i class="fas fa-long-arrow-alt-up"></i>',
28 'left_icon' => '<i class="fas fa-long-arrow-alt-left"></i>',
29 'bottom_icon' => '<i class="fas fa-long-arrow-alt-down"></i>',
30 'right_icon' => '<i class="fas fa-long-arrow-alt-right"></i>',
31 'all_icon' => '<i class="fas fa-arrows-alt"></i>',
32 'top_placeholder' => esc_html__( 'top', 'csf' ),
33 'right_placeholder' => esc_html__( 'right', 'csf' ),
34 'bottom_placeholder' => esc_html__( 'bottom', 'csf' ),
35 'left_placeholder' => esc_html__( 'left', 'csf' ),
36 'all_placeholder' => esc_html__( 'all', 'csf' ),
37 'top' => true,
38 'left' => true,
39 'bottom' => true,
40 'right' => true,
41 'all' => false,
42 'color' => true,
43 'style' => true,
44 'unit' => 'px',
45 )
46 );
47 // phpcs:enable WordPress.WP.I18n.TextDomainMismatch
48
49 $default_value = array(
50 'top' => '',
51 'right' => '',
52 'bottom' => '',
53 'left' => '',
54 'color' => '',
55 'style' => 'solid',
56 'all' => '',
57 );
58
59 // phpcs:disable WordPress.WP.I18n.TextDomainMismatch
60 $border_props = array(
61 'solid' => esc_html__( 'Solid', 'csf' ),
62 'dashed' => esc_html__( 'Dashed', 'csf' ),
63 'dotted' => esc_html__( 'Dotted', 'csf' ),
64 'double' => esc_html__( 'Double', 'csf' ),
65 'inset' => esc_html__( 'Inset', 'csf' ),
66 'outset' => esc_html__( 'Outset', 'csf' ),
67 'groove' => esc_html__( 'Groove', 'csf' ),
68 'ridge' => esc_html__( 'ridge', 'csf' ),
69 'none' => esc_html__( 'None', 'csf' ),
70 );
71 // phpcs:enable WordPress.WP.I18n.TextDomainMismatch
72
73 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
74
75 $value = wp_parse_args( $this->value, $default_value );
76
77 echo $this->field_before();
78
79 echo '<div class="csf--inputs" data-depend-id="' . esc_attr( $this->field['id'] ) . '">';
80
81 if ( ! empty( $args['all'] ) ) {
82
83 $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . esc_attr( $args['all_placeholder'] ) . '"' : '';
84
85 echo '<div class="csf--input">';
86 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="csf--label csf--icon">' . $args['all_icon'] . '</span>' : '';
87 echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . $placeholder . ' class="csf-input-number csf--is-unit" step="any" />';
88 echo ( ! empty( $args['unit'] ) ) ? '<span class="csf--label csf--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
89 echo '</div>';
90
91 } else {
92
93 $properties = array();
94
95 foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) {
96 if ( ! empty( $args[ $prop ] ) ) {
97 $properties[] = $prop;
98 }
99 }
100
101 $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties;
102
103 foreach ( $properties as $property ) {
104
105 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . esc_attr( $args[ $property . '_placeholder' ] ) . '"' : '';
106
107 echo '<div class="csf--input">';
108 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="csf--label csf--icon">' . $args[ $property . '_icon' ] . '</span>' : '';
109 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . $placeholder . ' class="csf-input-number csf--is-unit" step="any" />';
110 echo ( ! empty( $args['unit'] ) ) ? '<span class="csf--label csf--unit">' . esc_attr( $args['unit'] ) . '</span>' : '';
111 echo '</div>';
112
113 }
114 }
115
116 if ( ! empty( $args['style'] ) ) {
117 echo '<div class="csf--input">';
118 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
119 foreach ( $border_props as $border_prop_key => $border_prop_value ) {
120 $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : '';
121 echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $border_prop_value ) . '</option>';
122 }
123 echo '</select>';
124 echo '</div>';
125 }
126
127 echo '</div>';
128
129 if ( ! empty( $args['color'] ) ) {
130 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . esc_attr( $default_value['color'] ) . '"' : '';
131 echo '<div class="csf--color">';
132 echo '<div class="csf-field-color">';
133 echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="csf-color"' . $default_color_attr . ' />';
134 echo '</div>';
135 echo '</div>';
136 }
137
138 echo $this->field_after();
139
140 }
141
142 public function output() {
143
144 $output = '';
145 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
146 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
147 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
148
149 // properties
150 $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : '';
151 $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : '';
152 $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : '';
153 $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : '';
154 $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : '';
155 $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : '';
156 $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : '';
157
158 if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) {
159
160 $output = $element . '{';
161 $output .= ( $all !== '' ) ? 'border-width:' . $all . $unit . $important . ';' : '';
162 $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
163 $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
164 $output .= '}';
165
166 } elseif ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) {
167
168 $output = $element . '{';
169 $output .= ( $top !== '' ) ? 'border-top-width:' . $top . $unit . $important . ';' : '';
170 $output .= ( $right !== '' ) ? 'border-right-width:' . $right . $unit . $important . ';' : '';
171 $output .= ( $bottom !== '' ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : '';
172 $output .= ( $left !== '' ) ? 'border-left-width:' . $left . $unit . $important . ';' : '';
173 $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : '';
174 $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : '';
175 $output .= '}';
176
177 }
178
179 $this->parent->output_css .= $output;
180
181 return $output;
182
183 }
184
185 }
186 }
187
188