cdn_url = defined( 'PXLBSADMINIFY_ASSETS' ) ? PXLBSADMINIFY_ASSETS . 'vendors/leaflet' : ''; } public function render() { $args = wp_parse_args( $this->field, array( 'placeholder' => esc_html__( 'Search...', 'adminify' ), 'latitude_text' => esc_html__( 'Latitude', 'adminify' ), 'longitude_text' => esc_html__( 'Longitude', 'adminify' ), 'address_field' => '', 'height' => '', ) ); $value = wp_parse_args( $this->value, array( 'address' => '', 'latitude' => '20', 'longitude' => '0', 'zoom' => '2', ) ); $default_settings = array( 'center' => array( $value['latitude'], $value['longitude'] ), 'zoom' => $value['zoom'], 'scrollWheelZoom' => false, ); $settings = ( ! empty( $this->field['settings'] ) ) ? $this->field['settings'] : array(); $settings = wp_parse_args( $settings, $default_settings ); $style_attr = ( ! empty( $args['height'] ) ) ? ' style="min-height:'. esc_attr( $args['height'] ) .';"' : ''; $placeholder = ( ! empty( $args['placeholder'] ) ) ? array( 'placeholder' => $args['placeholder'] ) : ''; echo wp_kses_post( $this->field_before() ); if ( empty( $args['address_field'] ) ) { echo ''; } else { echo '
'; } echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built. echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo wp_kses_post( $this->field_after() ); } public function enqueue() { if ( empty( $this->cdn_url ) ) { return; } if ( ! wp_script_is( 'adminify-leaflet' ) ) { wp_enqueue_script( 'adminify-leaflet', esc_url( $this->cdn_url .'/leaflet.js' ), array( 'adminify' ), $this->version, true ); } if ( ! wp_style_is( 'adminify-leaflet' ) ) { wp_enqueue_style( 'adminify-leaflet', esc_url( $this->cdn_url .'/leaflet.css' ), array(), $this->version ); } if ( ! wp_script_is( 'jquery-ui-autocomplete' ) ) { wp_enqueue_script( 'jquery-ui-autocomplete' ); } } } }