PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Libs/adminify-framework/fields/map/map.php +71 -69 4.1.173.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: map
5 6 *
@@ -4,95 +5,96 @@
4 5 * Field: map
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_map' ) ) {
11 - class ADMINIFY_Field_map extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_map extends ADMINIFY_Fields {
12 12
13 - public $version = '1.9.4';
14 - public $cdn_url = 'https://cdn.jsdelivr.net/npm/leaflet@';
13 + public $version = '1.7.1';
14 + public $cdn_url = 'https://cdn.jsdelivr.net/npm/leaflet@';
15 15
16 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
17 - parent::__construct( $field, $value, $unique, $where, $parent );
18 - }
16 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
17 + parent::__construct( $field, $value, $unique, $where, $parent );
18 + }
19 19
20 - public function render() {
20 + public function render() {
21 + $args = wp_parse_args(
22 + $this->field,
23 + [
24 + 'placeholder' => esc_html__( 'Search...', 'adminify' ),
25 + 'latitude_text' => esc_html__( 'Latitude', 'adminify' ),
26 + 'longitude_text' => esc_html__( 'Longitude', 'adminify' ),
27 + 'address_field' => '',
28 + 'height' => '',
29 + ]
30 + );
21 31
22 - $args = wp_parse_args( $this->field, array(
23 - 'placeholder' => esc_html__( 'Search...', 'adminify' ),
24 - 'latitude_text' => esc_html__( 'Latitude', 'adminify' ),
25 - 'longitude_text' => esc_html__( 'Longitude', 'adminify' ),
26 - 'address_field' => '',
27 - 'height' => '',
28 - ) );
32 + $value = wp_parse_args(
33 + $this->value,
34 + [
35 + 'address' => '',
36 + 'latitude' => '20',
37 + 'longitude' => '0',
38 + 'zoom' => '2',
39 + ]
40 + );
29 41
30 - $value = wp_parse_args( $this->value, array(
31 - 'address' => '',
32 - 'latitude' => '20',
33 - 'longitude' => '0',
34 - 'zoom' => '2',
35 - ) );
42 + $default_settings = [
43 + 'center' => [ $value['latitude'], $value['longitude'] ],
44 + 'zoom' => $value['zoom'],
45 + 'scrollWheelZoom' => false,
46 + ];
36 47
37 - $default_settings = array(
38 - 'center' => array( $value['latitude'], $value['longitude'] ),
39 - 'zoom' => $value['zoom'],
40 - 'scrollWheelZoom' => false,
41 - );
48 + $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : [];
49 + $settings = wp_parse_args( $settings, $default_settings );
42 50
43 - $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array();
44 - $settings = wp_parse_args( $settings, $default_settings );
51 + $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:' . esc_attr( $args['height'] ) . ';"' : '';
52 + $placeholder = ( ! empty( $args['placeholder'] ) ) ? [ 'placeholder' => $args['placeholder'] ] : '';
45 53
46 - $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : '';
47 - $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : '';
54 + echo wp_kses_post( $this->field_before() );
48 55
49 - echo $this->field_before();
56 + if ( empty( $args['address_field'] ) ) {
57 + echo '<div class="adminify--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="adminify--address-field" data-address-field="' . esc_attr( $args['address_field'] ) . '"></div>';
62 + }
50 63
51 - if ( empty( $args['address_field'] ) ) {
52 - echo '<div class="adminify--map-search">';
53 - echo '<input type="text" name="'. esc_attr( $this->field_name( '[address]' ) ) .'" value="'. esc_attr( $value['address'] ) .'"'. $this->field_attributes( $placeholder ) .' />';
54 - echo '</div>';
55 - } else {
56 - echo '<div class="adminify--address-field" data-address-field="'. esc_attr( $args['address_field'] ) .'"></div>';
57 - }
64 + echo '<div class="adminify--map-osm-wrap"><div class="adminify--map-osm" data-map="' . esc_attr( json_encode( $settings ) ) . '"' . esc_attr( $style_attr ) . '></div></div>';
58 65
59 - echo '<div class="adminify--map-osm-wrap"><div class="adminify--map-osm" data-map="'. esc_attr( json_encode( $settings ) ) .'"'. $style_attr .'></div></div>';
66 + echo '<div class="adminify--map-inputs">';
60 67
61 - echo '<div class="adminify--map-inputs">';
68 + echo '<div class="adminify--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="adminify--latitude" />';
71 + echo '</div>';
62 72
63 - echo '<div class="adminify--map-input">';
64 - echo '<label>'. esc_attr( $args['latitude_text'] ) .'</label>';
65 - echo '<input type="text" name="'. esc_attr( $this->field_name( '[latitude]' ) ) .'" value="'. esc_attr( $value['latitude'] ) .'" class="adminify--latitude" />';
66 - echo '</div>';
73 + echo '<div class="adminify--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="adminify--longitude" />';
76 + echo '</div>';
67 77
68 - echo '<div class="adminify--map-input">';
69 - echo '<label>'. esc_attr( $args['longitude_text'] ) .'</label>';
70 - echo '<input type="text" name="'. esc_attr( $this->field_name( '[longitude]' ) ) .'" value="'. esc_attr( $value['longitude'] ) .'" class="adminify--longitude" />';
71 - echo '</div>';
78 + echo '</div>';
72 79
73 - echo '</div>';
80 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[zoom]' ) ) . '" value="' . esc_attr( $value['zoom'] ) . '" class="adminify--zoom" />';
74 81
75 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[zoom]' ) ) .'" value="'. esc_attr( $value['zoom'] ) .'" class="adminify--zoom" />';
82 + echo wp_kses_post( $this->field_after() );
83 + }
76 84
77 - echo $this->field_after();
85 + public function enqueue() {
86 + if ( ! wp_script_is( 'adminify-leaflet' ) ) {
87 + wp_enqueue_script( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version . '/dist/leaflet.js' ), [ 'adminify' ], $this->version, true );
88 + }
78 89
79 - }
90 + if ( ! wp_style_is( 'adminify-leaflet' ) ) {
91 + wp_enqueue_style( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version . '/dist/leaflet.css' ), [], $this->version );
92 + }
80 93
81 - public function enqueue() {
94 + if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
95 + wp_enqueue_script( 'jquery-ui-autocomplete' );
96 + }
97 + }
82 98
83 - if ( ! wp_script_is( 'adminify-leaflet' ) ) {
84 - wp_enqueue_script( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.js' ), array( 'adminify' ), $this->version, true );
85 - }
86 -
87 - if ( ! wp_style_is( 'adminify-leaflet' ) ) {
88 - wp_enqueue_style( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.css' ), array(), $this->version );
89 - }
90 -
91 - if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) {
92 - wp_enqueue_script( 'jquery-ui-autocomplete' );
93 - }
94 -
95 - }
96 -
97 - }
99 + }
98 100 }