PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.4.5
StreamCast – bring live radio to your site with a sleek player v2.4.5
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / vendor / codestar-framework / fields / spacing / spacing.php

spacing.php in StreamCast – bring live radio to your site with a sleek player 2.4.5, at vendor/codestar-framework/fields/spacing/spacing.php

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