Skip to content

Commit 9faa62c

Browse files
author
Joe Hawes
committed
2
1 parent 9e887df commit 9faa62c

File tree

9 files changed

+110
-65
lines changed

9 files changed

+110
-65
lines changed

assets/dist/waymark-js/js/waymark-js.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7469,8 +7469,6 @@ function Waymark_Map() {
74697469
show_gallery: 0,
74707470
show_filter: 0,
74717471
show_elevation: 0,
7472-
// TODO!
7473-
// Add setting
74747472
show_cluster: 1,
74757473
elevation_div_id: "waymark-elevation",
74767474
elevation_units: "metric",
@@ -8836,6 +8834,15 @@ function Waymark_Map_Viewer() {
88368834
if (!Waymark.config.show_cluster) {
88378835
return;
88388836
}
8837+
// Use Cluster Setting
8838+
console.log(
8839+
Waymark.get_property(
8840+
waymark_settings,
8841+
"misc",
8842+
"cluster_options",
8843+
"show_cluster",
8844+
),
8845+
);
88398846

88408847
console.debug("setupCluster");
88418848

assets/dist/waymark-js/js/waymark-js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/Front/Waymark_Content.php

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,66 @@
11
<?php
22

33
class Waymark_Content {
4-
function __construct() {
5-
add_filter('the_content', array($this, 'the_content'));
6-
add_filter('the_excerpt', array($this, 'the_content'));
7-
}
8-
9-
function the_content($content) {
10-
global $post;
11-
12-
//Don't do anything if password required
13-
if (post_password_required()) {
14-
return $content;
15-
}
16-
17-
//Ensure we have a post object and post type
18-
if (is_null($post) || !isset($post->post_type)) {
19-
return $content;
20-
}
21-
22-
//Only modify Map page
23-
if ($post->post_type != 'waymark_map') {
24-
return $content;
25-
}
26-
27-
//Map
28-
$Map = new Waymark_Map($post->ID);
29-
$shortcode = '[' . Waymark_Config::get_item('shortcode');
30-
$shortcode .= ' map_id="' . $post->ID . '"';
31-
32-
//Shortcode Header?
33-
if (Waymark_Config::get_setting('misc', 'shortcode_options', 'shortcode_header') == '1') {
34-
$shortcode .= ' shortcode_header="1"';
35-
}
36-
37-
//Elevation?
38-
if (Waymark_Config::get_setting('misc', 'elevation_options', 'show_elevation') == '2') {
39-
$shortcode .= ' show_elevation="1"';
40-
}
41-
42-
$shortcode .= ']';
43-
$content = do_shortcode($shortcode);
44-
45-
//Single Map page only
46-
if (is_single()) {
47-
//START Meta
48-
$map_meta = Waymark_Helper::get_map_meta($Map);
49-
50-
//Do we have something to display?
51-
if (sizeof($map_meta)) {
52-
$content .= Waymark_Helper::map_meta_html($map_meta, false);
53-
}
54-
//END Meta
55-
}
56-
57-
return $content;
58-
}
4+
function __construct() {
5+
add_filter('the_content', array($this, 'the_content'));
6+
add_filter('the_excerpt', array($this, 'the_content'));
7+
}
8+
9+
function the_content($content) {
10+
global $post;
11+
12+
//Don't do anything if password required
13+
if (post_password_required()) {
14+
return $content;
15+
}
16+
17+
//Ensure we have a post object and post type
18+
if (is_null($post) || !isset($post->post_type)) {
19+
return $content;
20+
}
21+
22+
//Only modify Map page
23+
if ($post->post_type != 'waymark_map') {
24+
return $content;
25+
}
26+
27+
//Map
28+
$Map = new Waymark_Map($post->ID);
29+
$shortcode = '[' . Waymark_Config::get_item('shortcode');
30+
$shortcode .= ' map_id="' . $post->ID . '"';
31+
32+
//Shortcode Header?
33+
if (Waymark_Config::get_setting('misc', 'shortcode_options', 'shortcode_header') == '1') {
34+
$shortcode .= ' shortcode_header="1"';
35+
}
36+
37+
//Elevation?
38+
if (Waymark_Config::get_setting('misc', 'elevation_options', 'show_elevation') == '2') {
39+
$shortcode .= ' show_elevation="1"';
40+
}
41+
42+
// Cluster
43+
if (Waymark_Config::get_setting('misc', 'cluster_options', 'show_cluster') == '1') {
44+
$shortcode .= ' show_cluster="1"';
45+
}
46+
47+
$shortcode .= ']';
48+
$content = do_shortcode($shortcode);
49+
50+
//Single Map page only
51+
if (is_single()) {
52+
//START Meta
53+
$map_meta = Waymark_Helper::get_map_meta($Map);
54+
55+
//Do we have something to display?
56+
if (sizeof($map_meta)) {
57+
$content .= Waymark_Helper::map_meta_html($map_meta, false);
58+
}
59+
//END Meta
60+
}
61+
62+
return $content;
63+
}
5964
}
6065

6166
new Waymark_Content;

inc/Front/Waymark_Shortcode.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ function handle_shortcode($shortcode_data, $content = null) {
220220
$out .= ' <div id="waymark-elevation-' . $shortcode_hash . '" class="waymark-elevation"></div>' . "\n";
221221
}
222222

223+
// Cluster
224+
if (array_key_exists('show_cluster', $shortcode_data)) {
225+
$show_cluster = $shortcode_data['show_cluster'];
226+
} else {
227+
$show_cluster = Waymark_Config::get_setting('misc', 'cluster_options', 'show_cluster') == '1';
228+
}
229+
223230
//Close container
224231
$out .= '</div>' . "\n";
225232

@@ -324,6 +331,11 @@ function handle_shortcode($shortcode_data, $content = null) {
324331
$out .= 'waymark_config.elevation_units = "' . $elevation_units . '";' . "\n";
325332
}
326333

334+
// Clustering?
335+
if ($show_cluster) {
336+
$out .= 'waymark_config.show_cluster = 1;' . "\n";
337+
}
338+
327339
//Initially Show / Hide Types
328340
foreach (['hide_marker', 'show_marker', 'hide_line', 'show_line', 'hide_shape', 'show_shape'] as $show_hide_type) {
329341
if (array_key_exists($show_hide_type, $shortcode_data)) {

inc/Waymark_Config.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static function init() {
101101
'wake_message' => esc_attr__('Click or Hover to Wake', 'waymark'),
102102
),
103103
'cluster_options' => array(
104-
'display_cluster' => '0',
104+
'show_cluster' => '0',
105105
'cluster_min' => '1',
106106
'cluster_max' => '14',
107107
),
@@ -408,13 +408,20 @@ public static function get_settings_js() {
408408
$settings_js['overlay']['properties'] = [];
409409
}
410410

411-
//Interaction Options
411+
// Sleep Options
412412
if (isset($settings['misc']['interaction_options']['delay_seconds'])) {
413413
$settings_js['misc']['interaction_options']['delay_seconds'] = $settings['misc']['interaction_options']['delay_seconds'];
414414
} else {
415415
$settings_js['misc']['interaction_options']['delay_seconds'] = 2;
416416
}
417417

418+
// Cluster Options
419+
if (isset($settings['misc']['cluster_options']['show_cluster'])) {
420+
$settings_js['misc']['cluster_options']['show_cluster'] = $settings['misc']['cluster_options']['show_cluster'];
421+
} else {
422+
$settings_js['misc']['cluster_options']['show_cluster'] = 0;
423+
}
424+
418425
if (isset($settings['misc']['interaction_options']['do_message'])) {
419426
$settings_js['misc']['interaction_options']['do_message'] = $settings['misc']['interaction_options']['do_message'];
420427
} else {

waymark-js/dist/js/waymark-js.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7469,8 +7469,6 @@ function Waymark_Map() {
74697469
show_gallery: 0,
74707470
show_filter: 0,
74717471
show_elevation: 0,
7472-
// TODO!
7473-
// Add setting
74747472
show_cluster: 1,
74757473
elevation_div_id: "waymark-elevation",
74767474
elevation_units: "metric",
@@ -8836,6 +8834,15 @@ function Waymark_Map_Viewer() {
88368834
if (!Waymark.config.show_cluster) {
88378835
return;
88388836
}
8837+
// Use Cluster Setting
8838+
console.log(
8839+
Waymark.get_property(
8840+
waymark_settings,
8841+
"misc",
8842+
"cluster_options",
8843+
"show_cluster",
8844+
),
8845+
);
88398846

88408847
console.debug("setupCluster");
88418848

waymark-js/dist/js/waymark-js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

waymark-js/src/js/Waymark_Map.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ function Waymark_Map() {
9696
show_gallery: 0,
9797
show_filter: 0,
9898
show_elevation: 0,
99-
// TODO!
100-
// Add setting
10199
show_cluster: 1,
102100
elevation_div_id: "waymark-elevation",
103101
elevation_units: "metric",

waymark-js/src/js/Waymark_Map_Viewer.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ function Waymark_Map_Viewer() {
4040
if (!Waymark.config.show_cluster) {
4141
return;
4242
}
43+
// Use Cluster Setting
44+
console.log(
45+
Waymark.get_property(
46+
waymark_settings,
47+
"misc",
48+
"cluster_options",
49+
"show_cluster",
50+
),
51+
);
4352

4453
console.debug("setupCluster");
4554

0 commit comments

Comments
 (0)