From e7ca1d3e92d0400d2dc824637c7422bac1b199b1 Mon Sep 17 00:00:00 2001 From: maslybs Date: Mon, 26 Nov 2018 15:14:36 +0200 Subject: [PATCH 01/12] I've added include and exclude options to the shortcode. --- includes/class-sm-shortcodes.php | 40 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/includes/class-sm-shortcodes.php b/includes/class-sm-shortcodes.php index 9662d5c..7ca587c 100755 --- a/includes/class-sm-shortcodes.php +++ b/includes/class-sm-shortcodes.php @@ -461,11 +461,11 @@ public function display_images( $atts = array() ) { // Get images. $terms = apply_filters( 'sermon-images-get-terms', '', array( // phpcs:ignore - 'taxonomy' => $args['display'], - 'term_args' => array( - 'order' => $args['order'], - 'orderby' => $args['orderby'], - ), + 'taxonomy' => $args['display'], + 'term_args' => array( + 'order' => $args['order'], + 'orderby' => $args['orderby'], + ), ) ); // $terms will always return an array @@ -773,14 +773,17 @@ function display_sermons( $atts = array() ) { 'hide_series' => '', 'hide_preachers' => '', 'hide_books' => '', + 'include' => '', + 'exclude' => '', 'hide_service_types' => \SermonManager::getOption( 'service_type_filtering' ) ? '' : 'yes', ); // Legacy convert. $old_options = array( 'posts_per_page' => 'per_page', - 'id' => 'sermons', - 'sermon' => 'sermons', + 'id' => 'include', + 'sermon' => 'include', + 'sermons' => 'include', 'hide_nav' => 'hide_pagination', 'taxonomy' => 'filter_by', 'tax_term' => 'filter_value', @@ -844,8 +847,8 @@ function display_sermons( $atts = array() ) { $query_args['orderby'] = $args['orderby']; // If we should show just specific sermons. - if ( $args['sermons'] ) { - $posts_in = explode( ',', $args['sermons'] ); + if ( $args['include'] ) { + $posts_in = explode( ',', $args['include'] ); if ( ! empty( $posts_in ) ) { foreach ( $posts_in as &$post_in ) { @@ -863,6 +866,25 @@ function display_sermons( $atts = array() ) { } } + if ( $args['exclude'] ) { + $posts_in = explode( ',', $args['exclude'] ); + + if ( ! empty( $posts_in ) ) { + foreach ( $posts_in as &$post_in ) { + // Remove if it's not an ID. + if ( ! is_numeric( trim( $post_in ) ) ) { + unset( $post_in ); + continue; + } + + // Convert to int. + $posts_in = intval( trim( $post_in ) ); + } + + $query_args['post__not_in'] = (array) $posts_in; + } + } + // If we should filter by something. if ( $args['filter_by'] && $args['filter_value'] ) { // Term string to array. From 74877724750d8b2dd851d7a5656d6d82731e0859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 26 Nov 2018 14:29:02 +0100 Subject: [PATCH 02/12] Update changelog Related to e7ca1d3e92d0400d2dc824637c7422bac1b199b1 Closes #148 --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index d4896e8..57b5e38 100755 --- a/readme.txt +++ b/readme.txt @@ -122,6 +122,9 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man 2. Sermon Files ## Changelog ## +### 2.15.10 ### +* Change: Add "include" and "exclude" parameters to the shortcode + ### 2.15.9 ### * New: Add support for Hueman and Hueman Pro themes * New: Add support for NativeChurch theme From bad71d3926623263066a97de684ea7549da3f501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Tue, 27 Nov 2018 17:10:45 +0100 Subject: [PATCH 03/12] Add an option to force loading plugin views --- includes/admin/settings/class-sm-settings-debug.php | 8 ++++++++ includes/sm-template-functions.php | 10 ++++++---- readme.txt | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/includes/admin/settings/class-sm-settings-debug.php b/includes/admin/settings/class-sm-settings-debug.php index 6f74b4f..e0c1cea 100644 --- a/includes/admin/settings/class-sm-settings-debug.php +++ b/includes/admin/settings/class-sm-settings-debug.php @@ -167,6 +167,14 @@ public function get_settings() { 'id' => 'disable_layouts', 'default' => 'no', ), + array( + 'title' => __( 'Force Plugin Views', 'sermon-manager-for-wordpress' ), + 'type' => 'checkbox', + 'desc' => __( 'Force plugin views.', 'sermon-manager-for-wordpress' ), + 'desc_tip' => __( 'Forces loading of Sermon Manager views, while overriding theme overrides.', 'sermon-manager-for-wordpress' ), + 'id' => 'force_layouts', + 'default' => 'no', + ), array( 'type' => 'sectionend', diff --git a/includes/sm-template-functions.php b/includes/sm-template-functions.php index 5d86b81..7555c50 100755 --- a/includes/sm-template-functions.php +++ b/includes/sm-template-functions.php @@ -14,7 +14,7 @@ */ if ( ! \SermonManager::getOption( 'theme_compatibility' ) ) { add_filter( 'template_include', function ( $template ) { - return sm_get_views_path($template); + return sm_get_views_path( $template ); } ); } @@ -687,7 +687,9 @@ function wpfc_get_partial( $name = '', $args = array() ) { * * @since 2.13.4 */ -function sm_get_views_path( $template = '' ){ +function sm_get_views_path( $template = '' ) { + $force_views = SermonManager::getOption( 'force_layouts' ); + if ( is_singular( 'wpfc_sermon' ) ) { $default_file = 'single-wpfc_sermon.php'; } elseif ( is_tax( get_object_taxonomies( 'wpfc_sermon' ) ) ) { @@ -702,7 +704,7 @@ function sm_get_views_path( $template = '' ){ ) ) ) { $default_file = 'taxonomy-' . $term->taxonomy . '.php'; - if ( ! file_exists( get_stylesheet_directory() . '/' . $default_file ) ) { + if ( ! file_exists( get_stylesheet_directory() . '/' . $default_file ) && ! $force_views ) { $default_file = 'archive-wpfc_sermon.php'; } } else { @@ -715,7 +717,7 @@ function sm_get_views_path( $template = '' ){ } if ( $default_file ) { - if ( file_exists( get_stylesheet_directory() . '/' . $default_file ) ) { + if ( file_exists( get_stylesheet_directory() . '/' . $default_file ) && ! $force_views ) { return get_stylesheet_directory() . '/' . $default_file; } diff --git a/readme.txt b/readme.txt index 57b5e38..b516555 100755 --- a/readme.txt +++ b/readme.txt @@ -124,6 +124,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man ## Changelog ## ### 2.15.10 ### * Change: Add "include" and "exclude" parameters to the shortcode +* Change: Add an option to force loading plugin views ### 2.15.9 ### * New: Add support for Hueman and Hueman Pro themes From ccf83c4013dba8557d3ba8414a206ac31eded10f Mon Sep 17 00:00:00 2001 From: maslybs Date: Wed, 28 Nov 2018 15:05:17 +0200 Subject: [PATCH 04/12] fixed conflict with Divi (comments double) --- views/single-wpfc_sermon.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/views/single-wpfc_sermon.php b/views/single-wpfc_sermon.php index aa6cbfb..e86e9d5 100755 --- a/views/single-wpfc_sermon.php +++ b/views/single-wpfc_sermon.php @@ -23,7 +23,10 @@ echo get_the_password_form( $post ); } - if ( comments_open() || get_comments_number() ) : + /* + * Hide if Divi theme is activated + */ + if ( ( comments_open() || get_comments_number() ) && ! function_exists( 'et_get_option' ) ) : comments_template(); endif; endwhile; From 9b5ee13b924ad4ceff7812e57aa51ffd643d1307 Mon Sep 17 00:00:00 2001 From: maslybs Date: Wed, 28 Nov 2018 15:53:36 +0200 Subject: [PATCH 05/12] return original --- views/single-wpfc_sermon.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/views/single-wpfc_sermon.php b/views/single-wpfc_sermon.php index e86e9d5..aa6cbfb 100755 --- a/views/single-wpfc_sermon.php +++ b/views/single-wpfc_sermon.php @@ -23,10 +23,7 @@ echo get_the_password_form( $post ); } - /* - * Hide if Divi theme is activated - */ - if ( ( comments_open() || get_comments_number() ) && ! function_exists( 'et_get_option' ) ) : + if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; From 119452695057756ef1c72728a7333c928084b1f2 Mon Sep 17 00:00:00 2001 From: maslybs Date: Wed, 28 Nov 2018 18:29:47 +0200 Subject: [PATCH 06/12] add filter for Dive theme from Nikola --- views/single-wpfc_sermon.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/single-wpfc_sermon.php b/views/single-wpfc_sermon.php index aa6cbfb..25b0946 100755 --- a/views/single-wpfc_sermon.php +++ b/views/single-wpfc_sermon.php @@ -24,7 +24,9 @@ } if ( comments_open() || get_comments_number() ) : - comments_template(); + if ( ! apply_filters( 'single-wpfc_sermon-disable-comments', false ) ) { + comments_template(); + } endif; endwhile; From d759e1bb04265a20b24ce28b10bff6bd66afeab8 Mon Sep 17 00:00:00 2001 From: Tyler Paulson Date: Wed, 28 Nov 2018 11:34:16 -0500 Subject: [PATCH 07/12] Append service type title to Podcast feed when loading a service type's feed --- views/wpfc-podcast-feed.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index bc9d552..31bad5a 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -106,6 +106,9 @@ 'terms' => $term, ), ); + if($taxonomy === 'wpfc_service_type') { + $settings['title'] = single_term_title($settings['title'].' - ', false); + } } /** From 94b4d7615296108826218e152320323152d4988a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Thu, 29 Nov 2018 14:29:32 +0100 Subject: [PATCH 08/12] Append title for all taxonomies --- views/wpfc-podcast-feed.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index 31bad5a..3f77dc5 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -106,9 +106,9 @@ 'terms' => $term, ), ); - if($taxonomy === 'wpfc_service_type') { - $settings['title'] = single_term_title($settings['title'].' - ', false); - } + + // Append term name to the feed title, so it looks like "Feed Name - Term Name". + $settings['title'] = single_term_title( $settings['title'] . ' - ', false ); } /** From 0d8411c2bb5b4e73072b09f76ab0eeec9bd06d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 30 Nov 2018 13:16:46 +0100 Subject: [PATCH 09/12] Fix edge case feed with taxonomy bug --- readme.txt | 1 + views/wpfc-podcast-feed.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/readme.txt b/readme.txt index b516555..27a8e40 100755 --- a/readme.txt +++ b/readme.txt @@ -125,6 +125,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man ### 2.15.10 ### * Change: Add "include" and "exclude" parameters to the shortcode * Change: Add an option to force loading plugin views +* Fix: Edge case PHP bug in feed with taxonomy ### 2.15.9 ### * New: Add support for Hueman and Hueman Pro themes diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index bc9d552..ae7e2c8 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -129,6 +129,10 @@ // Override the default tax_query for that taxonomy. if ( ! empty( $args['tax_query'] ) ) { foreach ( $args['tax_query'] as $id => $arg ) { + if ( ! is_array( $arg ) ) { + continue; + } + if ( $arg['taxonomy'] === $taxonomy ) { unset( $args['tax_query'][ $id ] ); } From 4543c29e3b5d53f40b11d6c4dd2b950f58b7f346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 30 Nov 2018 13:37:46 +0100 Subject: [PATCH 10/12] Fix notice when using sermons shortcode --- includes/class-sm-shortcodes.php | 2 +- readme.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-sm-shortcodes.php b/includes/class-sm-shortcodes.php index 7ca587c..f5f2bb2 100755 --- a/includes/class-sm-shortcodes.php +++ b/includes/class-sm-shortcodes.php @@ -806,7 +806,7 @@ function display_sermons( $atts = array() ) { 'hide_series' => $args['hide_series'], 'hide_preachers' => $args['hide_preachers'], 'hide_books' => $args['hide_books'], - 'hide_service_types' => $args['hide_service_type'], + 'hide_service_types' => $args['hide_service_types'], ); // Set query args. diff --git a/readme.txt b/readme.txt index 27a8e40..42d701f 100755 --- a/readme.txt +++ b/readme.txt @@ -126,6 +126,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man * Change: Add "include" and "exclude" parameters to the shortcode * Change: Add an option to force loading plugin views * Fix: Edge case PHP bug in feed with taxonomy +* Fix: Notice when using shortcode ### 2.15.9 ### * New: Add support for Hueman and Hueman Pro themes From c0cdb693319fe3fea4eb3aad5951b2d330fba804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 30 Nov 2018 18:52:27 +0100 Subject: [PATCH 11/12] CS fix --- includes/class-sm-shortcodes.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/class-sm-shortcodes.php b/includes/class-sm-shortcodes.php index f5f2bb2..0de6f91 100755 --- a/includes/class-sm-shortcodes.php +++ b/includes/class-sm-shortcodes.php @@ -461,11 +461,11 @@ public function display_images( $atts = array() ) { // Get images. $terms = apply_filters( 'sermon-images-get-terms', '', array( // phpcs:ignore - 'taxonomy' => $args['display'], - 'term_args' => array( - 'order' => $args['order'], - 'orderby' => $args['orderby'], - ), + 'taxonomy' => $args['display'], + 'term_args' => array( + 'order' => $args['order'], + 'orderby' => $args['orderby'], + ), ) ); // $terms will always return an array From 7f5f52591328dc28be013a8a613583ef2a6cc59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 30 Nov 2018 18:53:36 +0100 Subject: [PATCH 12/12] Update versions --- readme.txt | 2 +- sermons.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 42d701f..54b07fd 100755 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: church, sermon, sermons, preaching, podcasting, manage, managing, podcasts Requires at least: 4.7.0 Tested up to: 4.9 Requires PHP: 5.3 -Stable tag: 2.15.9 +Stable tag: 2.15.10 License: GPLv2 License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/sermons.php b/sermons.php index 56d63b5..5248566 100755 --- a/sermons.php +++ b/sermons.php @@ -3,7 +3,7 @@ * Plugin Name: Sermon Manager for WordPress * Plugin URI: https://www.wpforchurch.com/products/sermon-manager-for-wordpress/ * Description: Add audio and video sermons, manage speakers, series, and more. - * Version: 2.15.9 + * Version: 2.15.10 * Author: WP for Church * Author URI: https://www.wpforchurch.com/ * Requires at least: 4.5