Skip to content

Commit

Permalink
Merge pull request #10 from whitkirkchurch/exclude-categories
Browse files Browse the repository at this point in the history
Add exclude_categories parameter
  • Loading branch information
jacksonj04 authored Aug 20, 2022
2 parents 45d7d11 + 27f2426 commit d5aa3d6
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion include-churchsuite-events.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
Plugin Name: Include ChurchSuite Events
Plugin URI: https://github.com/whitkirkchurch/include-churchsuite-events
Description: Gets a list of events from a ChurchSuite account, and includes it as part of a post or page.
Version: 1.2.2
Version: 1.3.0
Author: St Mary's Church, Whitkirk
Author URI: https://whitkirkchurch.org.uk
License: GPL-2.0+
@@ -80,6 +80,13 @@ function cs_events_shortcode($atts = [])
$limit_to_count = true;
}

if (isset($atts['exclude_categories'])) {
$exclude_categories = explode(',', $atts['exclude_categories']);
unset($atts['exclude_categories']);
} else {
$exclude_categories = [];
}

try {
$params = [];

@@ -105,6 +112,12 @@ function cs_events_shortcode($atts = [])

// This is where most of the magic happens
foreach ($data_to_loop as $event) {

// If the event's category is in the exclude list, just skip the loop for it
if (in_array($event->category->id, $exclude_categories)) {
continue;
}

// Build the event URL, we use this a couple of times
$event_url =
'https://' .
9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@
Contributors: jacksonj04
Tags: churchsuite, events
Requires at least: 4.7
Tested up to: 5.4.1
Stable tag: v1.2.2
Tested up to: 6.0.1
Stable tag: v1.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://whitkirkchurch.org.uk/donate
@@ -43,6 +43,7 @@ There are some additional parameters you can pass:
* `show_end_times`: Display the time an event is scheduled to end. Defaults to false.
* `show_locations`: Display details of an event's location. Defaults to false.
* `show_descriptions`: Display and event's description if given. Defaults to true.
* `exclude_categories`: A comma-delimited list of category IDs to exclude from the output. Defaults to an empty array.

== Changelog ==

@@ -74,3 +75,7 @@ There are some additional parameters you can pass:
= 1.2.2 =

* Updated "missing site parameter" error message, to "missing account parameter"

= 1.3.0 =

* Added `exclude_categories` parameter.

0 comments on commit d5aa3d6

Please sign in to comment.