PluginProbe
Easy Hotel – Powerful Hotel Booking / trunk
Easy Hotel – Powerful Hotel Booking vtrunk
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / framework / fields / spacing / spacing.php

spacing.php in Easy Hotel – Powerful Hotel Booking trunk, at admin/includes/framework/fields/spacing/spacing.php

172 lines 7.0 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( 'ESHB_Field_spacing' ) ) {
11 class ESHB_Field_spacing extends ESHB_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', 'easy-hotel' ),
26 'right_placeholder' => esc_html__( 'right', 'easy-hotel' ),
27 'bottom_placeholder' => esc_html__( 'bottom', 'easy-hotel' ),
28 'left_placeholder' => esc_html__( 'left', 'easy-hotel' ),
29 'all_placeholder' => esc_html__( 'all', 'easy-hotel' ),
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 ) ) ? ' csf--is-unit' : '';
52
53 echo wp_kses_post($this->field_before());
54
55 echo '<div class="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="csf--input">';
62 echo ( ! empty( $args['all_icon'] ) ) ? '<span class="csf--label 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'] ) .'"'. esc_attr($placeholder) .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
64 echo ( $unit ) ? '<span class="csf--label 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="csf--input">';
84 echo ( ! empty( $args[$property.'_icon'] ) ) ? '<span class="csf--label 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] ) .'"'. esc_attr($placeholder) .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
86 echo ( $unit ) ? '<span class="csf--label 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="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