Skip to content

Commit fd4e548

Browse files
author
Nikola Miljković
committed
Release 2.15.8
2 parents fb52c74 + d7a68dc commit fd4e548

6 files changed

Lines changed: 167 additions & 30 deletions

File tree

includes/admin/class-sm-admin-settings.php

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ public static function add_error( $text ) {
197197
* Loops though the Sermon Manager options array and outputs each field.
198198
*
199199
* @param array[] $options Opens array to output.
200+
* @param array $values The array of custom values. Optional.
200201
*/
201-
public static function output_fields( $options ) {
202+
public static function output_fields( $options, $values = array() ) {
202203
foreach ( $options as $value ) {
203204
if ( ! isset( $value['type'] ) ) {
204205
continue;
@@ -235,20 +236,53 @@ public static function output_fields( $options ) {
235236
$description = $field_description['description'];
236237
$tooltip_html = $field_description['tooltip_html'];
237238

238-
// Fill out pages for pages selection.
239-
if ( isset( $value['options'] ) && '%pages%' === $value['options'] ) {
240-
$pages = get_pages();
241-
$value['options'] = array(
242-
0 => '-- ' . __( 'None', 'sermon-manager-for-wordpress' ) . ' --',
243-
);
239+
// Execute a function to get the options in (multi)select if it's specified.
240+
if ( isset( $value['options'] ) ) {
241+
$function = false;
242+
$args = null;
243+
244+
if ( is_string( $value['options'] ) ) {
245+
$function = $value['options'];
246+
} elseif ( is_array( $value['options'] ) ) {
247+
if ( count( $value['options'] ) === 1 ) {
248+
foreach ( $value['options'] as $function => $args ) {
249+
// Let's assume that it's a function with arguments.
250+
if ( is_array( $args ) ) {
251+
break;
252+
}
253+
}
254+
}
255+
}
256+
257+
if ( $function ) {
258+
if ( function_exists( $function ) ) {
259+
if ( is_array( $args ) ) {
260+
$value['options'] = call_user_func_array( $function, $args );
261+
} else {
262+
$value['options'] = call_user_func( $function );
263+
}
264+
265+
if ( ! is_array( $value['options'] ) ) {
266+
$value['options'] = array();
267+
}
244268

245-
foreach ( $pages as $page ) {
246-
$value['options'][ $page->ID ] = $page->post_title;
269+
if ( count( $value['options'] ) === 0 ) {
270+
$value['options'] = array( 0 => '-- ' . __( 'None' ) . ' --' );
271+
}
272+
} else {
273+
$value['options'] = array(
274+
0 => __( 'Error.' ),
275+
);
276+
}
247277
}
248278
}
249279

250280
// Get the value.
251-
$option_value = self::get_option( $value['id'], $value['default'] );
281+
if ( empty( $values ) ) {
282+
$option_value = self::get_option( $value['id'], $value['default'] );
283+
} else {
284+
$option_value = empty( $values[ $value['id'] ] ) ? $value['default'] : $values[ $value['id'] ];
285+
}
252286

253287
// Output the field based on type.
254288
switch ( $value['type'] ) {

includes/admin/views/html-admin-settings.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@
4343
</form>
4444
</div>
4545
<div class="settings-side">
46+
<div class="postbox sm-box" style="background: #f6fbff;">
47+
<h3><span>Sermon Manager Pro</span>
48+
</h3>
49+
<div class="inside">
50+
<p>Imagine being able to change the look of your sermons with one click or use your favorite page
51+
builder, or create multiple podcasts...well now you can with Sermon Manager Pro, plus a lot
52+
more. </p>
53+
<div style="text-align:center">
54+
<a href="https://sermonmanager.pro/?utm_source=sermon-manager&amp;utm_medium=wordpress"
55+
target="_blank" class="button-secondary">Get Pro</a>&nbsp;
56+
<a href="https://sermonmanager.pro/?utm_source=sermon-manager&amp;utm_medium=wordpress"
57+
class="button-primary">Learn More</a>
58+
</div>
59+
<div class="description">
60+
<span>Early Adopter pricing ends Nov 23</span>
61+
</div>
62+
</div>
63+
</div>
4664
<div class="postbox sm-box">
4765
<h3><span><?php esc_html_e( 'Need Some Help?', 'sermon-manager-for-wordpress' ); ?></span>
4866
</h3>

includes/class-sm-install.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public static function plugin_row_meta( $links, $file ) {
267267
if ( SM_BASENAME == $file ) {
268268
$row_meta = array(
269269
'support' => '<a href="' . esc_url( 'https://wpforchurch.com/my/submitticket.php?utm_source=sermon-manager&utm_medium=wordpress' ) . '" aria-label="' . esc_attr__( 'Visit premium customer support', 'sermon-manager-for-wordpress' ) . '">' . esc_html__( 'Premium support', 'sermon-manager-for-wordpress' ) . '</a>',
270+
'smp' => '<a href="https://sermonmanager.pro/?utm_source=sermon-manager&amp;utm_medium=wordpress" aria-label="' . esc_attr( __( 'Get Sermon Manager Pro', 'sermon-manager-pro' ) ) . '" target="_blank" style="color:#ff0000;">' . __( 'Get Sermon Manager Pro', 'sermon-manager-pro' ) . '</a>',
270271
);
271272

272273
return array_merge( $links, $row_meta );

readme.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: church, sermon, sermons, preaching, podcasting, manage, managing, podcasts
55
Requires at least: 4.7.0
66
Tested up to: 4.9
77
Requires PHP: 5.3
8-
Stable tag: 2.15.7
8+
Stable tag: 2.15.8
99
License: GPLv2
1010
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -60,6 +60,25 @@ You can access the paid support options via [our website](http://wpforchurch.com
6060

6161
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.
6262

63+
### Sermon Manager Pro Features ###
64+
65+
* Change your look with Templates
66+
* Multiple Podcast Support
67+
* Divi Support & Custom Divi Builder Modules
68+
* Custom Elementor Elements
69+
* Custom Beaver Builder Modules
70+
* Custom WPBakery Page Builder Modules
71+
* Works with YOUR theme
72+
* Page Assignment for Archive & Taxonomy
73+
* Migration from other plugins is a breeze
74+
* SEO & Marketing Ready
75+
* Live Chat Support Inside the Plugin
76+
* PowerPress Compatibility
77+
* [Full List of Pro Features & Roadmap](https://sermonmanager.pro/)
78+
79+
When you upgrade to Pro you also get premium ticket and live chat support for the free version of Sermon Manager too!
80+
*Grab your copy of Sermon Manager Pro at early adopter pricing for life between Nov 9th and Nov 23!*
81+
6382
### Developers ###
6483

6584
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)!
@@ -103,6 +122,10 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man
103122
2. Sermon Files
104123

105124
## Changelog ##
125+
### 2.15.8 ###
126+
* Dev: Add callable select options (pass function name as string)
127+
* Dev: Add a way to pass custom values to settings
128+
106129
### 2.15.7 ###
107130
* Fix: PHP warning when archive output is used wrongly
108131
* Fix: Podcast items may be sorted the wrong way

sermons.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Sermon Manager for WordPress
44
* Plugin URI: https://www.wpforchurch.com/products/sermon-manager-for-wordpress/
55
* Description: Add audio and video sermons, manage speakers, series, and more.
6-
* Version: 2.15.7
6+
* Version: 2.15.8
77
* Author: WP for Church
88
* Author URI: https://www.wpforchurch.com/
99
* Requires at least: 4.5

views/wpfc-podcast-feed.php

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,72 @@
99

1010
global $taxonomy, $term;
1111

12+
if ( isset( $GLOBALS['sm_podcast_data'] ) && is_array( $GLOBALS['sm_podcast_data'] ) ) {
13+
$settings = $GLOBALS['sm_podcast_data'];
14+
} else {
15+
$settings = array();
16+
}
17+
18+
// Option ID => escape function.
19+
$default_settings = array(
20+
'podcasts_per_page' => 'intval',
21+
'title' => 'esc_html',
22+
'website_link' => 'esc_url',
23+
'description' => 'esc_html',
24+
'language' => 'esc_html',
25+
'copyright' => 'esc_html',
26+
'itunes_subtitle' => 'esc_html',
27+
'itunes_author' => 'esc_html',
28+
'enable_podcast_html_description' => '',
29+
'itunes_summary' => '',
30+
'itunes_owner_name' => 'esc_html',
31+
'itunes_owner_email' => 'esc_html',
32+
'itunes_cover_image' => 'esc_url',
33+
'itunes_sub_category' => '',
34+
'podcast_sermon_image_series' => '',
35+
'podtrac' => '',
36+
'use_published_date' => '',
37+
);
38+
39+
// If there is no default.
40+
$wordpress_settings = array(
41+
'podcasts_per_page' => 10,
42+
'title' => get_wp_title_rss(),
43+
'website_link' => get_bloginfo_rss( 'url' ),
44+
'description' => get_bloginfo_rss( 'description' ),
45+
'language' => get_bloginfo_rss( 'language' ),
46+
);
47+
48+
foreach ( $default_settings as $id => $escape_function ) {
49+
// Get SM podcast setting if there is no custom.
50+
if ( ! isset( $settings[ $id ] ) ) {
51+
$settings[ $id ] = SermonManager::getOption( $id );
52+
}
53+
54+
// Escape the data.
55+
if ( $escape_function ) {
56+
$settings[ $id ] = call_user_func( $escape_function, $settings[ $id ] );
57+
}
58+
59+
// Get the WordPress or custom default if there is no custom setting or SM setting.
60+
if ( ! $settings[ $id ] ) {
61+
$settings[ $id ] = '';
62+
63+
if ( isset( $wordpress_settings[ $id ] ) ) {
64+
$settings[ $id ] = $wordpress_settings[ $id ];
65+
}
66+
}
67+
68+
// No need to escape again here, since the data will either come from WordPress podcast functions or be pre-escaped
69+
// in this script (or be blank).
70+
}
71+
1272
/**
1373
* Create the query for sermons.
1474
*/
1575
$args = array(
1676
'post_type' => 'wpfc_sermon',
17-
'posts_per_page' => intval( \SermonManager::getOption( 'podcasts_per_page' ) ) ?: 10,
77+
'posts_per_page' => $settings['podcasts_per_page'],
1878
'meta_key' => 'sermon_date',
1979
'meta_value_num' => time(),
2080
'meta_compare' => '<=',
@@ -109,19 +169,19 @@
109169
'7' => 'Spirituality',
110170
);
111171

112-
$title = esc_html( \SermonManager::getOption( 'title' ) ) ?: get_wp_title_rss();
113-
$link = esc_url( \SermonManager::getOption( 'website_link' ) ) ?: get_bloginfo_rss( 'url' );
114-
$description = esc_html( \SermonManager::getOption( 'description' ) ) ?: get_bloginfo_rss( 'description' );
115-
$language = esc_html( \SermonManager::getOption( 'language' ) ) ?: get_bloginfo_rss( 'language' );
172+
$title = $settings['title'];
173+
$link = $settings['website_link'];
174+
$description = $settings['description'];
175+
$language = $settings['language'];
116176
$last_sermon_date = ! empty( $sermon_podcast_query->posts ) ? get_post_meta( $sermon_podcast_query->posts[0]->ID, 'sermon_date', true ) ?: null : null;
117-
$copyright = html_entity_decode( esc_html( \SermonManager::getOption( 'copyright' ) ), ENT_COMPAT, 'UTF-8' );
118-
$subtitle = esc_html( \SermonManager::getOption( 'itunes_subtitle' ) );
119-
$author = esc_html( \SermonManager::getOption( 'itunes_author' ) );
120-
$summary = str_replace( '&nbsp;', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ) : stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) );
121-
$owner_name = esc_html( \SermonManager::getOption( 'itunes_owner_name' ) );
122-
$owner_email = esc_html( \SermonManager::getOption( 'itunes_owner_email' ) );
123-
$cover_image_url = esc_url( \SermonManager::getOption( 'itunes_cover_image' ) );
124-
$subcategory = esc_attr( ! empty( $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] ) ? $categories[ \SermonManager::getOption( 'itunes_sub_category' ) ] : 'Christianity' );
177+
$copyright = html_entity_decode( $settings['copyright'], ENT_COMPAT, 'UTF-8' );
178+
$subtitle = $settings['itunes_subtitle'];
179+
$author = $settings['itunes_author'];
180+
$summary = str_replace( '&nbsp;', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $settings['itunes_summary'] ) ) ) : stripslashes( wp_filter_nohtml_kses( $settings['itunes_summary'] ) ) );
181+
$owner_name = $settings['itunes_owner_name'];
182+
$owner_email = $settings['itunes_owner_email'];
183+
$cover_image_url = $settings['itunes_cover_image'];
184+
$subcategory = esc_attr( ! empty( $categories[ $settings['itunes_sub_category'] ] ) ? $categories[ $settings['itunes_sub_category'] ] : 'Christianity' );
125185

126186
?>
127187
<rss version="2.0"
@@ -150,7 +210,7 @@
150210
<itunes:email><?php echo $owner_email; ?></itunes:email>
151211
</itunes:owner>
152212
<itunes:explicit>no</itunes:explicit>
153-
<?php if ( \SermonManager::getOption( 'itunes_cover_image' ) ) : ?>
213+
<?php if ( $cover_image_url ) : ?>
154214
<itunes:image href="<?php echo $cover_image_url; ?>"/>
155215
<?php endif; ?>
156216

@@ -175,12 +235,12 @@
175235
$speaker = $speakers_terms ? $speakers_terms[0]->name : '';
176236
$series = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_series', '', ', ', '' ) );
177237
$topics = strip_tags( get_the_term_list( $post->ID, 'wpfc_sermon_topics', '', ', ', '' ) );
178-
$post_image = get_sermon_image_url( SermonManager::getOption( 'podcast_sermon_image_series' ) );
238+
$post_image = get_sermon_image_url( $settings['podcast_sermon_image_series'] );
179239
$post_image = str_ireplace( 'https://', 'http://', ! empty( $post_image ) ? $post_image : '' );
180240
$audio_duration = get_post_meta( $post->ID, '_wpfc_sermon_duration', true ) ?: '0:00';
181241
$audio_file_size = get_post_meta( $post->ID, '_wpfc_sermon_size', 'true' ) ?: 0;
182242
$description = strip_shortcodes( get_post_meta( $post->ID, 'sermon_description', true ) );
183-
$description = str_replace( '&nbsp;', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) );
243+
$description = str_replace( '&nbsp;', '', $settings['enable_podcast_html_description'] ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) );
184244
$date_preached = SM_Dates::get( 'D, d M Y H:i:s +0000', null, false, false );
185245
$date_published = get_the_date( 'D, d M Y H:i:s +0000', $post->ID );
186246

@@ -189,7 +249,7 @@
189249
$audio = site_url( $audio );
190250
}
191251

192-
if ( \SermonManager::getOption( 'podtrac' ) ) {
252+
if ( $settings['podtrac'] ) {
193253
$audio = 'http://dts.podtrac.com/redirect.mp3/' . esc_url( preg_replace( '#^https?://#', '', $audio ) );
194254
} else {
195255
// As per RSS 2.0 spec, the enclosure URL must be HTTP only:
@@ -205,7 +265,7 @@
205265
<comments><?php comments_link_feed(); ?></comments>
206266
<?php endif; ?>
207267

208-
<pubDate><?php echo SermonManager::getOption( 'use_published_date' ) ? $date_published : $date_preached; ?></pubDate>
268+
<pubDate><?php echo $settings['use_published_date'] ? $date_published : $date_preached; ?></pubDate>
209269
<dc:creator><![CDATA[<?php echo esc_html( $speaker ); ?>]]></dc:creator>
210270
<?php the_category_rss( 'rss2' ); ?>
211271

@@ -220,6 +280,7 @@
220280
<itunes:image href="<?php echo esc_url( $post_image ); ?>"/>
221281
<?php endif; ?>
222282

283+
<!--suppress CheckEmptyScriptTag -->
223284
<enclosure url="<?php echo esc_url( $audio ); ?>"
224285
length="<?php echo esc_attr( $audio_file_size ); ?>"
225286
type="audio/mpeg"/>

0 commit comments

Comments
 (0)