diff --git a/includes/class-sm-background-updater.php b/includes/class-sm-background-updater.php index ebe6189..d18e52a 100644 --- a/includes/class-sm-background-updater.php +++ b/includes/class-sm-background-updater.php @@ -19,46 +19,6 @@ class SM_Background_Updater extends WP_Background_Process { */ protected $action = 'sm_updater'; - /** - * Dispatch updater. - * - * Updater will still run via cron job if this fails for any reason. - */ - public function dispatch() { - parent::dispatch(); - } - - /** - * Handle cron healthcheck - * - * Restart the background process if not already running - * and data exists in the queue. - */ - public function handle_cron_healthcheck() { - if ( $this->is_process_running() ) { - // Background process already running. - return; - } - - if ( $this->is_queue_empty() ) { - // No data to process. - $this->clear_scheduled_event(); - - return; - } - - $this->handle(); - } - - /** - * Schedule fallback event. - */ - protected function schedule_event() { - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { - wp_schedule_event( time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier ); - } - } - /** * Is the updater running? * @@ -85,7 +45,7 @@ protected function task( $callback ) { define( 'SM_UPDATING', true ); } - include_once( dirname( __FILE__ ) . '/sm-update-functions.php' ); + include_once 'sm-update-functions.php'; if ( is_callable( $callback ) ) { call_user_func( $callback ); diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php index 640ee5d..c2c5e7c 100644 --- a/includes/class-sm-install.php +++ b/includes/class-sm-install.php @@ -9,7 +9,7 @@ class SM_Install { /** @var array DB updates and callbacks that need to be run per version */ private static $db_updates = array( - '2.8' => array( + '2.8' => array( 'sm_update_28_revert_old_dates', 'sm_update_28_convert_dates_to_unix', 'sm_update_28_fill_out_empty_dates', @@ -17,8 +17,8 @@ class SM_Install { 'sm_update_28_save_sermon_render_into_post_content', 'sm_update_28_reset_recovery', ), - '2.8.3' => array( - 'sm_update_283_resave_sermons' + '2.8.4' => array( + 'sm_update_284_resave_sermons' ) ); @@ -98,12 +98,15 @@ private static function _install() { * Push all needed DB updates to the queue for processing. */ private static function _update() { - $current_db_version = get_option( 'sm_version' ); - $update_queued = false; + if ( self::$background_updater->is_updating() ) { + return; + } + + $update_queued = false; foreach ( self::_get_db_update_callbacks() as $version => $update_callbacks ) { - if ( version_compare( $current_db_version, $version, '<' ) ) { - foreach ( $update_callbacks as $update_callback ) { + foreach ( $update_callbacks as $update_callback ) { + if ( ! get_option( 'wp_sm_updater_' . $update_callback . '_done' ) ) { self::$background_updater->push_to_queue( $update_callback ); $update_queued = true; } @@ -124,14 +127,6 @@ private static function _get_db_update_callbacks() { return self::$db_updates; } - /** - * Init background updates - */ - public static function init_background_updater() { - include_once 'class-sm-background-updater.php'; - self::$background_updater = new SM_Background_Updater(); - } - /** * Update DB version to current. * @@ -142,6 +137,14 @@ public static function update_db_version( $version = null ) { add_option( 'sm_version', is_null( $version ) ? SM_VERSION : $version ); } + /** + * Init background updates + */ + public static function init_background_updater() { + include_once 'class-sm-background-updater.php'; + self::$background_updater = new SM_Background_Updater(); + } + /** * Add more cron schedules * diff --git a/includes/libraries/wp-background-process.php b/includes/libraries/wp-background-process.php index 1323ee5..f3f59a0 100644 --- a/includes/libraries/wp-background-process.php +++ b/includes/libraries/wp-background-process.php @@ -303,6 +303,7 @@ protected function handle() { $batch->data[ $key ] = $task; } else { unset( $batch->data[ $key ] ); + update_option('wp_sm_updater_' . $value . '_done', 1 ); } if ( $this->time_exceeded() || $this->memory_exceeded() ) { diff --git a/includes/options.php b/includes/options.php index f5b8cb1..a101275 100755 --- a/includes/options.php +++ b/includes/options.php @@ -26,11 +26,11 @@ static function wpfc_validate_options( $input ) { unset( $input['sm_do_not_catch'] ); } else { update_option( '_sm_recovery_do_not_catch', '0' ); - } + } - if ( SermonManager::getOption( 'archive_slug' ) != $input['archive_slug'] || - SermonManager::getOption( 'common_base_slug' ) != $input['common_base_slug'] || - SermonManager::getOption( 'preacher_label' ) != $input['preacher_label'] ) { + if ( SermonManager::getOption( 'archive_slug' ) != $input['archive_slug'] || + SermonManager::getOption( 'common_base_slug' ) != $input['common_base_slug'] || + SermonManager::getOption( 'preacher_label' ) != $input['preacher_label'] ) { update_option( 'sm_flush_rewrite_rules', '1' ); } @@ -43,7 +43,7 @@ static function wpfc_validate_options( $input ) { * @since 2.5.2 */ function maybe_flush_rewrite_rules() { - if ( boolval( get_option( 'sm_flush_rewrite_rules' ) ) ) { + if ( (bool) get_option( 'sm_flush_rewrite_rules' ) ) { flush_rewrite_rules(); update_option( 'sm_flush_rewrite_rules', '0' ); } @@ -167,17 +167,21 @@ function wpfc_sermon_options_render_form() { -

+

+

@@ -186,13 +190,16 @@ function wpfc_sermon_options_render_form() {
-

+

+

' . esc_html__( 'Sign up', 'sermon-manager-for-wordpress' ) . '' ); ?>

  - + target="_blank" + class="button-secondary">  +
@@ -201,7 +208,9 @@ function wpfc_sermon_options_render_form() {
-

+

+ +

- ' . esc_html__( 'knowledge base', 'sermon-manager-for-wordpress' ) . '' ); ?> + ' . esc_html__( 'knowledge base', 'sermon-manager-for-wordpress' ) . '' ); ?>
-

+

+ +

+ target="_blank" + class="button-secondary">
@@ -241,7 +253,9 @@ function wpfc_sermon_options_render_form() {
-

+

+ +

@@ -279,7 +293,7 @@ function wpfc_sermon_options_render_form() {
@@ -371,7 +385,9 @@ function wpfc_sermon_options_render_form() {
-

+

+ +

@@ -411,11 +427,11 @@ function wpfc_sermon_options_render_form() { ESV', - 'NET', - 'KJV', - 'LEB', - '' . esc_html__( 'bib.ly', 'sermon-manager-for-wordpress' ) . '' ); ?> + 'ESV', + 'NET', + 'KJV', + 'LEB', + '' . esc_html__( 'bib.ly', 'sermon-manager-for-wordpress' ) . '' ); ?>
ESV' ); ?>
@@ -426,7 +442,9 @@ function wpfc_sermon_options_render_form() {
-

+

+ +

@@ -462,7 +480,7 @@ function wpfc_sermon_options_render_form() {
@@ -472,7 +490,7 @@ function wpfc_sermon_options_render_form() { @@ -482,7 +500,7 @@ function wpfc_sermon_options_render_form() { @@ -492,12 +510,12 @@ function wpfc_sermon_options_render_form() { @@ -517,7 +535,7 @@ function wpfc_sermon_options_render_form() { @@ -540,7 +558,7 @@ function wpfc_sermon_options_render_form() {

- ' . htmlspecialchars( '©' ) . ''); ?> + ' . htmlspecialchars( '©' ) . '' ); ?>

@@ -553,7 +571,7 @@ function wpfc_sermon_options_render_form() { + placeholder="">

@@ -565,7 +583,7 @@ function wpfc_sermon_options_render_form() {
@@ -578,7 +596,7 @@ function wpfc_sermon_options_render_form() { @@ -676,11 +694,11 @@ class="itunes_cover_image_field"
+ $archive_slug = $options['archive_slug']; + if ( empty( $archive_slug ) ) { + $archive_slug = 'sermons'; + } + echo home_url( '/' ) . $archive_slug; ?>/feed/"/>

' . esc_html__( 'Feed Validator', 'sermon-manager-for-wordpress' ) . '' ); ?> diff --git a/includes/shortcodes.php b/includes/shortcodes.php index b0a8914..988f880 100755 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -302,7 +302,7 @@ public function displayImages( $atts = array() ) { $args = shortcode_atts( $args, $atts, 'sermon_images' ); // convert to bool - $args['show_description'] = boolval( $args['show_description'] ); + $args['show_description'] = (bool) $args['show_description']; // check if we are using a SM taxonomy, and if we are, convert to valid taxonomy name if ( $this->convertTaxonomyName( $args['display'], true ) ) { @@ -425,11 +425,11 @@ function displayLatestSeriesImage( $atts = array() ) { $image = wp_get_attachment_image( $series_image_id, $args['size'], false, array( 'class' => $image_class ) ); $title = $description = ''; - if ( boolval( $args['show_title'] ) === true ) { + if ( (bool) $args['show_title'] === true ) { $title = $latest_series->name; $title = '<' . $args['title_wrapper'] . ' class="' . $title_class . '">' . $title . ''; } - if ( boolval( $args['show_desc'] ) === true ) { + if ( (bool) $args['show_desc'] === true ) { $description = '

' . wpautop( $latest_series->description ) . '
'; } diff --git a/includes/sm-legacy-php-functions.php b/includes/sm-legacy-php-functions.php deleted file mode 100644 index 6cb377c..0000000 --- a/includes/sm-legacy-php-functions.php +++ /dev/null @@ -1,13 +0,0 @@ -get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) ); foreach ( $sermons as $sermon ) { - wp_update_post( array( - 'ID' => $sermon->ID, - 'post_content' => wpfc_sermon_single( true, $sermon ) - ) ); + $post = $sermon; + $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_content = '%s' WHERE ID = $sermon->ID", wpfc_sermon_single( true ) ) ); } + $post = $original_post; + // clear all cached data wp_cache_flush(); } /** - * element was not included in 2.8 save. We allowed it and it will work now + * We had a bug from 2.8 to 2.8.3, so we will do it again */ -function sm_update_283_resave_sermons(){ +function sm_update_284_resave_sermons() { sm_update_28_save_sermon_render_into_post_content(); -} +} \ No newline at end of file diff --git a/readme.txt b/readme.txt index 78a3269..e4945d1 100755 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: church, sermon, sermons, preaching, podcasting, manage, managing, podcasts Requires at least: 4.5 Tested up to: 4.8.2 Requires PHP: 5.3 -Stable tag: 2.8.3 +Stable tag: 2.8.4 License: GPLv2 License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -93,6 +93,12 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man 2. Sermon Files ## Changelog ## +### 2.8.4 ### +* Fix sermons having to be resaved to work +* Fix fatal error when using plugin views +* Fix update functions being executed multiple times +* Fix update functions not being executed for users who skip versions + ### 2.8.3 ### * Fix sermon audio not showing up * Fix sermon not updating on first save diff --git a/sermons.php b/sermons.php index 94c0476..de9b513 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.8.3 + * Version: 2.8.4 * Author: WP for Church * Author URI: https://www.wpforchurch.com/ * Requires at least: 4.5 @@ -124,7 +124,6 @@ private function _includes() { 'includes/class-sm-install.php', // Install and update functions 'includes/sm-deprecated-functions.php', // Deprecated SM functions 'includes/sm-core-functions.php', // Deprecated SM functions - 'includes/sm-legacy-php-functions.php', // Old PHP compatibility fixes 'includes/sm-cmb-functions.php', // CMB2 Meta Fields functions 'includes/taxonomy-images/taxonomy-images.php', // Images for Custom Taxonomies 'includes/entry-views.php', // Entry Views Tracking @@ -385,10 +384,8 @@ public function render_sermon_into_content( $post_ID, $post ) { define( 'SM_SAVING_POST', 1 ); } - wp_update_post( array( - 'ID' => $post_ID, - 'post_content' => wpfc_sermon_single( true ) - ) ); + global $wpdb; + $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_content = '%s' WHERE ID = $post_ID", wpfc_sermon_single( true ) ) ); } /** diff --git a/views/archive-wpfc_sermon.php b/views/archive-wpfc_sermon.php index 5d07242..4b53045 100644 --- a/views/archive-wpfc_sermon.php +++ b/views/archive-wpfc_sermon.php @@ -56,8 +56,8 @@
- ID ); ?> - + ID ); ?> + approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>
diff --git a/views/taxonomy-wpfc_bible_book.php b/views/taxonomy-wpfc_bible_book.php index ce8bdd2..9496af8 100644 --- a/views/taxonomy-wpfc_bible_book.php +++ b/views/taxonomy-wpfc_bible_book.php @@ -84,9 +84,9 @@ class="meta-sep"> by ID, 'wpfc_preacher', '
- ID ); ?> + ID ); ?> + class="comments-link">approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>
diff --git a/views/taxonomy-wpfc_preacher.php b/views/taxonomy-wpfc_preacher.php index 436835f..e815023 100644 --- a/views/taxonomy-wpfc_preacher.php +++ b/views/taxonomy-wpfc_preacher.php @@ -90,9 +90,9 @@ class="meta-sep"> by ID, 'wpfc_preacher', '
- ID ); ?> + ID ); ?> + class="comments-link">approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>
diff --git a/views/taxonomy-wpfc_sermon_series.php b/views/taxonomy-wpfc_sermon_series.php index a6d186b..27c18b8 100644 --- a/views/taxonomy-wpfc_sermon_series.php +++ b/views/taxonomy-wpfc_sermon_series.php @@ -91,9 +91,9 @@ class="meta-sep"> by ID, 'wpfc_preacher', '
- ID ); ?> + ID ); ?> + class="comments-link">approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>
diff --git a/views/taxonomy-wpfc_sermon_topics.php b/views/taxonomy-wpfc_sermon_topics.php index 09273de..ecc1433 100644 --- a/views/taxonomy-wpfc_sermon_topics.php +++ b/views/taxonomy-wpfc_sermon_topics.php @@ -91,9 +91,9 @@ class="meta-sep"> by ID, 'wpfc_preacher', '
- ID ); ?> + ID ); ?> + class="comments-link">approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>
diff --git a/views/taxonomy-wpfc_service_type.php b/views/taxonomy-wpfc_service_type.php index 923d1e7..7595f32 100644 --- a/views/taxonomy-wpfc_service_type.php +++ b/views/taxonomy-wpfc_service_type.php @@ -84,9 +84,9 @@ class="meta-sep"> by ID, 'wpfc_preacher', '
- ID ); ?> + ID ); ?> + class="comments-link">approved ), 'sermon-manager-for-wordpress' ) ), number_format_i18n( $approved_comments_count ) ) ); ?> | ', '' ); ?>