'; + break; default: echo apply_filters( 'sm_templates_wrapper_start', '
' ); break; From 336cdcf9be1ceeaa567aadf8a071eb20158bcc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 16:25:18 +0200 Subject: [PATCH 16/22] Fix memory leak during getting of next/previous sermon --- includes/sm-core-functions.php | 44 +++++----------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/includes/sm-core-functions.php b/includes/sm-core-functions.php index 27960e9..fed0f97 100644 --- a/includes/sm-core-functions.php +++ b/includes/sm-core-functions.php @@ -783,30 +783,14 @@ function sm_get_previous_sermon( $post = null ) { _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post.', '2.12.5' ); } - $current_sermon_id = $post->ID; - - $query = new WP_Query( array( - 'post_type' => 'wpfc_sermon', - 'meta_key' => 'sermon_date', - 'meta_value_num' => time(), - 'meta_compare' => '<=', - 'orderby' => 'meta_value_num', - 'order' => 'DESC', - 'posts_per_page' => - 1, - ) ); - - for ( $p = 0; $p < count( $query->posts ); $p ++ ) { - if ( $query->posts[ $p ]->ID === $current_sermon_id ) { - $the_post = isset( $query->posts[ $p - 1 ] ) ? $query->posts[ $p - 1 ] : null; - } - } + $the_post = get_previous_post(); /** * Allows to filter the return value. * * @param $the_post WP_Post|null The post if found. */ - return apply_filters( 'sm_get_previous_sermon', isset( $the_post ) ? $the_post : null ); + return apply_filters( 'sm_get_previous_sermon', empty( $the_post ) ? null : $the_post ); } /** @@ -819,38 +803,22 @@ function sm_get_previous_sermon( $post = null ) { * @return WP_Post|null The sermon if found, null otherwise. */ function sm_get_next_sermon( $post = null ) { - if ( $post === null ) { + if ( null === $post ) { global $post; } - if ( ! $post instanceof WP_Post || $post->post_type !== 'wpfc_sermon' ) { + if ( ! $post instanceof WP_Post || 'wpfc_sermon' !== $post->post_type ) { _doing_it_wrong( __FUNCTION__, '$post must be an instance of WP_Post.', '2.12.5' ); } - $current_sermon_id = $post->ID; - - $query = new WP_Query( array( - 'post_type' => 'wpfc_sermon', - 'meta_key' => 'sermon_date', - 'meta_value_num' => time(), - 'meta_compare' => '<=', - 'orderby' => 'meta_value_num', - 'order' => 'DESC', - 'posts_per_page' => - 1, - ) ); - - for ( $p = 0; $p < count( $query->posts ); $p ++ ) { - if ( $query->posts[ $p ]->ID === $current_sermon_id ) { - $the_post = isset( $query->posts[ $p + 1 ] ) ? $query->posts[ $p + 1 ] : null; - } - } + $the_post = get_next_post(); /** * Allows to filter the return value. * * @param $the_post WP_Post|null The post if found. */ - return apply_filters( 'sm_get_next_sermon', isset( $the_post ) ? $the_post : null ); + return apply_filters( 'sm_get_next_sermon', empty( $the_post ) ? null : $the_post ); } /** From 35f2f06a114e087347e0ebd5fdad45b190483087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 16:25:46 +0200 Subject: [PATCH 17/22] Update header in view files to be more precise --- views/partials/content-sermon-archive.php | 2 +- views/partials/content-sermon-attachments.php | 2 +- views/partials/content-sermon-filtering.php | 2 +- views/partials/content-sermon-single.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/views/partials/content-sermon-archive.php b/views/partials/content-sermon-archive.php index 42cf5e3..06668c3 100644 --- a/views/partials/content-sermon-archive.php +++ b/views/partials/content-sermon-archive.php @@ -1,6 +1,6 @@ /partials/content-sermon-archive.php` * - `/wp-content/themes//template-parts/content-sermon-archive.php` * - `/wp-content/themes//content-sermon-archive.php` diff --git a/views/partials/content-sermon-attachments.php b/views/partials/content-sermon-attachments.php index 265d5f6..ab63973 100644 --- a/views/partials/content-sermon-attachments.php +++ b/views/partials/content-sermon-attachments.php @@ -1,6 +1,6 @@ /partials/content-sermon-attachments.php` * - `/wp-content/themes//template-parts/content-sermon-attachments.php` * - `/wp-content/themes//content-sermon-attachments.php` diff --git a/views/partials/content-sermon-filtering.php b/views/partials/content-sermon-filtering.php index 7754239..c67c233 100644 --- a/views/partials/content-sermon-filtering.php +++ b/views/partials/content-sermon-filtering.php @@ -1,6 +1,6 @@ /partials/content-sermon-filtering.php` * - `/wp-content/themes//template-parts/content-sermon-filtering.php` * - `/wp-content/themes//content-sermon-filtering.php` diff --git a/views/partials/content-sermon-single.php b/views/partials/content-sermon-single.php index b722166..56e34a1 100644 --- a/views/partials/content-sermon-single.php +++ b/views/partials/content-sermon-single.php @@ -1,6 +1,6 @@ /partials/content-sermon-single.php` * - `/wp-content/themes//template-parts/content-sermon-single.php` * - `/wp-content/themes//content-sermon-single.php` From 6cdac62a6b75fa6f5e16f1bea29b01a7713517c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 16:26:09 +0200 Subject: [PATCH 18/22] Move SM after plugin load action at the end of the actions --- sermons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sermons.php b/sermons.php index 65f083c..c6e2850 100755 --- a/sermons.php +++ b/sermons.php @@ -235,8 +235,6 @@ public function __construct() { return 'no'; } ); - do_action( 'sm_after_plugin_load' ); - add_action( 'sm_admin_settings_sanitize_option_post_content_enabled', function ( $value ) { $value = intval( $value ); @@ -267,6 +265,8 @@ public function __construct() { return $value; } ); + + do_action( 'sm_after_plugin_load' ); } /** From 655d379ae4073ba008c7d71e2db62de20295d4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 16:26:44 +0200 Subject: [PATCH 19/22] Update changelog --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 59b1912..304996e 100755 --- a/readme.txt +++ b/readme.txt @@ -107,6 +107,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man * New: Add an option to show date "Published" instead of date "Preached" in feed and frontend * Fix: Excerpt meta box not showing up * Fix: Fix description not showing in the podcast feed +* Fix: Fix memory leak when site has big number of sermons * Change: Use native player in Safari * Change: Separate "Preached" and "Published" dates in admin view From 9f9b12633239c841668212e3883234ee45cefdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 16:36:01 +0200 Subject: [PATCH 20/22] Use non-localized dates in the RSS feed --- includes/class-sm-dates.php | 5 +++-- readme.txt | 1 + views/wpfc-podcast-feed.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/class-sm-dates.php b/includes/class-sm-dates.php index a88f187..3252960 100644 --- a/includes/class-sm-dates.php +++ b/includes/class-sm-dates.php @@ -28,10 +28,11 @@ class SM_Dates { * @param bool $force_unix_sanitation Optional. Sanitation is done only if Sermon Manager is older than 2.6, * we are assuming that newer (2.6>) Sermon Manager versions will save * the date as Unix timestamp so sanitation is not required. + * @param bool $localize If set to false, it will skip date localization. Default true. * * @return string|false Date when sermon was preached. False on failure. */ - public static function get( $format = '', $post = null, $force_unix_sanitation = false ) { + public static function get( $format = '', $post = null, $force_unix_sanitation = false, $localize = true ) { // Reset the variable. $has_time = false; $sanitized = false; @@ -99,7 +100,7 @@ public static function get( $format = '', $post = null, $force_unix_sanitation = } // Format it. - $date = date_i18n( $format, $date ); + $date = $localize ? date_i18n( $format, $date ) : date( $format, $date ); /** * Filters the date a post was preached diff --git a/readme.txt b/readme.txt index 304996e..785fcf8 100755 --- a/readme.txt +++ b/readme.txt @@ -108,6 +108,7 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man * Fix: Excerpt meta box not showing up * Fix: Fix description not showing in the podcast feed * Fix: Fix memory leak when site has big number of sermons +* Fix: Use non-localized dates in the RSS feed * Change: Use native player in Safari * Change: Separate "Preached" and "Published" dates in admin view diff --git a/views/wpfc-podcast-feed.php b/views/wpfc-podcast-feed.php index f41daed..f08dadc 100644 --- a/views/wpfc-podcast-feed.php +++ b/views/wpfc-podcast-feed.php @@ -156,7 +156,7 @@ $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 ) ) ); - $date_preached = SM_Dates::get( 'D, d M Y H:i:s +0000' ); + $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 ); // Fix for relative audio file URLs. From c54e717b4918c64442a09b14ab64ae8eac609ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 18:44:03 +0200 Subject: [PATCH 21/22] Fix issues with Sermon Browser importing --- .../css/admin-partials/_add-edit-sermon.scss | 8 ++ assets/css/admin.min.css | 2 +- assets/css/admin.min.css.map | 2 +- includes/admin/import/class-sm-import-sb.php | 104 +++++++++++++----- .../includes/types/CMB2_Type_Text_Date.php | 1 + readme.txt | 5 +- 6 files changed, 93 insertions(+), 29 deletions(-) diff --git a/assets/css/admin-partials/_add-edit-sermon.scss b/assets/css/admin-partials/_add-edit-sermon.scss index f398d7b..aceb4da 100644 --- a/assets/css/admin-partials/_add-edit-sermon.scss +++ b/assets/css/admin-partials/_add-edit-sermon.scss @@ -1,3 +1,11 @@ #sermon_video_link { width: 25em; +} + +#sermon_date { + width: 125px; + + &::placeholder{ + color: #ccc; + } } \ No newline at end of file diff --git a/assets/css/admin.min.css b/assets/css/admin.min.css index 7465973..6cca6ed 100644 --- a/assets/css/admin.min.css +++ b/assets/css/admin.min.css @@ -1,2 +1,2 @@ -body.edit-php.post-type-wpfc_sermon .fixed .column-preacher,body.edit-php.post-type-wpfc_sermon .fixed .column-preached{width:10%}body.edit-php.post-type-wpfc_sermon .fixed .column-series,body.edit-php.post-type-wpfc_sermon .fixed .column-topics{width:15%}body.edit-php.post-type-wpfc_sermon .fixed .column-views{width:7%}body.wpfc_sermon_page_sm-settings .wp-heading-inline{margin-bottom:5px}body.wpfc_sermon_page_sm-settings .settings-main{display:flex;margin-top:5px}body.wpfc_sermon_page_sm-settings .settings-content{width:100%}body.wpfc_sermon_page_sm-settings .settings-content #mainform{border:1px solid #e8e8e8}body.wpfc_sermon_page_sm-settings .settings-content span.description{display:block;margin-top:5px}body.wpfc_sermon_page_sm-settings .settings-content input[type=text],body.wpfc_sermon_page_sm-settings .settings-content input[type=email]{width:100%;max-width:400px}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper{background:white;padding:0;border-bottom:1px solid #e8e8e8}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab{float:none;border:none;margin:0;padding:20px 20px;display:inline-block;background:none;font-weight:normal;color:#666;font-size:13px}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:hover,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:focus{border-bottom:2px solid #ccc;outline:none;box-shadow:none}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus:active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:hover{border-bottom:2px solid #4abcf0}body.wpfc_sermon_page_sm-settings .settings-content .inside{padding:.2rem 1rem .01rem 1rem;background:white}body.wpfc_sermon_page_sm-settings .settings-side{width:30%;max-width:300px;margin-left:1rem}body.wpfc_sermon_page_sm-settings .settings-side .sm-box h3{margin-left:.8rem}body.wpfc_sermon_page_sm-settings .settings-side .sm-box .description{text-align:center;font-size:0.85em;padding:0.4rem 0 0}body.wpfc_sermon_page_sm-settings .settings-side .sm-box ol{list-style-type:circle}body.wpfc_sermon_page_sm-import-export .wp-list-table{overflow:hidden;height:100%}body.wpfc_sermon_page_sm-import-export .plugin-card{position:relative}body.wpfc_sermon_page_sm-import-export .plugin-card>h2{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%);z-index:1;color:#4a4a4a !important;margin:0;font-size:1.7rem;font-weight:100;letter-spacing:2px;font-family:'Roboto', sans-serif;text-transform:uppercase;opacity:0;transition:opacity .2s;cursor:default;width:100%;text-align:center}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:before{content:"";background:repeating-linear-gradient(45deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05) 10px, rgba(0,0,0,0.1) 10px, rgba(0,0,0,0.1) 20px);width:100%;height:100%;position:absolute;left:0;top:0;z-index:1}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover>h2{opacity:1}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover .plugin-card-top{-webkit-filter:blur(1px);filter:blur(1px)}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available *{color:#ccc}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available .plugin-icon{filter:opacity(0.2)}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top{padding:0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top:hover .import-note{display:block}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-note{display:none;color:rgba(0,0,0,0.5)}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name{margin-top:20px}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .desc,body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name{margin-left:185px}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .action-links{top:0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon{font-size:5rem;color:#656565;left:0;top:0;height:168px;width:168px;margin:-20px 20px 0 0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon.dashicons{margin-top:1rem}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .wp-upload-form{display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper{line-height:1;vertical-align:middle;width:13px;position:relative;top:-1px;display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper img{max-width:100%}body.post-php.post-type-wpfc_sermon #sermon_video_link{width:25em} +body.edit-php.post-type-wpfc_sermon .fixed .column-preacher,body.edit-php.post-type-wpfc_sermon .fixed .column-preached{width:10%}body.edit-php.post-type-wpfc_sermon .fixed .column-series,body.edit-php.post-type-wpfc_sermon .fixed .column-topics{width:15%}body.edit-php.post-type-wpfc_sermon .fixed .column-views{width:7%}body.wpfc_sermon_page_sm-settings .wp-heading-inline{margin-bottom:5px}body.wpfc_sermon_page_sm-settings .settings-main{display:flex;margin-top:5px}body.wpfc_sermon_page_sm-settings .settings-content{width:100%}body.wpfc_sermon_page_sm-settings .settings-content #mainform{border:1px solid #e8e8e8}body.wpfc_sermon_page_sm-settings .settings-content span.description{display:block;margin-top:5px}body.wpfc_sermon_page_sm-settings .settings-content input[type=text],body.wpfc_sermon_page_sm-settings .settings-content input[type=email]{width:100%;max-width:400px}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper{background:white;padding:0;border-bottom:1px solid #e8e8e8}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab{float:none;border:none;margin:0;padding:20px 20px;display:inline-block;background:none;font-weight:normal;color:#666;font-size:13px}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:hover,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab:focus{border-bottom:2px solid #ccc;outline:none;box-shadow:none}body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:focus:active,body.wpfc_sermon_page_sm-settings .settings-content .sm-nav-tab-wrapper .nav-tab-active:hover{border-bottom:2px solid #4abcf0}body.wpfc_sermon_page_sm-settings .settings-content .inside{padding:.2rem 1rem .01rem 1rem;background:white}body.wpfc_sermon_page_sm-settings .settings-side{width:30%;max-width:300px;margin-left:1rem}body.wpfc_sermon_page_sm-settings .settings-side .sm-box h3{margin-left:.8rem}body.wpfc_sermon_page_sm-settings .settings-side .sm-box .description{text-align:center;font-size:0.85em;padding:0.4rem 0 0}body.wpfc_sermon_page_sm-settings .settings-side .sm-box ol{list-style-type:circle}body.wpfc_sermon_page_sm-import-export .wp-list-table{overflow:hidden;height:100%}body.wpfc_sermon_page_sm-import-export .plugin-card{position:relative}body.wpfc_sermon_page_sm-import-export .plugin-card>h2{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%);z-index:1;color:#4a4a4a !important;margin:0;font-size:1.7rem;font-weight:100;letter-spacing:2px;font-family:'Roboto', sans-serif;text-transform:uppercase;opacity:0;transition:opacity .2s;cursor:default;width:100%;text-align:center}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:before{content:"";background:repeating-linear-gradient(45deg, rgba(0,0,0,0.05), rgba(0,0,0,0.05) 10px, rgba(0,0,0,0.1) 10px, rgba(0,0,0,0.1) 20px);width:100%;height:100%;position:absolute;left:0;top:0;z-index:1}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover>h2{opacity:1}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available:hover .plugin-card-top{-webkit-filter:blur(1px);filter:blur(1px)}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available *{color:#ccc}body.wpfc_sermon_page_sm-import-export .plugin-card.not-available .plugin-icon{filter:opacity(0.2)}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top{padding:0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top:hover .import-note{display:block}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-note{display:none;color:rgba(0,0,0,0.5)}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name{margin-top:20px}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .desc,body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .name{margin-left:185px}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .action-links{top:0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon{font-size:5rem;color:#656565;left:0;top:0;height:168px;width:168px;margin:-20px 20px 0 0}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .plugin-icon.dashicons{margin-top:1rem}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .wp-upload-form{display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper{line-height:1;vertical-align:middle;width:13px;position:relative;top:-1px;display:none}body.wpfc_sermon_page_sm-import-export .plugin-card .plugin-card-top .import-sniper img{max-width:100%}body.post-php.post-type-wpfc_sermon #sermon_video_link{width:25em}body.post-php.post-type-wpfc_sermon #sermon_date{width:125px}body.post-php.post-type-wpfc_sermon #sermon_date::placeholder{color:#ccc} /*# sourceMappingURL=admin.min.css.map */ diff --git a/assets/css/admin.min.css.map b/assets/css/admin.min.css.map index 44da695..8da462a 100644 --- a/assets/css/admin.min.css.map +++ b/assets/css/admin.min.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AACE,uHAAmC,CACjC,KAAK,CAAE,GAAG,CAGZ,mHAA+B,CAC7B,KAAK,CAAE,GAAG,CAGZ,wDAAc,CACZ,KAAK,CAAE,EAAE,CCVb,oDAAmB,CACjB,aAAa,CAAE,GAAG,CAGpB,gDAAe,CACb,OAAO,CAAE,IAAI,CACb,UAAU,CAAE,GAAG,CAGjB,mDAAkB,CAChB,K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AAE,IAAI,CACf,KAAK,CAAE,OAAO,CACd,IAAI,CAAE,CAAC,CACP,GAAG,CAAE,CAAC,CACN,MAAM,CAAE,KAAK,CACb,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,cAAc,CAEtB,2FAAY,CACV,UAAU,CAAE,IAAI,CAIpB,oFAAgB,CACd,OAAO,CAAE,IAAI,CAGf,mFAAe,CACb,WAAW,CAAE,CAAC,CACd,cAAc,CAAE,MAAM,CACtB,KAAK,CAAE,IAAI,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,IAAI,CACT,OAAO,CAAE,IAAI,CACb,uFAAI,CACF,SAAS,CAAE,IAAI,CC9GvB,sDAAmB,CACjB,KAAK,CAAE,IAAI,CAGb,gDAAa,CACX,KAAK,CAAE,KAAK,CAEZ,6DAAc,CACZ,KAAK,CAAE,IAAI", "sources": ["admin-partials/_all-sermons.scss","admin-partials/_settings.scss","admin-partials/_import-export.scss","admin-partials/_add-edit-sermon.scss"], "names": [], "file": "admin.min.css" diff --git a/includes/admin/import/class-sm-import-sb.php b/includes/admin/import/class-sm-import-sb.php index cf6f389..89958e3 100644 --- a/includes/admin/import/class-sm-import-sb.php +++ b/includes/admin/import/class-sm-import-sb.php @@ -257,12 +257,15 @@ private function _import_preachers() { if ( '' !== $preacher->image ) { // Set image. - $media = wp_get_upload_dir(); - $attachment_id = sm_import_and_set_post_thumbnail( $media['baseurl'] . '/sermons/images/' . $preacher->image, 0 ); - if ( is_int( $attachment_id ) ) { - $assigned_images = get_option( 'sermon_image_plugin' ); - $assigned_images[ $term_data['term_id'] ] = $attachment_id; - update_option( 'sermon_image_plugin', $assigned_images ); + $media = wp_get_upload_dir(); + + if ( file_exists( $media['basedir'] . '/sermons/images/' . $preacher->image ) ) { + $attachment_id = sm_import_and_set_post_thumbnail( $media['baseurl'] . '/sermons/images/' . $preacher->image, 0 ); + if ( is_int( $attachment_id ) ) { + $assigned_images = get_option( 'sermon_image_plugin' ); + $assigned_images[ $term_data['term_id'] ] = $attachment_id; + update_option( 'sermon_image_plugin', $assigned_images ); + } } } @@ -379,7 +382,7 @@ private function _import_sermons() { $sermons = apply_filters( 'sm_import_sb_messages', $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}sb_sermons" ) ); ob_start(); - print_r( $sermons ); + //print_r( $sermons ); $this->log( 'Raw sermon data: Show data', 0 ); @@ -394,6 +397,10 @@ private function _import_sermons() { 'comment_status' => SermonManager::getOption( 'import_disallow_comments' ) ? 'closed' : 'open', ) ) ); + $imported[ $sermon->id ] = array( + 'new_id' => $id, + ); + if ( 0 === $id || $id instanceof WP_Error ) { // Skip if error. $this->log( 'Sermon "' . $sermon->title . '" could not be imported. (error data: ' . serialize( $id ) . ')', 2 ); @@ -402,10 +409,6 @@ private function _import_sermons() { $this->log( ' • Sermon "' . $sermon->title . '" imported. (ID: ' . $imported[ $sermon->id ]['new_id'] . ')', 255 ); } - $imported[ $sermon->id ] = array( - 'new_id' => $id, - ); - /** * We write it after each insert in case that we get fatal error later. * We don't want to import sermons twice, it would be a mess. @@ -435,29 +438,80 @@ private function _import_sermons() { foreach ( $stuff as $item ) { $url = $item->name; - if ( in_array( pathinfo( $url, PATHINFO_EXTENSION ), array( 'mp3', 'wav', 'ogg' ) ) ) { - $this->log( 'Found an audio file! ("' . $url . '")', 253 ); + if ( 'file' === $item->type || 'url' === $item->type ) { if ( parse_url( $url, PHP_URL_SCHEME ) === null ) { $url = site_url( ( ! empty( $options['upload_dir'] ) ? $options['upload_dir'] : 'wp-content/uploads/sermons/' ) . rawurlencode( $url ) ); - $this->log( 'Audio URL is local, created a full URL. ("' . $url . '")', 253 ); + $this->log( 'File URL is local, created a full URL. ("' . $url . '")', 253 ); + } + + switch ( pathinfo( $url, PATHINFO_EXTENSION ) ) { + case 'mp3': + case 'wav': + case 'ogg': + case 'wma': + $this->log( 'Found an audio file! ("' . $url . '")', 253 ); + + update_post_meta( $id, 'sermon_audio', $url ); + break; + case 'mp4': + case 'avi': + case 'wmv': + case 'mov': + case 'divx': + $this->log( 'Found an video file! ("' . $url . '")', 253 ); + + update_post_meta( $id, 'sermon_video_link', $url ); + break; + case 'doc': + case 'docx': + case 'rtf': + case 'txt': + $this->log( 'Found sermon notes! ("' . $url . '")', 253 ); + + update_post_meta( $id, 'sermon_notes', $url ); + break; + case 'ppt': + case 'pptx': + case 'pdf': + case 'xls': + case 'xlsx': + $this->log( 'Found sermon bulletin! ("' . $url . '")', 253 ); + + update_post_meta( $id, 'sermon_bulletin', $url ); + break; + default: + if ( strpos( $url, 'vimeo.com' ) !== false ) { + $this->log( 'Found an video URL! ("' . $url . '")', 253 ); + + update_post_meta( $id, 'sermon_video_link', $url ); + break; + } } + } elseif ( 'code' === $item->type ) { + $this->log( 'Found video embed!', 253 ); - update_post_meta( $id, 'sermon_audio', $url ); - break; + update_post_meta( $id, 'sermon_video', base64_decode( $item->name ) ); } } - // Set speaker. - wp_set_object_terms( $id, intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 'wpfc_preacher' ); - $this->log( 'Assigned preacher with ID ' . intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 253 ); + if ( ! empty( $this->_imported_preachers[ intval( $sermon->preacher_id ) ] ) ) { + // Set speaker. + wp_set_object_terms( $id, intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 'wpfc_preacher' ); + $this->log( 'Assigned preacher with ID ' . intval( $this->_imported_preachers[ intval( $sermon->preacher_id ) ]['new_id'] ), 253 ); + } - // Set service type. - wp_set_object_terms( $id, intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 'wpfc_service_type' ); - $this->log( 'Assigned service type with ID ' . intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 253 ); + if ( ! empty( $this->_imported_service_types[ intval( $sermon->service_id ) ] ) ) { + // Set service type. + wp_set_object_terms( $id, intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 'wpfc_service_type' ); + update_post_meta( $id, 'wpfc_service_type', intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ) ); + $this->log( 'Assigned service type with ID ' . intval( $this->_imported_service_types[ intval( $sermon->service_id ) ]['new_id'] ), 253 ); + } - // Set series. - wp_set_object_terms( $id, intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 'wpfc_sermon_series' ); - $this->log( 'Assigned series with ID ' . intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 253 ); + if ( ! empty( $this->_imported_series[ intval( $sermon->series_id ) ] ) ) { + // Set series. + wp_set_object_terms( $id, intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 'wpfc_sermon_series' ); + $this->log( 'Assigned series with ID ' . intval( $this->_imported_series[ intval( $sermon->series_id ) ]['new_id'] ), 253 ); + } // Set description. update_post_meta( $id, 'sermon_description', $sermon->description ); diff --git a/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php index 1ff0c3e..a63698d 100755 --- a/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php +++ b/includes/vendor/CMB2/includes/types/CMB2_Type_Text_Date.php @@ -18,6 +18,7 @@ public function render( $args = array() ) { $args = $this->parse_args( 'text_date', array( 'class' => 'cmb2-text-small cmb2-datepicker', 'value' => isset( $_GET['post'] ) ? ( get_post_meta( $_GET['post'], 'sermon_date_auto', true ) ? '' : $this->field->get_timestamp_format() ) : '', + 'placeholder' => isset( $_GET['post'] ) ? get_post_meta( $_GET['post'], 'sermon_date_auto', true) ? 'Same as Published' : '' : '', 'desc' => $this->_desc(), 'js_dependencies' => array( 'jquery-ui-core', 'jquery-ui-datepicker' ), ) ); diff --git a/readme.txt b/readme.txt index 785fcf8..377890e 100755 --- a/readme.txt +++ b/readme.txt @@ -105,12 +105,13 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man ## Changelog ## ### 2.13.2 ### * New: Add an option to show date "Published" instead of date "Preached" in feed and frontend +* Change: Use native player in Safari +* Change: Separate "Preached" and "Published" dates in admin view * Fix: Excerpt meta box not showing up * Fix: Fix description not showing in the podcast feed * Fix: Fix memory leak when site has big number of sermons * Fix: Use non-localized dates in the RSS feed -* Change: Use native player in Safari -* Change: Separate "Preached" and "Published" dates in admin view +* Fix: Fix issues with Sermon Browser importing ### 2.13.1 ### * New: Add `list_podcasts` shortcode (thanks @macbookandrew!) From 2e6988ec900312b7d1dbecc385b54bc21a084559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Miljkovi=C4=87?= Date: Mon, 6 Aug 2018 18:53:37 +0200 Subject: [PATCH 22/22] Update version --- readme.txt | 2 +- sermons.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 377890e..1dfebb1 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.13.1 +Stable tag: 2.13.2 License: GPLv2 License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/sermons.php b/sermons.php index c6e2850..fc17fa4 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.13.1 + * Version: 2.13.2 * Author: WP for Church * Author URI: https://www.wpforchurch.com/ * Requires at least: 4.5