PluginProbe
Easy Hotel – Powerful Hotel Booking / 2.0.4
Easy Hotel – Powerful Hotel Booking v2.0.4
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 / image_select / image_select.php

image_select.php in Easy Hotel – Powerful Hotel Booking 2.0.4, at admin/includes/framework/fields/image_select/image_select.php

80 lines 2.4 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: image_select
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_image_select' ) ) {
11 class ESHB_Field_image_select 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 'multiple' => false,
21 'inline' => false,
22 'options' => array(),
23 ) );
24
25 $inline = ( $args['inline'] ) ? ' csf--inline-list' : '';
26
27 $value = ( is_array( $this->value ) ) ? $this->value : array_filter( (array) $this->value );
28
29 echo wp_kses_post($this->field_before());
30
31 if ( ! empty( $args['options'] ) ) {
32
33 echo '<div class="csf-siblings csf--image-group'. esc_attr( $inline ) .'" data-multiple="'. esc_attr( $args['multiple'] ) .'">';
34
35 $num = 1;
36
37 foreach ( $args['options'] as $key => $option ) {
38
39 $type = ( $args['multiple'] ) ? 'checkbox' : 'radio';
40 $extra = ( $args['multiple'] ) ? '[]' : '';
41 $active = ( in_array( $key, $value ) ) ? ' csf--active' : '';
42 $checked = ( in_array( $key, $value ) ) ? ' checked' : '';
43
44 echo '<div class="csf--sibling csf--image'. esc_attr( $active ) .'">';
45 echo '<figure>';
46 echo '<img src="'. esc_url( $option ) .'" alt="img-'. esc_attr( $num++ ) .'" />';
47 echo '<input type="'. esc_attr( $type ) .'" name="'. esc_attr( $this->field_name( $extra ) ) .'" value="'. esc_attr( $key ) .'"'. esc_attr($this->field_attributes()) . esc_attr( $checked ) .'/>';
48 echo '</figure>';
49 echo '</div>';
50
51 }
52
53 echo '</div>';
54
55 }
56
57 echo wp_kses_post($this->field_after());
58
59 }
60
61 public function output() {
62
63 $output = '';
64 $bg_image = array();
65 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
66 $elements = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
67
68 if ( ! empty( $elements ) && isset( $this->value ) && $this->value !== '' ) {
69 $output = $elements .'{background-image:url('. $this->value .')'. $important .';}';
70 }
71
72 $this->parent->output_css .= $output;
73
74 return $output;
75
76 }
77
78 }
79 }
80