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

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

98 lines 3.7 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: map
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ESHB_Field_map' ) ) {
11 class ESHB_Field_map extends ESHB_Fields {
12
13 public $version = '1.9.4';
14
15 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
16 parent::__construct( $field, $value, $unique, $where, $parent );
17 }
18
19 public function render() {
20
21 $args = wp_parse_args( $this->field, array(
22 'placeholder' => esc_html__( 'Search...', 'easy-hotel' ),
23 'latitude_text' => esc_html__( 'Latitude', 'easy-hotel' ),
24 'longitude_text' => esc_html__( 'Longitude', 'easy-hotel' ),
25 'address_field' => '',
26 'height' => '',
27 ) );
28
29 $value = wp_parse_args( $this->value, array(
30 'address' => '',
31 'latitude' => '20',
32 'longitude' => '0',
33 'zoom' => '2',
34 ) );
35
36 $default_settings = array(
37 'center' => array( $value['latitude'], $value['longitude'] ),
38 'zoom' => $value['zoom'],
39 'scrollWheelZoom' => false,
40 );
41
42 $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
43 $settings = wp_parse_args( $settings, $default_settings );
44
45 $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : '';
46 $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : '';
47
48 echo wp_kses_post($this->field_before());
49
50 if ( empty( $args['address_field'] ) ) {
51 echo '<div class="csf--map-search">';
52 echo '<input type="text" name="'. esc_attr( $this->field_name( '[address]' ) ) .'" value="'. esc_attr( $value['address'] ) .'"'. esc_attr($this->field_attributes( $placeholder )) .' />';
53 echo '</div>';
54 } else {
55 echo '<div class="csf--address-field" data-address-field="'. esc_attr( $args['address_field'] ) .'"></div>';
56 }
57
58 echo '<div class="csf--map-osm-wrap"><div class="csf--map-osm" data-map="'. esc_attr( wp_json_encode( $settings ) ) .'"'. esc_attr($style_attr) .'></div></div>';
59
60 echo '<div class="csf--map-inputs">';
61
62 echo '<div class="csf--map-input">';
63 echo '<label>'. esc_attr( $args['latitude_text'] ) .'</label>';
64 echo '<input type="text" name="'. esc_attr( $this->field_name( '[latitude]' ) ) .'" value="'. esc_attr( $value['latitude'] ) .'" class="csf--latitude" />';
65 echo '</div>';
66
67 echo '<div class="csf--map-input">';
68 echo '<label>'. esc_attr( $args['longitude_text'] ) .'</label>';
69 echo '<input type="text" name="'. esc_attr( $this->field_name( '[longitude]' ) ) .'" value="'. esc_attr( $value['longitude'] ) .'" class="csf--longitude" />';
70 echo '</div>';
71
72 echo '</div>';
73
74 echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[zoom]' ) ) .'" value="'. esc_attr( $value['zoom'] ) .'" class="csf--zoom" />';
75
76 echo wp_kses_post($this->field_after());
77
78 }
79
80 public function enqueue() {
81
82 if ( ! wp_script_is( 'csf-leaflet' ) ) {
83 wp_enqueue_script( 'csf-leaflet', ESHB_PL_PATH . 'admin/includes/framework/assets/js/leaflet.js', array( 'easy-hotel' ), $this->version, true );
84 }
85
86 if ( ! wp_style_is( 'csf-leaflet' ) ) {
87 wp_enqueue_style( 'csf-leaflet', ESHB_PL_PATH . 'admin/includes/framework/assets/js/leaflet.css', array(), $this->version );
88 }
89
90 if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
91 wp_enqueue_script( 'jquery-ui-autocomplete' );
92 }
93
94 }
95
96 }
97 }
98