Skip to content

Commit aeb46f5

Browse files
committed
Debugging
1 parent 2c0fc3c commit aeb46f5

File tree

3 files changed

+41
-14
lines changed

3 files changed

+41
-14
lines changed

inc/Front/Waymark_Shortcode.php

+39-14
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ function handle_shortcode($shortcode_data, $content = null) {
360360

361361
// === Initially Show / Hide ===
362362

363+
$debug_output = '';
364+
363365
foreach (['hide_marker', 'show_marker', 'hide_line', 'show_line', 'hide_shape', 'show_shape'] as $show_hide_type) {
364366
// If option exists
365367
if (array_key_exists($show_hide_type, $shortcode_data)) {
@@ -382,6 +384,11 @@ function handle_shortcode($shortcode_data, $content = null) {
382384
$out .= ' var this_key = waymark_viewer.make_key(waymark_config.map_options.' . $overlay_kind . '_types[i]["' . $overlay_kind . '_title"]);' . "\n";
383385

384386
$out .= ' if("' . $overlay_type . '" == "*" || this_key == "' . $overlay_type . '") {' . "\n";
387+
388+
if (Waymark_Helper::is_debug()) {
389+
$debug_output .= ucwords($overlay_kind) . ' ' . ucwords($show_hide_explode[0]) . ' (' . $overlay_type . ') ';
390+
}
391+
385392
$out .= ' waymark_config.map_options.' . $overlay_kind . '_types[i]["' . $overlay_kind . '_display"] = ' . $overlay_display . ';' . "\n";
386393
$out .= ' }' . "\n";
387394
$out .= ' }' . "\n";
@@ -395,8 +402,14 @@ function handle_shortcode($shortcode_data, $content = null) {
395402

396403
$out .= ' waymark_viewer.init(waymark_config);' . "\n";
397404

398-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Initialised");' . "\n";
399-
$out .= ' waymark_viewer.debug(waymark_config);' . "\n";
405+
if (Waymark_Helper::is_debug()) {
406+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Initialised");' . "\n";
407+
$out .= ' waymark_viewer.debug(waymark_config);' . "\n";
408+
409+
if ($debug_output) {
410+
$out .= ' waymark_viewer.debug("' . $debug_output . '");' . "\n";
411+
}
412+
}
400413

401414
// =====================================
402415
// ================ MAPS ===============
@@ -412,8 +425,10 @@ function handle_shortcode($shortcode_data, $content = null) {
412425
if (isset($map_output['map_data'])) {
413426
$out .= ' waymark_viewer.load_json(' . $map_output['map_data'] . ');' . "\n";
414427

415-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Map Loaded");' . "\n";
416-
$out .= ' waymark_viewer.debug(' . $map_output['map_data'] . ');' . "\n";
428+
if (Waymark_Helper::is_debug()) {
429+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Map Loaded");' . "\n";
430+
$out .= ' waymark_viewer.debug(' . $map_output['map_data'] . ');' . "\n";
431+
}
417432

418433
//Done loading
419434
$out .= ' waymark_viewer.load_done();' . "\n";
@@ -429,8 +444,10 @@ function handle_shortcode($shortcode_data, $content = null) {
429444

430445
$out .= ' waymark_load_map_data(waymark_viewer, ' . $map_id . ', ' . $reset_view . ');' . "\n";
431446

432-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Map Loaded via HTTP (' . $i . '/' . sizeof($maps_output) . ')");' . "\n";
433-
$out .= ' waymark_viewer.debug(' . $map_id . ');' . "\n";
447+
if (Waymark_Helper::is_debug()) {
448+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Map Loaded via HTTP (' . $i . '/' . sizeof($maps_output) . ')");' . "\n";
449+
$out .= ' waymark_viewer.debug(' . $map_id . ');' . "\n";
450+
}
434451

435452
//Done loading
436453
if ($i == sizeof($maps_output)) {
@@ -518,8 +535,10 @@ function handle_shortcode($shortcode_data, $content = null) {
518535
$out .= ' let marker_geojson = ' . json_encode($marker_geojson) . ';' . "\n";
519536
$out .= ' waymark_viewer.load_json(marker_geojson);' . "\n";
520537

521-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Marker Loaded");' . "\n";
522-
$out .= ' waymark_viewer.debug(marker_geojson);' . "\n";
538+
if (Waymark_Helper::is_debug()) {
539+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' Marker Loaded");' . "\n";
540+
$out .= ' waymark_viewer.debug(marker_geojson);' . "\n";
541+
}
523542
}
524543
}
525544

@@ -681,8 +700,10 @@ function handle_shortcode($shortcode_data, $content = null) {
681700
// Add Markers
682701
$out .= ' waymark_viewer.load_json(fileAddFeatures);' . "\n";
683702

684-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' File ' . ucwords($overlay_type) . 's Loaded");' . "\n";
685-
$out .= ' waymark_viewer.debug(fileAddFeatures);' . "\n";
703+
if (Waymark_Helper::is_debug()) {
704+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' File ' . ucwords($overlay_type) . 's Loaded");' . "\n";
705+
$out .= ' waymark_viewer.debug(fileAddFeatures);' . "\n";
706+
}
686707
}
687708

688709
break;
@@ -692,9 +713,10 @@ function handle_shortcode($shortcode_data, $content = null) {
692713

693714
$out .= ' waymark_viewer.load_json(file_geo_json);' . "\n";
694715

695-
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' File Loaded");' . "\n";
696-
$out .= ' waymark_viewer.debug(file_geo_json);' . "\n";
697-
716+
if (Waymark_Helper::is_debug()) {
717+
$out .= ' waymark_viewer.debug("Shortcode #' . $shortcode_hash . ' File Loaded");' . "\n";
718+
$out .= ' waymark_viewer.debug(file_geo_json);' . "\n";
719+
}
698720
}
699721
}
700722
}
@@ -706,7 +728,10 @@ function handle_shortcode($shortcode_data, $content = null) {
706728

707729
if (array_key_exists('loaded_callback', $shortcode_data)) {
708730
$out .= ' if(typeof ' . $shortcode_data['loaded_callback'] . ' === "function") {' . "\n";
709-
$out .= ' waymark_viewer.debug("Shortcode Callback detected ' . $shortcode_data['loaded_callback'] . '(waymark_instance)");' . "\n";
731+
if (Waymark_Helper::is_debug()) {
732+
$out .= ' waymark_viewer.debug("Shortcode Callback detected ' . $shortcode_data['loaded_callback'] . '(waymark_instance)");' . "\n";
733+
}
734+
710735
$out .= ' ' . $shortcode_data['loaded_callback'] . '(waymark_viewer);' . "\n";
711736
$out .= ' } else {' . "\n";
712737
$out .= ' waymark_viewer.message("Callback function not found!", "error");' . "\n";

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Built on the shoulders of giants, [thank you](https://www.waymark.dev/docs/thank
192192
### 1.4.0 ###
193193

194194
- Added the ability to show/hide all Types initially when using the Shortcode by specifying "*" as the Type key. For example, to initially hide all Marker Types, except "photo" and "alert", use `[Waymark map_id="1234" hide_marker="*" show_marker="photo,alert"]`. Thanks to [Association Franc-Comtoise du Chemin de Compostelle](https://www.af-ccc.fr) for requesting this.
195+
- Improved debugging output.
195196

196197
### 1.3.2 ###
197198

readme.txt

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Built on the shoulders of giants, [thank you](https://www.waymark.dev/docs/thank
174174
= 1.4.0 =
175175

176176
- Added the ability to show/hide all Types initially when using the Shortcode by specifying "*" as the Type key. For example, to initially hide all Marker Types, except "photo" and "alert", use `[Waymark map_id="1234" hide_marker="*" show_marker="photo,alert"]`. Thanks to [Association Franc-Comtoise du Chemin de Compostelle](https://www.af-ccc.fr) for requesting this.
177+
- Improved debugging output.
177178

178179
= 1.3.2 =
179180

0 commit comments

Comments
 (0)