From 6463a2d8d931326600ff2fa81272375f64a6bffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Thu, 8 Nov 2018 12:42:33 +0100 Subject: [PATCH 1/7] Add callable select options --- includes/admin/class-sm-admin-settings.php | 23 ++++++++++++++-------- readme.txt | 3 +++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/includes/admin/class-sm-admin-settings.php b/includes/admin/class-sm-admin-settings.php index ce27cf0..4050500 100644 --- a/includes/admin/class-sm-admin-settings.php +++ b/includes/admin/class-sm-admin-settings.php @@ -236,14 +236,21 @@ public static function output_fields( $options ) { $tooltip_html = $field_description['tooltip_html']; // Fill out pages for pages selection. - if ( isset( $value['options'] ) && '%pages%' === $value['options'] ) { - $pages = get_pages(); - $value['options'] = array( - 0 => '-- ' . __( 'None', 'sermon-manager-for-wordpress' ) . ' --', - ); - - foreach ( $pages as $page ) { - $value['options'][ $page->ID ] = $page->post_title; + if ( isset( $value['options'] ) && is_string( $value['options'] ) ) { + if ( function_exists( $value['options'] ) ) { + $value['options'] = call_user_func( $value['options'] ); + + if ( ! is_array( $value['options'] ) ) { + $value['options'] = array(); + } + + if ( count( $value['options'] ) === 0 ) { + $value['options'] = array( 0 => '-- ' . __( 'None' ) . ' --' ); + } + } else { + $value['options'] = array( + 0 => __( 'Error.' ), + ); } } diff --git a/readme.txt b/readme.txt index d13b87f..1af3202 100755 --- a/readme.txt +++ b/readme.txt @@ -103,6 +103,9 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man 2. Sermon Files ## Changelog ## +### 2.15.8 ### +* Dev: Add callable select options (pass function name as string) + ### 2.15.7 ### * Fix: PHP warning when archive output is used wrongly * Fix: Podcast items may be sorted the wrong way From d67b3d6b8adb8a48aec34807b633fe3a5ec65dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Thu, 8 Nov 2018 22:17:01 +0100 Subject: [PATCH 2/7] Add ability to call custom function with parameters in settings --- includes/admin/class-sm-admin-settings.php | 48 ++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/includes/admin/class-sm-admin-settings.php b/includes/admin/class-sm-admin-settings.php index 4050500..0d52045 100644 --- a/includes/admin/class-sm-admin-settings.php +++ b/includes/admin/class-sm-admin-settings.php @@ -235,22 +235,44 @@ public static function output_fields( $options ) { $description = $field_description['description']; $tooltip_html = $field_description['tooltip_html']; - // Fill out pages for pages selection. - if ( isset( $value['options'] ) && is_string( $value['options'] ) ) { - if ( function_exists( $value['options'] ) ) { - $value['options'] = call_user_func( $value['options'] ); - - if ( ! is_array( $value['options'] ) ) { - $value['options'] = array(); + // Execute a function to get the options in (multi)select if it's specified. + if ( isset( $value['options'] ) ) { + $function = false; + $args = null; + + if ( is_string( $value['options'] ) ) { + $function = $value['options']; + } elseif ( is_array( $value['options'] ) ) { + if ( count( $value['options'] ) === 1 ) { + foreach ( $value['options'] as $function => $args ) { + // Let's assume that it's a function with arguments. + if ( is_array( $args ) ) { + break; + } + } } + } + + if ( $function ) { + if ( function_exists( $function ) ) { + if ( is_array( $args ) ) { + $value['options'] = call_user_func_array( $function, $args ); + } else { + $value['options'] = call_user_func( $function ); + } - if ( count( $value['options'] ) === 0 ) { - $value['options'] = array( 0 => '-- ' . __( 'None' ) . ' --' ); + if ( ! is_array( $value['options'] ) ) { + $value['options'] = array(); + } + + if ( count( $value['options'] ) === 0 ) { + $value['options'] = array( 0 => '-- ' . __( 'None' ) . ' --' ); + } + } else { + $value['options'] = array( + 0 => __( 'Error.' ), + ); } - } else { - $value['options'] = array( - 0 => __( 'Error.' ), - ); } } From 4ca8ad16057c92d1f6fedfac26923d1743bb95f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Thu, 8 Nov 2018 23:09:08 +0100 Subject: [PATCH 3/7] Add a way to pass custom values to settings --- includes/admin/class-sm-admin-settings.php | 9 +++++++-- readme.txt | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-sm-admin-settings.php b/includes/admin/class-sm-admin-settings.php index 0d52045..12f987a 100644 --- a/includes/admin/class-sm-admin-settings.php +++ b/includes/admin/class-sm-admin-settings.php @@ -197,8 +197,9 @@ public static function add_error( $text ) { * Loops though the Sermon Manager options array and outputs each field. * * @param array[] $options Opens array to output. + * @param array $values The array of custom values. Optional. */ - public static function output_fields( $options ) { + public static function output_fields( $options, $values = array() ) { foreach ( $options as $value ) { if ( ! isset( $value['type'] ) ) { continue; @@ -277,7 +278,11 @@ public static function output_fields( $options ) { } // Get the value. - $option_value = self::get_option( $value['id'], $value['default'] ); + if ( empty( $values ) ) { + $option_value = self::get_option( $value['id'], $value['default'] ); + } else { + $option_value = empty( $values[ $value['id'] ] ) ? $value['default'] : $values[ $value['id'] ]; + } // Output the field based on type. switch ( $value['type'] ) { diff --git a/readme.txt b/readme.txt index 1af3202..ead7107 100755 --- a/readme.txt +++ b/readme.txt @@ -105,6 +105,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man ## Changelog ## ### 2.15.8 ### * Dev: Add callable select options (pass function name as string) +* Dev: Add a way to pass custom values to settings ### 2.15.7 ### * Fix: PHP warning when archive output is used wrongly From 21f858161e11fced968f775047451034a6921916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 9 Nov 2018 00:19:34 +0100 Subject: [PATCH 4/7] Podcasting improvement --- views/wpfc-podcast-feed.php | 97 ++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index c4ec5c7..675c317 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -9,12 +9,72 @@ global $taxonomy, $term; +if ( isset( $GLOBALS['sm_podcast_data'] ) && is_array( $GLOBALS['sm_podcast_data'] ) ) { + $settings = $GLOBALS['sm_podcast_data']; +} else { + $settings = array(); +} + +// Option ID => escape function. +$default_settings = array( + 'podcasts_per_page' => 'intval', + 'title' => 'esc_html', + 'website_link' => 'esc_url', + 'description' => 'esc_html', + 'language' => 'esc_html', + 'copyright' => 'esc_html', + 'itunes_subtitle' => 'esc_html', + 'itunes_author' => 'esc_html', + 'enable_podcast_html_description' => '', + 'itunes_summary' => '', + 'itunes_owner_name' => 'esc_html', + 'itunes_owner_email' => 'esc_html', + 'itunes_cover_image' => 'esc_url', + 'itunes_sub_category' => '', + 'podcast_sermon_image_series' => '', + 'podtrac' => '', + 'use_published_date' => '', +); + +// If there is no default. +$wordpress_settings = array( + 'podcasts_per_page' => 10, + 'title' => get_wp_title_rss(), + 'website_link' => get_bloginfo_rss( 'url' ), + 'description' => get_bloginfo_rss( 'description' ), + 'language' => get_bloginfo_rss( 'language' ), +); + +foreach ( $default_settings as $id => $escape_function ) { + // Get SM podcast setting if there is no custom. + if ( ! isset( $settings[ $id ] ) ) { + $settings[ $id ] = SermonManager::getOption( $id ); + } + + // Escape the data. + if ( $escape_function ) { + $settings[ $id ] = call_user_func( $escape_function, $settings[ $id ] ); + } + + // Get the WordPress or custom default if there is no custom setting or SM setting. + if ( ! $settings[ $id ] ) { + $settings[ $id ] = ''; + + if ( isset( $wordpress_settings[ $id ] ) ) { + $settings[ $id ] = $wordpress_settings[ $id ]; + } + } + + // No need to escape again here, since the data will either come from WordPress podcast functions or be pre-escaped + // in this script (or be blank). +} + /** * Create the query for sermons. */ $args = array( 'post_type' => 'wpfc_sermon', - 'posts_per_page' => intval( \SermonManager::getOption( 'podcasts_per_page' ) ) ?: 10, + 'posts_per_page' => $settings['podcasts_per_page'], 'meta_key' => 'sermon_date', 'meta_value_num' => time(), 'meta_compare' => '<=', @@ -109,19 +169,19 @@ '7' => 'Spirituality', ); -$title = esc_html( \SermonManager::getOption( 'title' ) ) ?: get_wp_title_rss(); -$link = esc_url( \SermonManager::getOption( 'website_link' ) ) ?: get_bloginfo_rss( 'url' ); -$description = esc_html( \SermonManager::getOption( 'description' ) ) ?: get_bloginfo_rss( 'description' ); -$language = esc_html( \SermonManager::getOption( 'language' ) ) ?: get_bloginfo_rss( 'language' ); +$title = $settings['title']; +$link = $settings['website_link']; +$description = $settings['description']; +$language = $settings['language']; $last_sermon_date = ! empty( $sermon_podcast_query->posts ) ? get_post_meta( $sermon_podcast_query->posts[0]->ID, 'sermon_date', true ) ?: null : null; -$copyright = html_entity_decode( esc_html( \SermonManager::getOption( 'copyright' ) ), ENT_COMPAT, 'UTF-8' ); -$subtitle = esc_html( \SermonManager::getOption( 'itunes_subtitle' ) ); -$author = esc_html( \SermonManager::getOption( 'itunes_author' ) ); -$summary = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ) : stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ); -$owner_name = esc_html( \SermonManager::getOption( 'itunes_owner_name' ) ); -$owner_email = esc_html( \SermonManager::getOption( 'itunes_owner_email' ) ); -$cover_image_url = esc_url( \SermonManager::getOption( 'itunes_cover_image' ) ); -$subcategory = esc_attr( ! empty( $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] ) ? $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] : 'Christianity' ); +$copyright = html_entity_decode( $settings['copyright'], ENT_COMPAT, 'UTF-8' ); +$subtitle = $settings['itunes_subtitle']; +$author = $settings['itunes_author']; +$summary = str_replace( ' ', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $settings['itunes_summary'] ) ) ) : stripslashes( wp_filter_nohtml_kses( $settings['itunes_summary'] ) ) ); +$owner_name = $settings['itunes_owner_name']; +$owner_email = $settings['itunes_owner_email']; +$cover_image_url = $settings['itunes_cover_image']; +$subcategory = esc_attr( ! empty( $categories[ $settings['itunes_sub_category'] ] ) ? $categories[ $settings['itunes_sub_category'] ] : 'Christianity' ); ?> no - + @@ -175,12 +235,12 @@ $speaker = $speakers_terms ? $speakers_terms[0]->name : ''; $series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) ); $topics = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ) ); - $post_image = get_sermon_image_url( SermonManager::getOption( 'podcast_sermon_image_series' ) ); + $post_image = get_sermon_image_url( $settings['podcast_sermon_image_series'] ); $post_image = str_ireplace( 'https://', 'http://', ! empty( $post_image ) ? $post_image : '' ); $audio_duration = get_post_meta( $post->ID, '_wpfc_sermon_duration', true ) ?: '0:00'; $audio_file_size = get_post_meta( $post->ID, '_wpfc_sermon_size', 'true' ) ?: 0; $description = strip_shortcodes( get_post_meta( $post->ID, 'sermon_description', true ) ); - $description = str_replace( ' ', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) ); + $description = str_replace( ' ', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) ); $date_preached = SM_Dates::get( 'D, d M Y H:i:s +0000', null, false, false ); $date_published = get_the_date( 'D, d M Y H:i:s +0000', $post->ID ); @@ -189,7 +249,7 @@ $audio = site_url( $audio ); } - if ( \SermonManager::getOption( 'podtrac' ) ) { + if ( $settings['podtrac'] ) { $audio = 'http://dts.podtrac.com/redirect.mp3/' . esc_url( preg_replace( '#^https?://#', '', $audio ) ); } else { // As per RSS 2.0 spec, the enclosure URL must be HTTP only: @@ -205,7 +265,7 @@ - + ]]> @@ -220,6 +280,7 @@ + From ac1366fc849311cdea19ed1d3671234b950c9598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 9 Nov 2018 06:05:37 +0100 Subject: [PATCH 5/7] Add SMP mentions --- includes/admin/views/html-admin-settings.php | 18 ++++++++++++++++++ readme.txt | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/includes/admin/views/html-admin-settings.php b/includes/admin/views/html-admin-settings.php index 8a33c5f..d9ac3e9 100644 --- a/includes/admin/views/html-admin-settings.php +++ b/includes/admin/views/html-admin-settings.php @@ -43,6 +43,24 @@
+
+

Sermon Manager Pro +

+
+

Imagine being able to change the look of your sermons with one click or use your favorite page + builder, or create multiple podcasts...well now you can with Sermon Manager Pro, plus a lot + more.

+ +
+ Early Adopter pricing ends Nov 23 +
+
+

diff --git a/readme.txt b/readme.txt index ead7107..ea40dd6 100755 --- a/readme.txt +++ b/readme.txt @@ -60,6 +60,25 @@ You can access the paid support options via [our website](http://wpforchurch.com Bug fixing and fixing unexpected behavior *is free* and *always will be free*. Just [make an issue on GitHub](https://github.com/WP-for-Church/Sermon-Manager/issues/new) or [create a support thread on WordPress](https://wordpress.org/support/plugin/sermon-manager-for-wordpress#new-post) and we will solve it ASAP. +### Sermon Manager Pro Features ### + +* Change your look with Templates +* Multiple Podcast Support +* Divi Support & Custom Divi Builder Modules +* Custom Elementor Elements +* Custom Beaver Builder Modules +* Custom WPBakery Page Builder Modules +* Works with YOUR theme +* Page Assignment for Archive & Taxonomy +* Migration from other plugins is a breeze +* SEO & Marketing Ready +* Live Chat Support Inside the Plugin +* PowerPress Compatibility +* [Full List of Pro Features & Roadmap](https://sermonmanager.pro/) + +When you upgrade to Pro you also get premium ticket and live chat support for the free version of Sermon Manager too! +*Grab your copy of Sermon Manager Pro at early adopter pricing for life between Nov 9th and Nov 23!* + ### Developers ### Would you like to help improve Sermon Manager or report a bug you found? This project is open source on [GitHub](https://github.com/WP-for-Church/Sermon-Manager)! From 378e26b21980f32cb057414c2e4836e25f7afffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 9 Nov 2018 06:19:24 +0100 Subject: [PATCH 6/7] Add SMP mentions --- includes/class-sm-install.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php index 63c9ab8..2500ebc 100644 --- a/includes/class-sm-install.php +++ b/includes/class-sm-install.php @@ -267,6 +267,7 @@ public static function plugin_row_meta( $links, $file ) { if ( SM_BASENAME == $file ) { $row_meta = array( 'support' => '' . esc_html__( 'Premium support', 'sermon-manager-for-wordpress' ) . '', + 'smp' => '' . __( 'Get Sermon Manager Pro', 'sermon-manager-pro' ) . '', ); return array_merge( $links, $row_meta ); From d7a68dc12ed9b645ae1e60a39dd9ef18afab6855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Fri, 9 Nov 2018 06:46:27 +0100 Subject: [PATCH 7/7] Update versions --- readme.txt | 2 +- sermons.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index ea40dd6..d285bef 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.7 +Stable tag: 2.15.8 License: GPLv2 License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/sermons.php b/sermons.php index 00ec4d7..3974205 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.7 + * Version: 2.15.8 * Author: WP for Church * Author URI: https://www.wpforchurch.com/ * Requires at least: 4.5