PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.2.4
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.2.4
2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 All 57 releases
darkify / admin / ta-framework / fields / map / map.php

map.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.2.4, at admin/ta-framework/fields/map/map.php

101 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: map
6 *
7 * @since 1.0.0
8 * @version 1.0.0
9 */
10 if ( ! class_exists( 'DRK_LITE_Field_map' ) ) {
11 class DRK_LITE_Field_map extends DRK_LITE_Fields {
12
13 public $version = '1.9.2';
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(
22 $this->field,
23 array(
24 'placeholder' => esc_html__( 'Search...', 'darkify' ),
25 'latitude_text' => esc_html__( 'Latitude', 'darkify' ),
26 'longitude_text' => esc_html__( 'Longitude', 'darkify' ),
27 'address_field' => '',
28 'height' => '',
29 )
30 );
31
32 $value = wp_parse_args(
33 $this->value,
34 array(
35 'address' => '',
36 'latitude' => '20',
37 'longitude' => '0',
38 'zoom' => '2',
39 )
40 );
41
42 $default_settings = array(
43 'center' => array( $value['latitude'], $value['longitude'] ),
44 'zoom' => $value['zoom'],
45 'scrollWheelZoom' => false,
46 );
47
48 $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
49 $settings = wp_parse_args( $settings, $default_settings );
50
51 $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:' . esc_attr( $args['height'] ) . ';"' : '';
52 $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : '';
53
54 echo wp_kses_post( $this->field_before() );
55
56 if ( empty( $args['address_field'] ) ) {
57 echo '<div class="drk_lite--map-search">';
58 echo '<input type="text" name="' . esc_attr( $this->field_name( '[address]' ) ) . '" value="' . esc_attr( $value['address'] ) . '"' . wp_kses_post($this->field_attributes( $placeholder )) . ' />';
59 echo '</div>';
60 } else {
61 echo '<div class="drk_lite--address-field" data-address-field="' . esc_attr( $args['address_field'] ) . '"></div>';
62 }
63
64 echo '<div class="drk_lite--map-osm-wrap"><div class="drk_lite--map-osm" data-map="' . esc_attr( wp_json_encode( $settings ) ) . '"' . wp_kses_post($style_attr) . '></div></div>';
65
66 echo '<div class="drk_lite--map-inputs">';
67
68 echo '<div class="drk_lite--map-input">';
69 echo '<label>' . esc_attr( $args['latitude_text'] ) . '</label>';
70 echo '<input type="text" name="' . esc_attr( $this->field_name( '[latitude]' ) ) . '" value="' . esc_attr( $value['latitude'] ) . '" class="drk_lite--latitude" />';
71 echo '</div>';
72
73 echo '<div class="drk_lite--map-input">';
74 echo '<label>' . esc_attr( $args['longitude_text'] ) . '</label>';
75 echo '<input type="text" name="' . esc_attr( $this->field_name( '[longitude]' ) ) . '" value="' . esc_attr( $value['longitude'] ) . '" class="drk_lite--longitude" />';
76 echo '</div>';
77
78 echo '</div>';
79
80 echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[zoom]' ) ) . '" value="' . esc_attr( $value['zoom'] ) . '" class="drk_lite--zoom" />';
81
82 echo wp_kses_post( $this->field_after() );
83 }
84
85 public function enqueue() {
86
87 if ( ! wp_script_is( 'drk_lite-leaflet' ) ) {
88 wp_enqueue_script( 'leaflet', DRK_LITE_DIR_URL . 'admin/ta-framework/assets/js/leaflet.js', array( 'ta-framework' ), '1.9.4', true );
89 }
90
91 if ( ! wp_style_is( 'drk_lite-leaflet' ) ) {
92 wp_enqueue_style( 'leaflet', DRK_LITE_DIR_URL . 'admin/ta-framework/assets/css/leaflet.css', array(), '1.9.4' );
93 }
94
95 if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
96 wp_enqueue_script( 'jquery-ui-autocomplete' );
97 }
98 }
99 }
100 }
101