| @@ -10,14 +10,12 @@ | ||
| 10 | 10 | if ( ! class_exists( 'ADMINIFY_Field_map' ) ) { |
| 11 | 11 | class ADMINIFY_Field_map extends ADMINIFY_Fields { |
| 12 | 12 | |
| 13 | 13 | public $version = '1.9.4'; |
| 14 | - public $cdn_url = ''; | |
| 14 | + public $cdn_url = 'https://cdn.jsdelivr.net/npm/leaflet@'; | |
| 15 | 15 | |
| 16 | 16 | public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 17 | 17 | parent::__construct( $field, $value, $unique, $where, $parent ); |
| 18 | - // Leaflet is bundled locally inside the plugin (no remote CDN). | |
| 19 | - $this->cdn_url = defined( 'PXLBSADMINIFY_ASSETS' ) ? PXLBSADMINIFY_ASSETS . 'vendors/leaflet' : ''; | |
| 20 | 18 | } |
| 21 | 19 | |
| 22 | 20 | public function render() { |
| 23 | 21 | |
| @@ -47,19 +45,19 @@ | ||
| 47 | 45 | |
| 48 | 46 | $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : ''; |
| 49 | 47 | $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : ''; |
| 50 | 48 | |
| 51 | - echo wp_kses_post( $this->field_before() ); | |
| 49 | + echo $this->field_before(); | |
| 52 | 50 | |
| 53 | 51 | if ( empty( $args['address_field'] ) ) { |
| 54 | 52 | echo '<div class="adminify--map-search">'; |
| 55 | - echo '<input type="text" name="'. esc_attr( $this->field_name( '[address]' ) ) .'" value="'. esc_attr( $value['address'] ) .'"'. $this->field_attributes( $placeholder ) .' />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- field_attributes() escapes each attribute via esc_attr() | |
| 53 | + echo '<input type="text" name="'. esc_attr( $this->field_name( '[address]' ) ) .'" value="'. esc_attr( $value['address'] ) .'"'. $this->field_attributes( $placeholder ) .' />'; | |
| 56 | 54 | echo '</div>'; |
| 57 | 55 | } else { |
| 58 | 56 | echo '<div class="adminify--address-field" data-address-field="'. esc_attr( $args['address_field'] ) .'"></div>'; |
| 59 | 57 | } |
| 60 | 58 | |
| 61 | - echo '<div class="adminify--map-osm-wrap"><div class="adminify--map-osm" data-map="'. esc_attr( wp_json_encode( $settings ) ) .'"'. $style_attr .'></div></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built. | |
| 59 | + echo '<div class="adminify--map-osm-wrap"><div class="adminify--map-osm" data-map="'. esc_attr( json_encode( $settings ) ) .'"'. $style_attr .'></div></div>'; | |
| 62 | 60 | |
| 63 | 61 | echo '<div class="adminify--map-inputs">'; |
| 64 | 62 | |
| 65 | 63 | echo '<div class="adminify--map-input">'; |
| @@ -75,22 +73,20 @@ | ||
| 75 | 73 | echo '</div>'; |
| 76 | 74 | |
| 77 | 75 | echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[zoom]' ) ) .'" value="'. esc_attr( $value['zoom'] ) .'" class="adminify--zoom" />'; |
| 78 | 76 | |
| 79 | - echo wp_kses_post( $this->field_after() ); | |
| 77 | + echo $this->field_after(); | |
| 80 | 78 | |
| 81 | 79 | } |
| 82 | 80 | |
| 83 | 81 | public function enqueue() { |
| 84 | 82 | |
| 85 | - if ( empty( $this->cdn_url ) ) { return; } | |
| 86 | - | |
| 87 | 83 | if ( ! wp_script_is( 'adminify-leaflet' ) ) { |
| 88 | - wp_enqueue_script( 'adminify-leaflet', esc_url( $this->cdn_url .'/leaflet.js' ), array( 'adminify' ), $this->version, true ); | |
| 84 | + wp_enqueue_script( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.js' ), array( 'adminify' ), $this->version, true ); | |
| 89 | 85 | } |
| 90 | 86 | |
| 91 | 87 | if ( ! wp_style_is( 'adminify-leaflet' ) ) { |
| 92 | - wp_enqueue_style( 'adminify-leaflet', esc_url( $this->cdn_url .'/leaflet.css' ), array(), $this->version ); | |
| 88 | + wp_enqueue_style( 'adminify-leaflet', esc_url( $this->cdn_url . $this->version .'/dist/leaflet.css' ), array(), $this->version ); | |
| 93 | 89 | } |
| 94 | 90 | |
| 95 | 91 | if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) { |
| 96 | 92 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |