Skip to content

Commit

Permalink
#4023 - Google Maps working properly once again.
Browse files Browse the repository at this point in the history
  • Loading branch information
kprovance committed Oct 9, 2024
1 parent fe57f70 commit 1ed6597
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function set_defaults() {
'street_number' => $def_street_number,
'route' => $def_route,
'locality' => $def_locality,
'administrative_area_level_1' => $def_state, // dickheads at Google. lol, srsly...wtf?
'administrative_area_level_1' => $def_state, // <-dickheads at google. lol, srsly...wtf?
// level_1 huh? maybe It's for multiple planets one day.
'postal_code' => $def_postal,
'country' => $def_country,
Expand Down Expand Up @@ -150,6 +150,7 @@ public function render() {

$hidden_style = ' style="display: none!important;" ';
?>

<div
class="redux_framework_google_maps <?php echo esc_attr( $this->field['class'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>"
Expand Down Expand Up @@ -177,23 +178,6 @@ class="google_m_controls google_m_autocomplete <?php echo esc_attr( $is_hidden )
value="<?php echo esc_attr( trim( $full ) ); ?>"
placeholder="<?php echo esc_attr( $this->field['placeholder'] ); ?>"/>

<div
id="<?php echo esc_attr( $this->field['id'] ); ?>_type_selector"
class="google_m_controls <?php echo esc_attr( $is_hidden ); ?>">

<input class="noUpdate" type="radio" name="type" id="changetype-all-<?php echo esc_attr( $this->field['id'] ); ?>" checked="checked"/>
<label for="changetype-all-<?php echo esc_attr( $this->field['id'] ); ?>"><?php esc_html_e( 'All', 'redux-framework' ); ?></label>

<input class="noUpdate" type="radio" name="type" id="changetype-establishment-<?php echo esc_attr( $this->field['id'] ); ?>"/>
<label for="changetype-establishment-<?php echo esc_attr( $this->field['id'] ); ?>"><?php esc_html_e( 'Place', 'redux-framework' ); ?></label>

<input class="noUpdate" type="radio" name="type" id="changetype-address-<?php echo esc_attr( $this->field['id'] ); ?>"/>
<label for="changetype-address-<?php echo esc_attr( $this->field['id'] ); ?>"><?php esc_html_e( 'Address', 'redux-framework' ); ?></label>

<input class="noUpdate" type="radio" name="type" id="changetype-geocode-<?php echo esc_attr( $this->field['id'] ); ?>"/>
<label for="changetype-geocode-<?php echo esc_attr( $this->field['id'] ); ?>"><?php esc_html_e( 'Geo', 'redux-framework' ); ?></label>
</div>

<div
id="<?php echo esc_attr( $this->field['id'] ); ?>_map_canvas"
class="google_m_canvas"
Expand All @@ -208,123 +192,123 @@ class="google_m_canvas"
<div class="input_wrapper street-address" <?php echo $is_hidden; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_street_number"><?php esc_html_e( 'Address', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_street_number"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[street_number]"
value="<?php echo esc_attr( $this->value['street_number'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['street_number'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_street_number"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[street_number]"
value="<?php echo esc_attr( $this->value['street_number'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['street_number'] ); ?>"
type="text"
/>
</div>
<div class="input_wrapper route" <?php echo $is_hidden; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_route"><?php esc_html_e( 'Street', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_route"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[route]"
value="<?php echo esc_attr( $this->value['route'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['route'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_route"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[route]"
value="<?php echo esc_attr( $this->value['route'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['route'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_city ? '' : $hidden_style; ?>
<div class="input_wrapper city" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_locality"><?php esc_html_e( 'City', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_locality"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[locality]"
value="<?php echo esc_attr( $this->value['locality'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['locality'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_locality"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[locality]"
value="<?php echo esc_attr( $this->value['locality'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['locality'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_state ? '' : $hidden_style; ?>
<div class="input_wrapper state" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_administrative_area_level_1"><?php esc_html_e( 'State', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_administrative_area_level_1"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[administrative_area_level_1]"
value="<?php echo esc_attr( $this->value['administrative_area_level_1'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['administrative_area_level_1'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_administrative_area_level_1"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[administrative_area_level_1]"
value="<?php echo esc_attr( $this->value['administrative_area_level_1'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['administrative_area_level_1'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_postal ? '' : $hidden_style; ?>
<div class="input_wrapper zip-code" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_postal_code"><?php esc_html_e( 'ZIP Code', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_postal_code"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[postal_code]"
value="<?php echo esc_attr( $this->value['postal_code'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['postal_code'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_postal_code"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[postal_code]"
value="<?php echo esc_attr( $this->value['postal_code'] ); ?>"
class="slimField field"
data-default-value="<?php echo esc_attr( $this->value['postal_code'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_country ? '' : $hidden_style; ?>
<div class="input_wrapper country" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_country"><?php esc_html_e( 'Country', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_country"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[country]"
value="<?php echo esc_attr( $this->value['country'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['country'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_country"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[country]"
value="<?php echo esc_attr( $this->value['country'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['country'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_lat ? '' : $hidden_style; ?>
<div class="input_wrapper latitude" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_latitude"><?php esc_html_e( 'Latitude', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_latitude"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[latitude]"
value="<?php echo esc_attr( $this->value['latitude'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['latitude'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_latitude"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[latitude]"
value="<?php echo esc_attr( $this->value['latitude'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['latitude'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_long ? '' : $hidden_style; ?>
<div class="input_wrapper longitude" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_longitude"><?php esc_html_e( 'Longitude', 'redux-framework' ); ?></label>
<input
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_longitude"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[longitude]"
value="<?php echo esc_attr( $this->value['longitude'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['longitude'] ); ?>"
type="text"
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_longitude"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[longitude]"
value="<?php echo esc_attr( $this->value['longitude'] ); ?>"
class="wideField field"
data-default-value="<?php echo esc_attr( $this->value['longitude'] ); ?>"
type="text"
/>
</div>

<?php $is_hidden = $show_marker_info ? '' : $hidden_style; ?>
<div class="input_wrapper marker-info" <?php echo( $is_hidden ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<label for="<?php echo esc_attr( $this->field['id'] ); ?>_marker_info"><?php esc_html_e( 'Marker Info', 'redux-framework' ); ?></label>
<textarea
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_marker_info"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[marker_info]"
class="field"
data-default-value="<?php echo esc_attr( $this->value['marker_info'] ); ?>"
rows="3"
type="text"><?php echo esc_textarea( $this->value['marker_info'] ); ?></textarea>
data-id="<?php echo esc_attr( $this->field['id'] ); ?>"
id="<?php echo esc_attr( $this->field['id'] ); ?>_marker_info"
name="<?php echo esc_attr( $this->field['name'] . $this->field['name_suffix'] ); ?>[marker_info]"
class="field"
data-default-value="<?php echo esc_attr( $this->value['marker_info'] ); ?>"
rows="3"
type="text"><?php echo esc_textarea( $this->value['marker_info'] ); ?></textarea>
</div>
</div>
<?php if ( $this->field['show_api_key'] ) { ?>
Expand Down Expand Up @@ -382,8 +366,6 @@ public function enqueue() {
$script = '(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key:"' . $api_key . '",
v:"' . $this->field['map_version'] . '",
libraries:"places,marker",
callback:"initMap"
});';

wp_add_inline_script( 'redux-field-google-maps', $script );
Expand Down
Loading

0 comments on commit 1ed6597

Please sign in to comment.