From 4cdc01e0601fee415a14f0d54a0682e120c32c5b Mon Sep 17 00:00:00 2001 From: Nikola Date: Mon, 14 Aug 2017 10:56:05 +0200 Subject: [PATCH 01/10] Fix PHP notice in the footer Closes #56 --- includes/shortcodes.php | 16 ++++++++++++---- includes/widgets.php | 4 +++- readme.txt | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/shortcodes.php b/includes/shortcodes.php index c1ff4bb..7162817 100755 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -62,7 +62,9 @@ public function legacyShortcodes() { */ public function displaySermonsList( $atts ) { // enqueue scripts and styles - define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } // default options $args = array( @@ -261,7 +263,9 @@ public function convertTaxonomyName( $name, $new_name ) { */ public function displayImages( $atts = array() ) { // enqueue scripts and styles - define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } // default args $args = array( @@ -352,7 +356,9 @@ public function displayImages( $atts = array() ) { */ function displayLatestSeriesImage( $atts = array() ) { // enqueue scripts and styles - define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } // default options $args = array( @@ -546,7 +552,9 @@ function getLatestSeriesImageId( $series = 0 ) { */ public function displaySermonSorting( $atts = array() ) { // enqueue scripts and styles - define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } return render_wpfc_sorting(); } diff --git a/includes/widgets.php b/includes/widgets.php index be259d2..5450015 100755 --- a/includes/widgets.php +++ b/includes/widgets.php @@ -20,7 +20,9 @@ public function __construct() { function widget( $args, $instance ) { // enqueue scripts and styles - define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } $cache = wp_cache_get( 'widget_recent_sermons', 'widget' ); diff --git a/readme.txt b/readme.txt index 005263a..1e9a4fe 100755 --- a/readme.txt +++ b/readme.txt @@ -83,6 +83,9 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man 2. Sermon Files == Changelog == += 2.4.7 = +* Fix PHP notice in the footer + = 2.4.6 = * Add a setting to define podcast count * Fix a bug that caused WSOD on some hosts From 88eb2bb7085fbf265a7ad8cb19012b81e7a855d4 Mon Sep 17 00:00:00 2001 From: Nikola Date: Mon, 14 Aug 2017 11:27:30 +0200 Subject: [PATCH 02/10] Force dates fix Closes #55 --- readme.txt | 1 + sermons.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/readme.txt b/readme.txt index 1e9a4fe..1e58b48 100755 --- a/readme.txt +++ b/readme.txt @@ -85,6 +85,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man == Changelog == = 2.4.7 = * Fix PHP notice in the footer +* Force dates fix for users who did not do it yet (there are too many bugs caused by old dates) = 2.4.6 = * Add a setting to define podcast count diff --git a/sermons.php b/sermons.php index 1cb0d73..242257c 100755 --- a/sermons.php +++ b/sermons.php @@ -59,6 +59,74 @@ public function __construct() { add_action( 'pre_get_posts', array( $this, 'fix_sermons_ordering' ), 9999 ); // no idea... better not touch it for now. add_filter( 'sermon-images-disable-public-css', '__return_true' ); + + // force dates fix + $this->fix_dates(); + } + + private function fix_dates() { + if ( intval( get_option( 'wpfc_sm_dates_all_fixed' ) ) === 1 || ! is_admin() ) { + return; + } + + try { + global $wpdb; + $wp_query = new WP_Query( array( + 'post_type' => 'wpfc_sermon', + 'posts_per_page' => - 1, + 'post_status' => 'any' + ) ); + $posts_meta = array(); + + $sermons = $wp_query->posts; + + foreach ( $sermons as $sermon ) { + // get post meta directly from DB. The reason for not using get_post_meta() is that we need meta_id too. + $date = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $sermon->ID, 'sermon_date' ) ); + + // if for some reason, the date is blank or something else, continue to next sermon + if ( empty( $date[0] ) ) { + continue; + } + + // assign first sermon_date meta to $date variable + $date = $date[0]; + + // skip if we need only old dates + if ( is_numeric( $date->meta_value ) ) { + continue; + } + + $posts_meta[] = array( + 'date' => $date->meta_value, + 'meta_id' => $date->meta_id, + 'post_id' => $sermon->ID, + ); + } + + $dates = $posts_meta; + $fixed = 0; + + if ( ! empty( $dates ) ) { + foreach ( $dates as $date ) { + // for backup + update_post_meta( $date['post_id'], 'sermon_date_old', $date['date'] ); + // update the date + update_post_meta( $date['post_id'], 'sermon_date', strtotime( $date['date'] ) ); + // add it to fixed dates + $fixed ++; + } + + update_option( 'wpfc_sm_dates_fixed', $fixed ); + update_option( 'wpfc_sm_dates_remaining', intval( get_option( 'wpfc_sm_dates_total', true ) ) - $fixed ); + } + + update_option( 'wpfc_sm_dates_all_fixed', 1 ); + } catch ( Exception $exception ) { + print_r( $exception ); + die(); + // failed :( + } } /** From 8107b09f05f5ed54735f37d24d2b71c58410924f Mon Sep 17 00:00:00 2001 From: Nikola Date: Mon, 14 Aug 2017 12:03:19 +0200 Subject: [PATCH 03/10] Fix slashes in RSS feed Closes #54 --- includes/podcast-functions.php | 20 ++++++++++---------- readme.txt | 1 + views/wpfc-podcast-feed.php | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/includes/podcast-functions.php b/includes/podcast-functions.php index ebb9ae5..9c315de 100755 --- a/includes/podcast-functions.php +++ b/includes/podcast-functions.php @@ -99,13 +99,13 @@ function wpfc_podcast_add_head() { + stripslashes( wp_filter_kses( wpautop( category_description() ) ), true ) : + stripslashes( wp_filter_nohtml_kses( category_description() ) ) ); ?> + stripslashes( wp_filter_kses( wpautop( \SermonManager::getOption( 'itunes_summary' ) ) ) ) : + stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ) ); ?> @@ -143,8 +143,8 @@ function wpfc_podcast_add_item() { + stripslashes( wp_filter_kses( wpautop( get_wpfc_sermon_meta( 'sermon_description' ) ) ) ) : + stripslashes( wp_filter_nohtml_kses( get_wpfc_sermon_meta( 'sermon_description' ) ) ) ); ?> @@ -174,9 +174,9 @@ function wpfc_podcast_add_item() { */ function wpfc_podcast_summary( $content ) { if ( \SermonManager::getOption( 'enable_podcast_html_description' ) ) { - $content = wpautop( wp_filter_kses( get_wpfc_sermon_meta( 'sermon_description' ) ) ); + $content = stripslashes( wp_filter_kses( wpautop( get_wpfc_sermon_meta( 'sermon_description' ) ) ) ); } else { - $content = wp_filter_nohtml_kses( get_wpfc_sermon_meta( 'sermon_description' ) ); + $content = stripslashes( wp_filter_nohtml_kses( get_wpfc_sermon_meta( 'sermon_description' ) ) ); } return $content; @@ -230,9 +230,9 @@ function wpfc_bloginfo_rss_filter( $info, $show ) { break; case 'description': if ( \SermonManager::getOption( 'enable_podcast_html_description' ) ) { - $new_info = wpautop( wp_filter_kses( \SermonManager::getOption( 'itunes_summary' ) ) ); + $new_info = stripslashes( wp_filter_kses( wpautop( \SermonManager::getOption( 'itunes_summary' ) ) ) ); } else { - $new_info = wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ); + $new_info = stripslashes( wp_filter_nohtml_kses( \SermonManager::getOption( 'itunes_summary' ) ) ); } break; diff --git a/readme.txt b/readme.txt index 1e58b48..e61ba27 100755 --- a/readme.txt +++ b/readme.txt @@ -86,6 +86,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man = 2.4.7 = * Fix PHP notice in the footer * Force dates fix for users who did not do it yet (there are too many bugs caused by old dates) +* Fix slashes in RSS feed = 2.4.6 = * Add a setting to define podcast count diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index 7f30785..5e182c2 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -50,7 +50,7 @@ - ]]> + asd]]> From 2461c20a260c51c59b337eaaa1a93c2c723afbcd Mon Sep 17 00:00:00 2001 From: Nikola Date: Mon, 14 Aug 2017 12:37:31 +0200 Subject: [PATCH 04/10] Fix podcast cover image not selecting Closes #53 --- includes/options.php | 51 +++++++++++++++++++++++++++++--------------- readme.txt | 4 +++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/includes/options.php b/includes/options.php index ceada3e..4f07e97 100755 --- a/includes/options.php +++ b/includes/options.php @@ -31,6 +31,7 @@ function wpfc_init() { } register_setting( 'wpfc_plugin_options', 'wpfc_options', $args ); + wp_enqueue_media(); } // Add menu page @@ -99,17 +100,38 @@ function wpfc_sermon_options_render_form() {