Skip to content

Commit c983ea2

Browse files
authored
v0.9.20 - Submission Collections
Front-end <a href="https://www.waymark.dev/docs/submissions/">Submissions</a> can now be added to a <a href="https://www.waymark.dev/docs/collections/">Collection</a> by default. A collection for User and Guest submissions can be specified in Settings > Submissions > Default Collection.
2 parents 37d20f9 + 2fde390 commit c983ea2

File tree

8 files changed

+84
-26
lines changed

8 files changed

+84
-26
lines changed

Waymark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Waymark
55
Plugin URI: https://www.waymark.dev/
66
Description: Mapping with WordPress made easy. With Waymark enabled, click on the "Maps" link in the sidebar to create and edit Maps. Once you are happy with your Map, copy the Waymark shortcode and add it to your content.
7-
Version: 0.9.19
7+
Version: 0.9.20
88
Text Domain: waymark
99
Author: Joe Hawes
1010
Author URI: https://www.morehawes.co.uk/

inc/Admin/Waymark_Settings.php

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,18 @@ function __construct() {
514514

515515
// ==================== Submission ====================
516516

517+
//Build list of Collections to use as <select> options
518+
$collection_objects = get_terms([
519+
'taxonomy' => 'waymark_collection',
520+
'hide_empty' => false
521+
]);
522+
$collection_array = [
523+
'' => ' - '
524+
];
525+
foreach($collection_objects as $collection) {
526+
$collection_array[$collection->term_id] = $collection->name;
527+
}
528+
517529
//Roles
518530
if(! function_exists('get_editable_roles')) {
519531
require_once ABSPATH . 'wp-admin/includes/user.php';
@@ -586,23 +598,31 @@ function __construct() {
586598
'name' => 'submission_status',
587599
'id' => 'submission_users_status',
588600
'type' => 'select',
589-
'title' => esc_html__('Post Status', 'waymark'),
601+
'title' => esc_html__('Default Status', 'waymark'),
590602
'default' => Waymark_Config::get_setting('submission', 'from_users', 'submission_status'),
591603
'tip' => esc_attr__('This is the initial status of the submitted Map. Note! Publish means that the Map (including any images added) will be *immediately* visible on your site.', 'waymark'),
592604
'options' => array(
593605
'publish' => esc_attr__('Publish', 'waymark'),
594606
'draft' => esc_attr__('Draft', 'waymark')
595607
)
596608
),
597-
'submission_alert' => array(
598-
'name' => 'submission_alert',
599-
'id' => 'submission_users_alert',
600-
'type' => 'boolean',
601-
'title' => esc_html__('Email Alert', 'waymark'),
602-
'default' => Waymark_Config::get_setting('submission', 'from_users', 'submission_alert'),
603-
'tip' => esc_attr__('Receive email alerts for new submissions.', 'waymark'),
604-
'class' => 'waymark-hidden'
605-
),
609+
'submission_collection' => array(
610+
'name' => 'submission_collection',
611+
'id' => 'submission_users_collection',
612+
'type' => 'select',
613+
'title' => esc_html__('Default Collection', 'waymark'),
614+
'tip' => esc_attr__('If specified, user submissions will be automatically added to this Collection.', 'waymark'),
615+
'options' => $collection_array
616+
),
617+
// 'submission_alert' => array(
618+
// 'name' => 'submission_alert',
619+
// 'id' => 'submission_users_alert',
620+
// 'type' => 'boolean',
621+
// 'title' => esc_html__('Email Alert', 'waymark'),
622+
// 'default' => Waymark_Config::get_setting('submission', 'from_users', 'submission_alert'),
623+
// 'tip' => esc_attr__('Receive email alerts for new submissions.', 'waymark'),
624+
// 'class' => 'waymark-hidden'
625+
// )
606626
)
607627
),
608628

@@ -652,7 +672,7 @@ function __construct() {
652672
'name' => 'submission_status',
653673
'id' => 'submission_public_status',
654674
'type' => 'select',
655-
'title' => esc_html__('Post Status', 'waymark'),
675+
'title' => esc_html__('Default Status', 'waymark'),
656676
'default' => Waymark_Config::get_setting('submission', 'from_public', 'submission_status'),
657677
'tip' => esc_attr__('This is the initial status of the submitted Map. Note! Publish means that the Map (including any images added) will be *immediately* visible on your site.', 'waymark'),
658678
'options' => array(
@@ -661,15 +681,23 @@ function __construct() {
661681
),
662682
'class' => ''
663683
),
664-
'submission_alert' => array(
665-
'name' => 'submission_alert',
666-
'id' => 'submission_public_alert',
667-
'type' => 'boolean',
668-
'title' => esc_html__('Email Alert', 'waymark'),
669-
'default' => Waymark_Config::get_setting('submission', 'from_public', 'submission_alert'),
670-
'tip' => esc_attr__('Receive email alerts for new submissions.', 'waymark'),
671-
'class' => 'waymark-hidden'
672-
),
684+
'submission_collection' => array(
685+
'name' => 'submission_collection',
686+
'id' => 'submission_public_collection',
687+
'type' => 'select',
688+
'title' => esc_html__('Default Collection', 'waymark'),
689+
'tip' => esc_attr__('If specified, user submissions will be automatically added to this Collection.', 'waymark'),
690+
'options' => $collection_array
691+
),
692+
// 'submission_alert' => array(
693+
// 'name' => 'submission_alert',
694+
// 'id' => 'submission_public_alert',
695+
// 'type' => 'boolean',
696+
// 'title' => esc_html__('Email Alert', 'waymark'),
697+
// 'default' => Waymark_Config::get_setting('submission', 'from_public', 'submission_alert'),
698+
// 'tip' => esc_attr__('Receive email alerts for new submissions.', 'waymark'),
699+
// 'class' => 'waymark-hidden'
700+
// ),
673701
)
674702
)
675703
)

