Skip to content

Commit

Permalink
Release 2.15.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Miljković committed Nov 9, 2018
2 parents fb52c74 + d7a68dc commit fd4e548
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 30 deletions.
54 changes: 44 additions & 10 deletions includes/admin/class-sm-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -235,20 +236,53 @@ 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'] ) && '%pages%' === $value['options'] ) {
$pages = get_pages();
$value['options'] = array(
0 => '-- ' . __( 'None', 'sermon-manager-for-wordpress' ) . ' --',
);
// 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 ( ! is_array( $value['options'] ) ) {
$value['options'] = array();
}

foreach ( $pages as $page ) {
$value['options'][ $page->ID ] = $page->post_title;
if ( count( $value['options'] ) === 0 ) {
$value['options'] = array( 0 => '-- ' . __( 'None' ) . ' --' );
}
} else {
$value['options'] = array(
0 => __( 'Error.' ),
);
}
}
}

// 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'] ) {
Expand Down
18 changes: 18 additions & 0 deletions includes/admin/views/html-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
</form>
</div>
<div class="settings-side">
<div class="postbox sm-box" style="background: #f6fbff;">
<h3><span>Sermon Manager Pro</span>
</h3>
<div class="inside">
<p>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. </p>
<div style="text-align:center">
<a href="https://sermonmanager.pro/?utm_source=sermon-manager&amp;utm_medium=wordpress"
target="_blank" class="button-secondary">Get Pro</a>&nbsp;
<a href="https://sermonmanager.pro/?utm_source=sermon-manager&amp;utm_medium=wordpress"
class="button-primary">Learn More</a>
</div>
<div class="description">
<span>Early Adopter pricing ends Nov 23</span>
</div>
</div>
</div>
<div class="postbox sm-box">
<h3><span><?php esc_html_e( 'Need Some Help?', 'sermon-manager-for-wordpress' ); ?></span>
</h3>
Expand Down
1 change: 1 addition & 0 deletions includes/class-sm-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public static function plugin_row_meta( $links, $file ) {
if ( SM_BASENAME == $file ) {
$row_meta = array(
'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>',
'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>',
);

return array_merge( $links, $row_meta );
Expand Down
25 changes: 24 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)!
Expand Down Expand Up @@ -103,6 +122,10 @@ 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)
* Dev: Add a way to pass custom values to settings

### 2.15.7 ###
* Fix: PHP warning when archive output is used wrongly
* Fix: Podcast items may be sorted the wrong way
Expand Down
2 changes: 1 addition & 1 deletion sermons.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
97 changes: 79 additions & 18 deletions views/wpfc-podcast-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '<=',
Expand Down Expand Up @@ -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( '&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' ) ) ) );
$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( '&nbsp;', '', $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' );

?>
<rss version="2.0"
Expand Down Expand Up @@ -150,7 +210,7 @@
<itunes:email><?php echo $owner_email; ?></itunes:email>
</itunes:owner>
<itunes:explicit>no</itunes:explicit>
<?php if ( \SermonManager::getOption( 'itunes_cover_image' ) ) : ?>
<?php if ( $cover_image_url ) : ?>
<itunes:image href="<?php echo $cover_image_url; ?>"/>
<?php endif; ?>

Expand All @@ -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( '&nbsp;', '', \SermonManager::getOption( 'enable_podcast_html_description' ) ? stripslashes( wpautop( wp_filter_kses( $description ) ) ) : stripslashes( wp_filter_nohtml_kses( $description ) ) );
$description = str_replace( '&nbsp;', '', $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 );

Expand All @@ -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:
Expand All @@ -205,7 +265,7 @@
<comments><?php comments_link_feed(); ?></comments>
<?php endif; ?>

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

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

<!--suppress CheckEmptyScriptTag -->
<enclosure url="<?php echo esc_url( $audio ); ?>"
length="<?php echo esc_attr( $audio_file_size ); ?>"
type="audio/mpeg"/>
Expand Down

0 comments on commit fd4e548

Please sign in to comment.