Skip to content

Commit 6b9a298

Browse files
authored
Merge pull request #659 from lightspeedwp/bug/657-hide-location-field-no-api-key
fix: Hide location field when no Google Maps API key is present
2 parents e0781ef + 1d86086 commit 6b9a298

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

changelog.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
## [[2.1.0]](https://github.com/lightspeedwp/tour-operator/releases/tag/2.1.0) - In Dev
44

5-
### Changed
6-
7-
85
### Added
96
- A filter to allow the disabling of destinations when searching for related content. `lsx_to_' . $key . '_include_destinations`. - [BH-74](https://www.bugherd.com/projects/430995/tasks/74)
107
- Integrate new icons block - PR [#547](https://github.com/lightspeedwp/tour-operator/pull/547), Issue [#548](https://github.com/lightspeedwp/tour-operator/issues/548)
@@ -57,6 +54,7 @@
5754
- Add "currentColor" to all icon colour styling [#575](https://github.com/lightspeedwp/tour-operator/pull/575)
5855
- Query Block Pagination not Inherting the correct query vars. [#608](https://github.com/lightspeedwp/tour-operator/pull/608)
5956
- Fixed – Excluded build/ directory from CodeRabbit reviews by updating .coderabbit.yaml. [#620](https://github.com/lightspeedwp/tour-operator/pull/620)
57+
- Hide "location" custom field and exclude relevant JS when Google Maps API key is missing. Only the map field is shown. ([#657](https://github.com/lightspeedwp/tour-operator/issues/657))
6058

6159
### Security
6260
-

includes/metaboxes/config-accommodation.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@
6161
if (isset(tour_operator()->options['googlemaps_key']) && ! empty(tour_operator()->options['googlemaps_key'])) {
6262
$google_api_key = tour_operator()->options['googlemaps_key'];
6363
}
64-
$metabox['fields'][] = array(
65-
'id' => 'location',
66-
'name' => esc_html__('Address', 'tour-operator'),
67-
'desc' => esc_html__('The address of the accommodation for map display.', 'tour-operator'),
68-
'type' => 'pw_map',
69-
'api_key' => $google_api_key,
70-
);
64+
if ( ! empty( $google_api_key ) ) {
65+
$metabox['fields'][] = array(
66+
'id' => 'location',
67+
'name' => esc_html__('Address', 'tour-operator'),
68+
'desc' => esc_html__('The address of the accommodation for map display.', 'tour-operator'),
69+
'type' => 'pw_map',
70+
'api_key' => $google_api_key,
71+
);
72+
}
73+
7174
$metabox['fields'][] = array(
7275
'id' => 'map_placeholder',
7376
'name' => esc_html__('Map Placeholder', 'tour-operator'),
74-
'desc' => esc_html__('A placeholder image for the map if no address or GPS data is available.', 'tour-operator'),
77+
'desc' => esc_html__('A placeholder image for the map, allowing lazy loading.', 'tour-operator'),
7578
'type' => 'file',
7679
'repeatable' => false,
7780
'show_size' => false,

includes/metaboxes/config-destination.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,14 @@
171171
if (isset(tour_operator()->options['googlemaps_key']) && ! empty(tour_operator()->options['googlemaps_key'])) {
172172
$google_api_key = tour_operator()->options['googlemaps_key'];
173173
}
174-
$metabox['fields'][] = array(
175-
'id' => 'location',
176-
'name' => esc_html__('Address', 'tour-operator'),
177-
'type' => 'pw_map',
178-
'api_key' => $google_api_key,
179-
);
174+
if ( ! empty($google_api_key) ) {
175+
$metabox['fields'][] = array(
176+
'id' => 'location',
177+
'name' => esc_html__('Address', 'tour-operator'),
178+
'type' => 'pw_map',
179+
'api_key' => $google_api_key,
180+
);
181+
}
180182
$metabox['fields'][] = array(
181183
'id' => 'map_placeholder',
182184
'name' => esc_html__('Map Placeholder', 'tour-operator'),

0 commit comments

Comments
 (0)