inc/Front/Waymark_Submission.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Waymark_Submission {
99
private $Map;
1010

1111
private $user;
12+
private $user_type; // admin / user / guest
1213
private $status;
1314
private $alert;
1415
private $features = [];
@@ -32,6 +33,7 @@ public function __construct($data = array()) {
3233
if(sizeof($this->user->roles)) {
3334
//Admin
3435
if(in_array('administrator', $this->user->roles)) {
36+
$this->user_type = 'admin';
3537
$this->allowed = true;
3638

3739
$this->status = 'publish';
@@ -40,6 +42,7 @@ public function __construct($data = array()) {
4042
$this->features = $this->all_features;
4143
//Current user can
4244
} elseif($this->user_can_submit()) {
45+
$this->user_type = 'user';
4346
$this->allowed = true;
4447

4548
$this->status = Waymark_Config::get_setting('submission', 'from_users', 'submission_status');
@@ -48,6 +51,7 @@ public function __construct($data = array()) {
4851
$this->features = Waymark_Config::get_setting('submission', 'from_users', 'submission_features');
4952
//Treat as public?
5053
} elseif(Waymark_Config::get_setting('submission', 'from_public', 'submission_public')) {
54+
$this->user_type = 'guest';
5155
$this->allowed = true;
5256

5357
$this->status = Waymark_Config::get_setting('submission', 'from_public', 'submission_status');
@@ -62,6 +66,7 @@ public function __construct($data = array()) {
6266
} else {
6367
//Public submissions allowed
6468
if(Waymark_Config::get_setting('submission', 'from_public', 'submission_public')) {
69+
$this->user_type = 'guest';
6570
$this->allowed = true;
6671

6772
$this->status = Waymark_Config::get_setting('submission', 'from_public', 'submission_status');
@@ -321,6 +326,23 @@ public function create_map() {
321326
'post_status' => $this->status
322327
));
323328

329+
//Add to collection?
330+
$submission_collection = false;
331+
switch($this->user_type) {
332+
case 'guest' :
333+
$submission_collection = Waymark_Config::get_setting('submission', 'from_public', 'submission_collection');
334+
335+
break;
336+
default :
337+
$submission_collection = Waymark_Config::get_setting('submission', 'from_users', 'submission_collection');
338+
339+
break;
340+
}
341+
if($submission_collection) {
342+
//Link Map to Collection
343+
wp_set_object_terms($this->Map->post_id, (int) $submission_collection, 'waymark_collection');
344+
}
345+
324346
$this->redirect_data['waymark_map_id'] = $this->Map->post_id;
325347

326348
return $this->Map->post_id;

inc/Waymark_Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static function init() {
1111
'plugin_name' => 'Waymark',
1212
'plugin_name_short' => 'Waymark',
1313
'custom_types' => array(),
14-
'plugin_version' => '0.9.19',
14+
'plugin_version' => '0.9.20',
1515
'nonce_string' => 'Waymark_Nonce',
1616
'site_url' => 'https://www.waymark.dev/',
1717
'directory_url' => 'https://wordpress.org/support/plugin/waymark/',

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Waymark",
3-
"version": "0.9.19",
3+
"version": "0.9.20",
44
"description": "Waymark for WordPress",
55
"author": "Joe Hawes",
66
"main": "Gruntfile.js",

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Requires at least:** 4.6
55
**Tested up to:** 6.0
66
**Requires PHP:** 5.2
7-
**Stable tag:** 0.9.19
7+
**Stable tag:** 0.9.20
88
**License:** GPLv2 or later
99
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -111,6 +111,10 @@ A big thank you to the following projects and their contributors. Without their
111111

112112
## Changelog ##
113113

114+
### 0.9.20 ###
115+
116+
* Front-end <a href="https://www.waymark.dev/docs/submissions/">Submissions</a> can now be added to a <a href="https://www.waymark.dev/docs/collections/">Collection</a> by default. A collection for User and Guest submissions can be specified in Settings > Submissions > Default Collection.
117+
114118
### 0.9.19 ###
115119

116120
* **<a href="https://www.waymark.dev/docs/shortcodes/#shortcode-files">Shortcode Files</a>**

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: Create interactive Maps, Add custom Markers, Display geotagged photos, ele
44
Requires at least: 4.6
55
Tested up to: 6.0
66
Requires PHP: 5.2
7-
Stable tag: 0.9.19
7+
Stable tag: 0.9.20
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -97,6 +97,10 @@ A big thank you to the following projects and their contributors. Without their
9797

9898
== Changelog ==
9999

100+
= 0.9.20 =
101+
102+
* Front-end <a href="https://www.waymark.dev/docs/submissions/">Submissions</a> can now be added to a <a href="https://www.waymark.dev/docs/collections/">Collection</a> by default. A collection for User and Guest submissions can be specified in Settings > Submissions > Default Collection.
103+
100104
= 0.9.19 =
101105

102106
* **<a href="https://www.waymark.dev/docs/shortcodes/#shortcode-files">Shortcode Files</a>**

0 commit comments

Comments
 (0)