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 / dimensions / dimensions.php

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

102 lines 4.6 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: dimensions
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_dimensions' ) ) {
11 class ESHB_Field_dimensions 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 'width_icon' => '<i class="fas fa-arrows-alt-h"></i>',
21 'height_icon' => '<i class="fas fa-arrows-alt-v"></i>',
22 'width_placeholder' => esc_html__( 'width', 'easy-hotel' ),
23 'height_placeholder' => esc_html__( 'height', 'easy-hotel' ),
24 'width' => true,
25 'height' => true,
26 'unit' => true,
27 'show_units' => true,
28 'units' => array( 'px', '%', 'em' )
29 ) );
30
31 $default_values = array(
32 'width' => '',
33 'height' => '',
34 'unit' => 'px',
35 );
36
37 $value = wp_parse_args( $this->value, $default_values );
38 $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
39 $is_unit = ( ! empty( $unit ) ) ? ' csf--is-unit' : '';
40
41 echo wp_kses_post($this->field_before());
42
43 echo '<div class="csf--inputs" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
44
45 if ( ! empty( $args['width'] ) ) {
46 $placeholder = ( ! empty( $args['width_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['width_placeholder'] ) .'"' : '';
47 echo '<div class="csf--input">';
48 echo ( ! empty( $args['width_icon'] ) ) ? '<span class="csf--label csf--icon">'. wp_kses_post($args['width_icon']) .'</span>' : '';
49 echo '<input type="number" name="'. esc_attr( $this->field_name( '[width]' ) ) .'" value="'. esc_attr( $value['width'] ) .'"'. esc_attr($placeholder) .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
50 echo ( ! empty( $unit ) ) ? '<span class="csf--label csf--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
51 echo '</div>';
52 }
53
54 if ( ! empty( $args['height'] ) ) {
55 $placeholder = ( ! empty( $args['height_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['height_placeholder'] ) .'"' : '';
56 echo '<div class="csf--input">';
57 echo ( ! empty( $args['height_icon'] ) ) ? '<span class="csf--label csf--icon">'. wp_kses_post($args['height_icon']) .'</span>' : '';
58 echo '<input type="number" name="'. esc_attr( $this->field_name( '[height]' ) ) .'" value="'. esc_attr( $value['height'] ) .'"'. esc_attr($placeholder) .' class="csf-input-number'. esc_attr( $is_unit ) .'" step="any" />';
59 echo ( ! empty( $unit ) ) ? '<span class="csf--label csf--unit">'. esc_attr( $args['units'][0] ) .'</span>' : '';
60 echo '</div>';
61 }
62
63 if ( ! empty( $args['unit'] ) && ! empty( $args['show_units'] ) && count( $args['units'] ) > 1 ) {
64 echo '<div class="csf--input">';
65 echo '<select name="'. esc_attr( $this->field_name( '[unit]' ) ) .'">';
66 foreach ( $args['units'] as $unit ) {
67 $selected = ( $value['unit'] === $unit ) ? ' selected' : '';
68 echo '<option value="'. esc_attr( $unit ) .'"'. esc_attr( $selected ) .'>'. esc_attr( $unit ) .'</option>';
69 }
70 echo '</select>';
71 echo '</div>';
72 }
73
74 echo '</div>';
75
76 echo wp_kses_post($this->field_after());
77
78 }
79
80 public function output() {
81
82 $output = '';
83 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
84 $prefix = ( ! empty( $this->field['output_prefix'] ) ) ? $this->field['output_prefix'] .'-' : '';
85 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
86 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
87 $width = ( isset( $this->value['width'] ) && $this->value['width'] !== '' ) ? $prefix .'width:'. $this->value['width'] . $unit . $important .';' : '';
88 $height = ( isset( $this->value['height'] ) && $this->value['height'] !== '' ) ? $prefix .'height:'. $this->value['height'] . $unit . $important .';' : '';
89
90 if ( $width !== '' || $height !== '' ) {
91 $output = $element .'{'. $width . $height .'}';
92 }
93
94 $this->parent->output_css .= $output;
95
96 return $output;
97
98 }
99
100 }
101 }
102