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

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

109 lines 4.1 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: repeater
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_repeater' ) ) {
11 class ESHB_Field_repeater 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 'max' => 0,
21 'min' => 0,
22 'button_title' => '<i class="fas fa-plus-circle"></i>',
23 ) );
24
25 if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
26
27 echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'easy-hotel' ) .'</div>';
28
29 } else {
30
31 echo wp_kses_post($this->field_before());
32
33 echo '<div class="csf-repeater-item csf-repeater-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
34 echo '<div class="csf-repeater-content">';
35 foreach ( $this->field['fields'] as $field ) {
36
37 $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
38 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
39
40 ESHB::field( $field, $field_default, '___'. $field_unique, 'field/repeater' );
41
42 }
43 echo '</div>';
44 echo '<div class="csf-repeater-helper">';
45 echo '<div class="csf-repeater-helper-inner">';
46 echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
47 echo '<i class="csf-repeater-clone far fa-clone"></i>';
48 echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'easy-hotel' ) .'"></i>';
49 echo '</div>';
50 echo '</div>';
51 echo '</div>';
52
53 echo '<div class="csf-repeater-wrapper csf-data-wrapper" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
54
55 if ( ! empty( $this->value ) && is_array( $this->value ) ) {
56
57 $num = 0;
58
59 foreach ( $this->value as $key => $value ) {
60
61 echo '<div class="csf-repeater-item">';
62 echo '<div class="csf-repeater-content">';
63 foreach ( $this->field['fields'] as $field ) {
64
65 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
66 $field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
67
68 ESHB::field( $field, $field_value, $field_unique, 'field/repeater' );
69
70 }
71 echo '</div>';
72 echo '<div class="csf-repeater-helper">';
73 echo '<div class="csf-repeater-helper-inner">';
74 echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
75 echo '<i class="csf-repeater-clone far fa-clone"></i>';
76 echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'easy-hotel' ) .'"></i>';
77 echo '</div>';
78 echo '</div>';
79 echo '</div>';
80
81 $num++;
82
83 }
84
85 }
86
87 echo '</div>';
88
89 echo '<div class="csf-repeater-alert csf-repeater-max">'. esc_html__( 'You cannot add more.', 'easy-hotel' ) .'</div>';
90 echo '<div class="csf-repeater-alert csf-repeater-min">'. esc_html__( 'You cannot remove more.', 'easy-hotel' ) .'</div>';
91 echo '<a href="#" class="button button-primary csf-repeater-add">'. wp_kses_post($args['button_title']) .'</a>';
92
93 echo wp_kses_post($this->field_after());
94
95 }
96
97 }
98
99 public function enqueue() {
100
101 if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
102 wp_enqueue_script( 'jquery-ui-sortable' );
103 }
104
105 }
106
107 }
108 }
109