diff --git a/assets/css/admin-icon.css b/assets/css/admin-icon.css new file mode 100644 index 0000000..57dfbd4 --- /dev/null +++ b/assets/css/admin-icon.css @@ -0,0 +1,9 @@ +.dashicons-sermon-manager:before { + font-family: "SermonManager"; + content: "\e900"; } + +@font-face { + font-family: SermonManager; + src: url(../fonts/Sermon-Manager.ttf); } + +/*# sourceMappingURL=admin-icon.css.map */ diff --git a/assets/css/admin-icon.css.map b/assets/css/admin-icon.css.map new file mode 100644 index 0000000..4fa13d9 --- /dev/null +++ b/assets/css/admin-icon.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAAA,gCAAiC;EAC/B,WAAW,EAAE,eAAe;EAC5B,OAAO,EAAE,OAAO;;AAGlB,UAGC;EAFC,WAAW,EAAE,aAAa;EAC1B,GAAG,EAAE,gCAAgC", +"sources": ["admin-icon.scss"], +"names": [], +"file": "admin-icon.css" +} \ No newline at end of file diff --git a/assets/css/admin-icon.scss b/assets/css/admin-icon.scss new file mode 100644 index 0000000..fe337b2 --- /dev/null +++ b/assets/css/admin-icon.scss @@ -0,0 +1,9 @@ +.dashicons-sermon-manager:before { + font-family: "SermonManager"; + content: "\e900"; +} + +@font-face { + font-family: SermonManager; + src: url(../fonts/Sermon-Manager.ttf); +} \ No newline at end of file diff --git a/css/bibly.min.css b/assets/css/bibly.min.css similarity index 100% rename from css/bibly.min.css rename to assets/css/bibly.min.css diff --git a/css/error-recovery.css b/assets/css/error-recovery.css similarity index 100% rename from css/error-recovery.css rename to assets/css/error-recovery.css diff --git a/css/error-recovery.css.map b/assets/css/error-recovery.css.map similarity index 100% rename from css/error-recovery.css.map rename to assets/css/error-recovery.css.map diff --git a/css/error-recovery.scss b/assets/css/error-recovery.scss similarity index 100% rename from css/error-recovery.scss rename to assets/css/error-recovery.scss diff --git a/css/plyr.css b/assets/css/plyr.css similarity index 100% rename from css/plyr.css rename to assets/css/plyr.css diff --git a/css/sermon.css b/assets/css/sermon.css similarity index 95% rename from css/sermon.css rename to assets/css/sermon.css index 630222a..87a301c 100755 --- a/css/sermon.css +++ b/assets/css/sermon.css @@ -1,322 +1,322 @@ -/* Sermon Manager CSS http://www.wpforchurch.com/products/sermon-manager-for-wordpress/ */ - -.single-wpfc_sermon .wpfc_sermon_image { - margin: 10px 0 10px; -} - -.wpfc_sermon_image_wide { - max-width: 100%; - float: left; -} - -.wpfc_sermon_image_wide img { - max-width: 100%; - height: auto; - margin: 0 0 10px 0; -} - -.wpfc_sermon_image { - max-width: 100%; - float: left; -} - -.wpfc_sermon_image img { - max-width: 100%; - height: auto; - margin: 0 10px 0 !important; -} - -.wpfc_sermon_wrap { - padding-bottom: 20px; - clear: both; -} - -#wpfc_sermon_sorting form { - display: inline; - margin: 0 10px 10px 0; -} - -.single-wpfc_sermon .wpfc_sermon_wrap { - padding-bottom: 0px; -} - -.wpfc_sermon_meta p { - margin: 0 !important; -} - -.sermon_date, .service_type { - text-transform: uppercase; - font-size: 12px; -} - -.sermon_series:before { - clear: left; -} - -#wpfc_sermon_tax_desc:after { - content: "."; - visibility: hidden; - display: block; - height: 0; - clear: right; -} - -/* controls padding around video embeds */ -.wpfc_sermon-video { - margin: 10px 0 10px; - max-width: 100%; - clear: both; -} - -.wpfc_sermon-video iframe, .wpfc_sermon-video embed, .wpfc_sermon-video-link iframe { - max-width: 100%; -} - -.mejs-container, #wpfc_sermon iframe, #wpfc_sermon object, #wpfc_sermon embed { - max-width: 100%; -} - -.wpfc_sermon-notes, -.wpfc_sermon-bulletin { - margin: 10px 0 10px; -} - -/* controls padding around audio player */ -.wpfc_sermon-audio { - margin: 10px 0 10px; - max-width: 500px; - clear: both; -} - -#wpfc_sermon_sorting { - padding: 10px 0 10px; -} - -/* Some clearfix code from HTML5 Boilerplate */ -.cf:before, .cf:after { - content: "\0020"; - display: block; - height: 0; - visibility: hidden; -} - -.cf:after { - clear: both; -} - -.cf { - zoom: 1; -} - -/* Recent Sermon Widget */ -.widget_recent_sermons ul { - margin-left: 0px !important; -} - -.widget_recent_sermons .dashicons-microphone { - font-size: 22px !important; - display: inline-block; - height: 40px; - float: left; - margin-right: 4px; -} - -.widget_recent_sermons .widget_recent_sermons_meta { - display: inline-block; - width: 100%; -} - -.widget_recent_sermons li { - list-style: none !important; - margin: 0px 0 12px; - line-height: 1.1em; -} - -.widget_recent_sermons span { - font-size: 0.75em; - color: #444444; - margin: 0; - display: block; -} - -.widget_recent_sermons .meta > span { - display: inline; -} - -#sermon-navigation { - padding-bottom: 15px; -} - -/* WP Pagenavi Styles */ -.wp-pagenavi { - font-size: 12px; - display: block; - clear: both; - padding: 20px 0px 20px 10px; -} - -.wp-pagenavi a, -.wp-pagenavi a:link, -.wp-pagenavi a:visited, -.wp-pagenavi a:active { - padding: 4px 8px !important; - margin: 3px !important; - text-decoration: none !important; - border: 1px solid #C8C8C2 !important; - background: #FCFCFC !important; - -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - color: #999 !important; -} - -.wp-pagenavi a:hover { - border: 1px solid #a7a7a3 !important; - color: #444 !important; -} - -.wp-pagenavi span.pages { - padding: 4px 8px !important; - margin: 3px !important; - font-style: italic !important; - color: #999 !important; -} - -.wp-pagenavi span.current { - padding: 4px 8px !important; - margin: 3px !important; - text-decoration: none !important; - border: 1px solid #a7a7a3 !important; - background: #FCFCFC !important; - -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - font-weight: bold !important; - color: #444 !important; -} - -.wp-pagenavi span.extend { - padding: 4px 8px !important; - margin: 3px !important; - text-decoration: none !important; - border: 1px solid #C8C8C2 !important; - background: #FCFCFC !important; - -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; - box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; -} - -/* Verse Popup Styles */ -.bibly_popup_outer { - font-size: 1.2em; -} - -.bibly_popup_footer { - display: none; -} - -/* Styles for additional files */ -#wpfc-attachments a { - display: block; -} - -#wpfc-attachments a[href$='.ppt'], #wpfc-attachments a[href$='.pptx'] { - height: 16px; - line-height: 16px; - margin: 10px 0; -} - -#wpfc-attachments a[href$='.doc'], #wpfc-attachments a[href$='.rtf'], #wpfc-attachments a[href$='.docx'] { - height: 16px; - line-height: 16px; - margin: 10px 0; -} - -#wpfc-attachments a[href$='.pdf'], a.sermon-notes, -#wpfc-attachments a[href$='.pdf'], a.sermon-bulletin { - height: 16px; - line-height: 16px; - margin: 10px 0; -} - -#wpfc-attachments a[href$='.mp3'] { - height: 16px; - line-height: 16px; - margin: 10px 0; -} - -#wpfc-attachments a[href$='.mp4'] { - height: 16px; - line-height: 16px; - margin: 10px 0; -} - -.sermon-notes .dashicons, .sermon-bulletin .dashicons, .dashicons-before:before, -#wpfc-attachments .dashicons, .dashicons-before:before { - vertical-align: text-top !important; -} - -/* Image styles for Sermon Series, Speakers */ -.sermon-images-the-terms { - margin: 10px 0; - padding: 0; - zoom: 1; -} - -.sermon-images-the-terms:before, -.sermon-images-the-terms:after { - content: "\0020"; - display: block; - height: 0; - visibility: hidden; - clear: both; -} - -.sermon-images-the-terms li, -.sermon-images-the-terms a, -.sermon-images-the-terms img { - float: left; - margin: 0; - padding: 0; -} - -.sermon-images-the-terms li { - list-style-type: none; - margin: 0 10px 10px 0; -} - -ul#wpfc_images_grid { - margin: 0 !important; -} - -ul#wpfc_images_grid:after { - content: "."; - visibility: hidden; - display: block; - height: 0; - clear: right; -} - -li.wpfc_grid_image { - list-style-type: none !important; - margin: 0 10px 10px 0 !important; - width: 47%; - float: left; -} - -li.wpfc_grid_image img { - max-width: 100%; - height: auto; -} - -h3.wpfc_grid_title a { - text-decoration: none; -} - -.wpfc_worship_audio { - max-width: 500px; -} - -.wpfc_worship_audio .wp-playlist { - border: 0px !important; -} +/* Sermon Manager CSS http://www.wpforchurch.com/products/sermon-manager-for-wordpress/ */ + +.single-wpfc_sermon .wpfc_sermon_image { + margin: 10px 0 10px; +} + +.wpfc_sermon_image_wide { + max-width: 100%; + float: left; +} + +.wpfc_sermon_image_wide img { + max-width: 100%; + height: auto; + margin: 0 0 10px 0; +} + +.wpfc_sermon_image { + max-width: 100%; + float: left; +} + +.wpfc_sermon_image img { + max-width: 100%; + height: auto; + margin: 0 10px 0 !important; +} + +.wpfc_sermon_wrap { + padding-bottom: 20px; + clear: both; +} + +#wpfc_sermon_sorting form { + display: inline; + margin: 0 10px 10px 0; +} + +.single-wpfc_sermon .wpfc_sermon_wrap { + padding-bottom: 0px; +} + +.wpfc_sermon_meta p { + margin: 0 !important; +} + +.sermon_date, .service_type { + text-transform: uppercase; + font-size: 12px; +} + +.sermon_series:before { + clear: left; +} + +#wpfc_sermon_tax_desc:after { + content: "."; + visibility: hidden; + display: block; + height: 0; + clear: right; +} + +/* controls padding around video embeds */ +.wpfc_sermon-video { + margin: 10px 0 10px; + max-width: 100%; + clear: both; +} + +.wpfc_sermon-video iframe, .wpfc_sermon-video embed, .wpfc_sermon-video-link iframe { + max-width: 100%; +} + +.mejs-container, #wpfc_sermon iframe, #wpfc_sermon object, #wpfc_sermon embed { + max-width: 100%; +} + +.wpfc_sermon-notes, +.wpfc_sermon-bulletin { + margin: 10px 0 10px; +} + +/* controls padding around audio player */ +.wpfc_sermon-audio { + margin: 10px 0 10px; + max-width: 500px; + clear: both; +} + +#wpfc_sermon_sorting { + padding: 10px 0 10px; +} + +/* Some clearfix code from HTML5 Boilerplate */ +.cf:before, .cf:after { + content: "\0020"; + display: block; + height: 0; + visibility: hidden; +} + +.cf:after { + clear: both; +} + +.cf { + zoom: 1; +} + +/* Recent Sermon Widget */ +.widget_recent_sermons ul { + margin-left: 0px !important; +} + +.widget_recent_sermons .dashicons-microphone { + font-size: 22px !important; + display: inline-block; + height: 40px; + float: left; + margin-right: 4px; +} + +.widget_recent_sermons .widget_recent_sermons_meta { + display: inline-block; + width: 100%; +} + +.widget_recent_sermons li { + list-style: none !important; + margin: 0px 0 12px; + line-height: 1.1em; +} + +.widget_recent_sermons span { + font-size: 0.75em; + color: #444444; + margin: 0; + display: block; +} + +.widget_recent_sermons .meta > span { + display: inline; +} + +#sermon-navigation { + padding-bottom: 15px; +} + +/* WP Pagenavi Styles */ +.wp-pagenavi { + font-size: 12px; + display: block; + clear: both; + padding: 20px 0px 20px 10px; +} + +.wp-pagenavi a, +.wp-pagenavi a:link, +.wp-pagenavi a:visited, +.wp-pagenavi a:active { + padding: 4px 8px !important; + margin: 3px !important; + text-decoration: none !important; + border: 1px solid #C8C8C2 !important; + background: #FCFCFC !important; + -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + color: #999 !important; +} + +.wp-pagenavi a:hover { + border: 1px solid #a7a7a3 !important; + color: #444 !important; +} + +.wp-pagenavi span.pages { + padding: 4px 8px !important; + margin: 3px !important; + font-style: italic !important; + color: #999 !important; +} + +.wp-pagenavi span.current { + padding: 4px 8px !important; + margin: 3px !important; + text-decoration: none !important; + border: 1px solid #a7a7a3 !important; + background: #FCFCFC !important; + -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + font-weight: bold !important; + color: #444 !important; +} + +.wp-pagenavi span.extend { + padding: 4px 8px !important; + margin: 3px !important; + text-decoration: none !important; + border: 1px solid #C8C8C2 !important; + background: #FCFCFC !important; + -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.1) !important; +} + +/* Verse Popup Styles */ +.bibly_popup_outer { + font-size: 1.2em; +} + +.bibly_popup_footer { + display: none; +} + +/* Styles for additional files */ +#wpfc-attachments a { + display: block; +} + +#wpfc-attachments a[href$='.ppt'], #wpfc-attachments a[href$='.pptx'] { + height: 16px; + line-height: 16px; + margin: 10px 0; +} + +#wpfc-attachments a[href$='.doc'], #wpfc-attachments a[href$='.rtf'], #wpfc-attachments a[href$='.docx'] { + height: 16px; + line-height: 16px; + margin: 10px 0; +} + +#wpfc-attachments a[href$='.pdf'], a.sermon-notes, +#wpfc-attachments a[href$='.pdf'], a.sermon-bulletin { + height: 16px; + line-height: 16px; + margin: 10px 0; +} + +#wpfc-attachments a[href$='.mp3'] { + height: 16px; + line-height: 16px; + margin: 10px 0; +} + +#wpfc-attachments a[href$='.mp4'] { + height: 16px; + line-height: 16px; + margin: 10px 0; +} + +.sermon-notes .dashicons, .sermon-bulletin .dashicons, .dashicons-before:before, +#wpfc-attachments .dashicons, .dashicons-before:before { + vertical-align: text-top !important; +} + +/* Image styles for Sermon Series, Speakers */ +.sermon-images-the-terms { + margin: 10px 0; + padding: 0; + zoom: 1; +} + +.sermon-images-the-terms:before, +.sermon-images-the-terms:after { + content: "\0020"; + display: block; + height: 0; + visibility: hidden; + clear: both; +} + +.sermon-images-the-terms li, +.sermon-images-the-terms a, +.sermon-images-the-terms img { + float: left; + margin: 0; + padding: 0; +} + +.sermon-images-the-terms li { + list-style-type: none; + margin: 0 10px 10px 0; +} + +ul#wpfc_images_grid { + margin: 0 !important; +} + +ul#wpfc_images_grid:after { + content: "."; + visibility: hidden; + display: block; + height: 0; + clear: right; +} + +li.wpfc_grid_image { + list-style-type: none !important; + margin: 0 10px 10px 0 !important; + width: 47%; + float: left; +} + +li.wpfc_grid_image img { + max-width: 100%; + height: auto; +} + +h3.wpfc_grid_title a { + text-decoration: none; +} + +.wpfc_worship_audio { + max-width: 500px; +} + +.wpfc_worship_audio .wp-playlist { + border: 0px !important; +} diff --git a/assets/fonts/Sermon-Manager.eot b/assets/fonts/Sermon-Manager.eot new file mode 100644 index 0000000..e1f4226 Binary files /dev/null and b/assets/fonts/Sermon-Manager.eot differ diff --git a/assets/fonts/Sermon-Manager.svg b/assets/fonts/Sermon-Manager.svg new file mode 100644 index 0000000..f44ef6b --- /dev/null +++ b/assets/fonts/Sermon-Manager.svg @@ -0,0 +1,14 @@ + + + + Generated by IcoMoon + + + + + + + + + \ No newline at end of file diff --git a/assets/fonts/Sermon-Manager.ttf b/assets/fonts/Sermon-Manager.ttf new file mode 100644 index 0000000..b40050e Binary files /dev/null and b/assets/fonts/Sermon-Manager.ttf differ diff --git a/assets/fonts/Sermon-Manager.woff b/assets/fonts/Sermon-Manager.woff new file mode 100644 index 0000000..d980a15 Binary files /dev/null and b/assets/fonts/Sermon-Manager.woff differ diff --git a/js/dismiss-php.js b/assets/js/admin/dismiss-php.js similarity index 100% rename from js/dismiss-php.js rename to assets/js/admin/dismiss-php.js diff --git a/js/error-recovery.js b/assets/js/admin/error-recovery.js similarity index 100% rename from js/error-recovery.js rename to assets/js/admin/error-recovery.js diff --git a/js/bibly.min.js b/assets/js/bibly.min.js similarity index 100% rename from js/bibly.min.js rename to assets/js/bibly.min.js diff --git a/js/plyr.js b/assets/js/plyr.js similarity index 100% rename from js/plyr.js rename to assets/js/plyr.js diff --git a/css/icons/README.txt b/css/icons/README.txt deleted file mode 100755 index 1092580..0000000 --- a/css/icons/README.txt +++ /dev/null @@ -1,73 +0,0 @@ -Fugue Icons - -Copyright (C) 2010 Yusuke Kamiyamane. All rights reserved. -The icons are licensed under a Creative Commons Attribution -3.0 license. - -If you can't or don't want to provide a link back, please -purchase a royalty-free license. - - -I'm unavailable for custom icon design work. But your -suggestions are always welcome! - - ------------------------------------------------------------- - -- geotag - - Copyright (C) Geotag Icon Project. All rights reserved. - - - Geotag icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license or LGPL. - - - -- language - - Copyright (C) Language Icon Project. All rights reserved. - - - Language icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license. - - -- open-share - - Copyright (C) Open Share Icon Project. All rights reserved. - - - Open Share icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license. - - -- opml - - Copyright (C) OPML Icon Project. All rights reserved. - - - OPML icon is licensed under a Creative Commons - Attribution-Share Alike 2.5 license. - - -- share - - Copyright (C) Share Icon Project. All rights reserved. - - - Share icon is licensed under a GPL or LGPL or BSD or - Creative Commons Attribution 2.5 license. - - - - - -- xfn - - Copyright (C) Wolfgang Bartelme. All rights reserved. - - - XFN icon is licensed under a Creative Commons - Attribution-Share Alike 2.5 license. - \ No newline at end of file diff --git a/css/icons/audio.png b/css/icons/audio.png deleted file mode 100755 index 90f9fb7..0000000 Binary files a/css/icons/audio.png and /dev/null differ diff --git a/css/icons/mic-icon.png b/css/icons/mic-icon.png deleted file mode 100755 index 7f83f71..0000000 Binary files a/css/icons/mic-icon.png and /dev/null differ diff --git a/css/icons/pdf.png b/css/icons/pdf.png deleted file mode 100755 index 4bdb47e..0000000 Binary files a/css/icons/pdf.png and /dev/null differ diff --git a/css/icons/ppt.png b/css/icons/ppt.png deleted file mode 100755 index 7ae9ce4..0000000 Binary files a/css/icons/ppt.png and /dev/null differ diff --git a/css/icons/video.png b/css/icons/video.png deleted file mode 100755 index 91c2126..0000000 Binary files a/css/icons/video.png and /dev/null differ diff --git a/css/icons/word.png b/css/icons/word.png deleted file mode 100755 index 4f67833..0000000 Binary files a/css/icons/word.png and /dev/null differ diff --git a/includes/CMB2/includes/CMB2_Utils.php b/includes/CMB2/includes/CMB2_Utils.php index be3d32a..9abaae8 100755 --- a/includes/CMB2/includes/CMB2_Utils.php +++ b/includes/CMB2/includes/CMB2_Utils.php @@ -260,7 +260,7 @@ public static function array_insert( &$array, $new, $position ) { */ public static function url( $path = '' ) { // SM: Seems like CMB2 doesn't return a correct URL. This should fix it. - return str_replace( get_site_url(), '', SERMON_MANAGER_URL ) . 'includes/CMB2/' . $path; + return str_replace( get_site_url(), '', SM_URL ) . 'includes/CMB2/' . $path; if ( self::$url ) { return self::$url . $path; diff --git a/includes/admin-functions.php b/includes/admin-functions.php old mode 100755 new mode 100644 index 8dd66ac..d52df3e --- a/includes/admin-functions.php +++ b/includes/admin-functions.php @@ -121,19 +121,19 @@ function wpfc_sermon_updated_messages( $messages ) { $messages['wpfc_sermon'] = array( 0 => '', // Unused. Messages start at index 1. - 1 => sprintf( __( 'Sermon updated. View sermon', 'sermon-manager-for-wordpress' ), esc_url( get_permalink( $post_ID ) ) ), - 2 => __( 'Custom field updated.', 'sermon-manager-for-wordpress' ), - 3 => __( 'Custom field deleted.', 'sermon-manager-for-wordpress' ), - 4 => __( 'Sermon updated.', 'sermon-manager-for-wordpress' ), + 1 => wp_sprintf( esc_html__( 'Sermon updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), + 2 => esc_html__( 'Custom field updated.', 'sermon-manager-for-wordpress' ), + 3 => esc_html__( 'Custom field deleted.', 'sermon-manager-for-wordpress' ), + 4 => esc_html__( 'Sermon updated.', 'sermon-manager-for-wordpress' ), /* translators: %s: date and time of the revision */ - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Sermon restored to revision from %s', 'sermon-manager-for-wordpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __( 'Sermon published. View sermon', 'sermon-manager-for-wordpress' ), esc_url( get_permalink( $post_ID ) ) ), - 7 => __( 'Sermon saved.', 'sermon-manager-for-wordpress' ), - 8 => sprintf( __( 'Sermon submitted. Preview sermon', 'sermon-manager-for-wordpress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), - 9 => sprintf( __( 'Sermon scheduled for: %1$s. Preview sermon', 'sermon-manager-for-wordpress' ), - // translators: Publish box date format, see http://php.net/date - date_i18n( __( 'M j, Y @ G:i', 'sermon-manager-for-wordpress' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), - 10 => sprintf( __( 'Sermon draft updated. Preview sermon', 'sermon-manager-for-wordpress' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + 5 => isset( $_GET['revision'] ) ? wp_sprintf( esc_html__( 'Sermon restored to revision from %s', 'sermon-manager-for-wordpress' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + 6 => wp_sprintf( esc_html__( 'Sermon published. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), + 7 => esc_html__( 'Sermon saved.', 'sermon-manager-for-wordpress' ), + 8 => wp_sprintf( esc_html__( 'Sermon submitted. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), + 9 => wp_sprintf( esc_html__( 'Sermon scheduled for: %1$s. %2$s', 'sermon-manager-for-wordpress' ), + '' . wp_sprintf( esc_html__( '%1$s at %2$s', 'sermon-manager-for-wordpress'), get_post_time( get_option( 'date_format' ), false, null, true ), get_post_time( get_option( 'time_format' ), false, null, true ) ) . '', + '' . esc_html__( 'Preview sermon', 'sermon-manager-for-wordpress' ) . '' ), + 10 => wp_sprintf( esc_html__( 'Sermon draft updated. %s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'View sermon', 'sermon-manager-for-wordpress' ) . '' ), ); return $messages; @@ -210,7 +210,7 @@ function wpfc_sermon_columns( $column ) { global $post; if ( empty( $post->ID ) ) { - echo 'Error. Can\'t find sermon ID.'; + echo wp_sprintf( esc_html__( '%s Can’t find sermon ID.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . '' ); return; } @@ -239,7 +239,7 @@ function wpfc_sermon_columns( $column ) { $data = wpfc_entry_views_get( array( 'post_id' => $post->ID ) ); break; case "preached": - $data = sm_get_the_date( '', $post ); + $data = date_i18n( get_option ( 'date_format' ), sm_get_the_date( 'U', $post ) ); break; case "passage": $data = get_post_meta( $post->ID, 'bible_passage', true ); @@ -249,7 +249,8 @@ function wpfc_sermon_columns( $column ) { } if ( $data instanceof WP_Error ) { - echo 'Error: ' . $data->get_error_message(); + if ( is_rtl() ) echo $data->get_error_message() . ' ' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . ''; + else echo '' . esc_html__( 'Error:', 'sermon-manager-for-wordpress' ) . ' ' . $data->get_error_message(); return; } @@ -303,14 +304,14 @@ function wpfc_dashboard() { // format the number to current locale $num = number_format_i18n( $num_posts->publish ); // put correct singular or plural text - $text = _n( 'Sermon', 'Sermons', intval( $num_posts->publish ) ); + $text = wp_sprintf( esc_html( _n( '%s sermon', '%s sermons', intval( $num_posts->publish ), 'sermon-manager-for-wordpress' ) ), $num ); $count = '
  • '; if ( current_user_can( 'edit_posts' ) ) { - $count .= '' . $num . ' ' . $text . ''; + $count .= '' . $text . ''; } else { - $count .= $num . ' ' . $text; + $count .= $text; } $count .= '
  • '; diff --git a/includes/class-sm-background-updater.php b/includes/class-sm-background-updater.php new file mode 100644 index 0000000..ebe6189 --- /dev/null +++ b/includes/class-sm-background-updater.php @@ -0,0 +1,107 @@ +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? + * + * @return boolean + */ + public function is_updating() { + return false === $this->is_queue_empty(); + } + + /** + * Task + * + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param string $callback Update callback function + * + * @return mixed + */ + protected function task( $callback ) { + if ( ! defined( 'SM_UPDATING' ) ) { + define( 'SM_UPDATING', true ); + } + + include_once( dirname( __FILE__ ) . '/sm-update-functions.php' ); + + if ( is_callable( $callback ) ) { + call_user_func( $callback ); + } + + return false; + } + + /** + * Complete + * + * Override if applicable, but ensure that the below actions are + * performed, or, call parent::complete(). + */ + protected function complete() { + SM_Install::update_db_version(); + parent::complete(); + } +} diff --git a/includes/class-sm-dates-wp.php b/includes/class-sm-dates-wp.php index 94e207b..7a470b4 100644 --- a/includes/class-sm-dates-wp.php +++ b/includes/class-sm-dates-wp.php @@ -34,6 +34,9 @@ public static function get_the_date( $the_date = '', $d = '', $post = null ) { */ public static function hook() { add_action( 'save_post_wpfc_sermon', array( get_class(), 'maybe_update_date' ), 10, 3 ); + add_action( 'save_post_wpfc_sermon', array( get_class(), 'save_series_date' ), 20, 3 ); + add_action( 'save_post_wpfc_sermon', array( get_class(), 'update_series_date' ), 30 ); + add_action( 'pre_post_update', array( get_class(), 'get_original_series' ) ); add_action( 'pre_post_update', array( get_class(), 'get_original_date' ) ); add_filter( 'cmb2_override_sermon_date_meta_remove', '__return_true' ); @@ -48,7 +51,75 @@ public static function hook() { } /** - * If post that is being updated is sermon, then it saves post date to globals + * Used to save series that were there before sermon update, for later comparison + * + * @param int $post_ID Post ID. + * + * @since 2.8 + */ + public static function get_original_series( $post_ID ) { + if ( get_post_type( $post_ID ) === 'wpfc_sermon' ) { + $GLOBALS['sm_original_series'] = wp_get_object_terms( $post_ID, 'wpfc_sermon_series' ); + } + } + + /** + * Saves sermon date as term meta (for ordering) + * + * @param int $post_ID Post ID. + * @param WP_Post $post Post object. + * @param bool $update Whether this is an existing post being updated or not. + * + * @since 2.8 + */ + public static function save_series_date( $post_ID, $post, $update ) { + $series = $_POST['tax_input']['wpfc_sermon_series']; + $orig_series = $GLOBALS['sm_original_series']; + + if ( $update ) { + foreach ( $orig_series as $term ) { + delete_term_meta( $term->term_id, 'sermon_date' ); + } + } + + if ( ! empty( $series ) ) { + foreach ( $orig_series as $term_id ) { + update_term_meta( $term_id, 'sermon_date_' . $post_ID, get_post_meta( $post_ID, 'sermon_date', true ) ); + } + } + } + + /** + * Loops through all series and sets latest available date + * + * @since 2.8 + */ + public static function update_series_date() { + foreach ( + get_terms( array( + 'taxonomy' => 'wpfc_sermon_series', + ) ) as $term + ) { + $term_meta = get_term_meta( $term->term_id ); + + if ( empty( $term_meta['sermon_date'] ) ) { + $dates = array(); + foreach ( $term_meta as $name => $value ) { + if ( strpos( $name, 'sermon_date_' ) !== false ) { + $dates[] = $value[0]; + } + } + + if ( ! empty( $dates ) ) { + arsort( $dates ); + update_term_meta( $term->term_id, 'sermon_date', $dates[0] ); + } + } + } + } + + /** + * Used to save date that was there before sermon update, for later comparison * * @param int $post_ID Post ID. * diff --git a/includes/class-sm-error-recovery.php b/includes/class-sm-error-recovery.php index 79dbe48..6e83d6c 100644 --- a/includes/class-sm-error-recovery.php +++ b/includes/class-sm-error-recovery.php @@ -1,4 +1,5 @@ query( $sql ); - $headers = get_headers( get_site_url() ); - if ( substr( $headers[0], 9, 3 ) == 500 ) { - self::reset_db(); + if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) === false ) { + $content = file_get_contents( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + $headers = get_headers( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + if ( ! ( strpos( strtolower( $content ), 'fatal error' ) === false && + $content !== '' && + substr( $headers[0], 9, 3 ) != 500 ) ) { + self::reset_db(); + } + } else { + if ( strpos( self::$_error['message'], 'sermon' ) === false && + strpos( $_SERVER['REQUEST_URI'], 'sermon' ) === false ) { + self::reset_db(); + } } $mysqli->query( "UPDATE {$table_prefix}options SET option_value = '0' WHERE option_name = '_sm_recovery_do_not_catch'" ); @@ -190,49 +201,50 @@ public static function reset_db() { * Displays WordPress admin error message */ public static function render_admin_message() { - $plugin_name = get_plugin_data( constant( self::$_plugin_main_file ) )['Name']; + $plugin_data = get_plugin_data( constant( self::$_plugin_main_file ) ); + $plugin_name = $plugin_data['Name']; $old_error = get_option( '_sm_recovery_last_fatal_error_hash' ) === md5( get_option( '_sm_recovery_last_fatal_error' ) ); ?>

    - - %s encountered a fatal error and recovered successfully.', 'sermon-manager-for-wordpress' ), $plugin_name ) ?> + + ' . esc_html( $plugin_name . '' ) ) ?> - +

    - + - + - +

    - -
    urlencode( str_replace( ABSPATH, '~/', get_option( '_sm_recovery_last_fatal_error' ) ) ), - 'environment_info' => 'WordPress: ' . $GLOBALS['wp_version'] . '; Server: ' . ( function_exists( 'apache_get_version' ) ? apache_get_version() : 'N/A' ) . '; PHP: ' . PHP_VERSION . '; Sermon Manager:' . SERMON_MANAGER_VERSION . ';', - 'plugin_name' => get_plugin_data( constant( self::$_plugin_main_file ) )['Name'], + 'environment_info' => 'WordPress: ' . $GLOBALS['wp_version'] . '; Server: ' . ( function_exists( 'apache_get_version' ) ? apache_get_version() : 'N/A' ) . '; PHP: ' . PHP_VERSION . '; Sermon Manager:' . SM_VERSION . ';', + 'plugin_name' => $plugin_data['Name'], ) ); - wp_enqueue_style( 'sm-error-recovery', SERMON_MANAGER_URL . 'css/error-recovery.css', array(), SERMON_MANAGER_VERSION ); + wp_enqueue_style( 'sm-error-recovery', SM_URL . 'assets/css/error-recovery.css', array(), SM_VERSION ); } /** @@ -269,14 +282,9 @@ public static function disable_send_report_button() { */ public static function upgrade_check() { $db_version = get_option( 'sm_version' ); - if ( empty( $db_version ) || $db_version != SERMON_MANAGER_VERSION ) { + if ( empty( $db_version ) || $db_version != SM_VERSION ) { update_option( '_sm_recovery_do_not_catch', 0 ); update_option( '_sm_recovery_disable', 0 ); - update_option( 'sm_version', SERMON_MANAGER_VERSION ); - - // Flush rewrite rules after update - add_action( 'sm_after_register_post_type', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) ); - add_action( 'sm_after_register_taxonomy', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) ); } } @@ -310,4 +318,4 @@ private function _register_wp_hooks() { add_action( 'wp_ajax_sm_clear_fatal_error', array( get_class(), 'reset_db' ) ); add_action( 'wp_ajax_sm_recovery_disable_send_report', array( get_class(), 'disable_send_report_button' ) ); } -} \ No newline at end of file +} diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php new file mode 100644 index 0000000..c0a69d1 --- /dev/null +++ b/includes/class-sm-install.php @@ -0,0 +1,195 @@ + array( + 'sm_update_28_revert_old_dates', + 'sm_update_28_convert_dates_to_unix', + 'sm_update_28_fill_out_empty_dates', + 'sm_update_28_fill_out_series_dates', + 'sm_update_28_save_sermon_render_into_post_content', + 'sm_update_28_reset_recovery', + ) + ); + + /** @var object Background update class */ + private static $background_updater; + + public static function init() { + add_action( 'init', array( __CLASS__, 'init_background_updater' ), 3 ); + add_action( 'init', array( __CLASS__, 'check_version' ), 8 ); + add_filter( 'plugin_action_links_' . SM_BASENAME, array( __CLASS__, 'plugin_action_links' ) ); + add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); + add_filter( 'cron_schedules', array( __CLASS__, 'cron_schedules' ) ); + } + + /** + * Check Sermon Manager version and run the updater is required + * + * This check is done on all requests and runs if the versions do not match + */ + public static function check_version() { + if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'sm_version' ) !== SM_VERSION ) { + self::_install(); + do_action( 'sm_updated' ); + } + } + + /** + * Install Sermon Manager + */ + private static function _install() { + global $wpdb; + + if ( ! is_blog_installed() ) { + return; + } + + if ( ! defined( 'SM_INSTALLING' ) ) { + define( 'SM_INSTALLING', true ); + } + + //self::_create_options(); todo: will be done in future versions, every option will have its own field in the database, so we will just use `add_option()` - it won't overwrite the field + //self::_create_roles(); todo: will be done in future versions + + // Register post types + SM_Post_types::register_post_types(); + SM_Post_types::register_taxonomies(); + + // do update + self::_update(); + + // Update version just in case + self::update_db_version(); + + // Flush rules after install + do_action( 'sm_flush_rewrite_rules' ); + + /* + * Deletes all expired transients. The multi-table delete syntax is used + * to delete the transient record from table a, and the corresponding + * transient_timeout record from table b. + * + * Based on code inside core's upgrade_network() function. + */ + /** @noinspection SqlNoDataSourceInspection */ + $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b + WHERE a.option_name LIKE %s + AND a.option_name NOT LIKE %s + AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) ) + AND b.option_value < %d"; + $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) ); + + // Trigger action + do_action( 'sm_installed' ); + } + + /** + * Push all needed DB updates to the queue for processing. + */ + private static function _update() { + $current_db_version = get_option( 'sm_version' ); + $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 ) { + self::$background_updater->push_to_queue( $update_callback ); + $update_queued = true; + } + } + } + + if ( $update_queued ) { + self::$background_updater->save()->dispatch(); + } + } + + /** + * Get list of DB update callbacks. + * + * @return array + */ + 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. + * + * @param string $version (optional) + */ + public static function update_db_version( $version = null ) { + delete_option( 'sm_version' ); + add_option( 'sm_version', is_null( $version ) ? SM_VERSION : $version ); + } + + /** + * Add more cron schedules + * + * @param array $schedules + * + * @return array + */ + public static function cron_schedules( $schedules ) { + $schedules['monthly'] = array( + 'interval' => 2635200, + 'display' => __( 'Monthly', 'sermon-manager-for-wordpress' ), + ); + + return $schedules; + } + + /** + * Show action links on the plugin screen. + * + * @param mixed $links Plugin Action links + * + * @return array + */ + public static function plugin_action_links( $links ) { + $action_links = array( + 'settings' => '' . esc_html__( 'Settings' ) . '', + ); + + return array_merge( $action_links, $links ); + } + + /** + * Show row meta on the plugin screen. + * + * @param mixed $links Plugin Row Meta + * @param mixed $file Plugin Base file + * + * @return array + */ + public static function plugin_row_meta( $links, $file ) { + /** @noinspection PhpUndefinedConstantInspection */ + if ( SM_BASENAME == $file ) { + $row_meta = array( + 'support' => '' . esc_html__( 'Premium support', 'sermon-manager-for-wordpress' ) . '', + ); + + return array_merge( $links, $row_meta ); + } + + return (array) $links; + } +} + +SM_Install::init(); diff --git a/includes/class-sm-post-types.php b/includes/class-sm-post-types.php index b8bf419..39f2b32 100644 --- a/includes/class-sm-post-types.php +++ b/includes/class-sm-post-types.php @@ -48,7 +48,7 @@ public static function register_taxonomies() { /* Translators: %s: Preacher label (sentence case; singular) */ 'singular_name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) ), /* Translators: %s: Preachers label (sentence case; plural) */ - 'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager' ), ucwords( $preacher_label ) . 's' ), + 'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ), /* Translators: %s: Preachers label (lowercase; plural) */ 'search_items' => sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ), /* Translators: %s: Preachers label (lowercase; plural) */ @@ -80,7 +80,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Series', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Series', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Series', 'Admin menu name', 'sermon-manager' ), + 'menu_name' => _x( 'Series', 'Admin menu name', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search series', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All series', 'sermon-manager-for-wordpress' ), 'parent_item' => null, // it's not hierarchical @@ -105,7 +105,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Topics', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Topic', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Topics', 'Admin menu name', 'sermon-manager' ), + 'menu_name' => _x( 'Topics', 'Admin menu name', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search topics', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All topics', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -130,7 +130,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Bible books', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Book', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Books', 'Admin menu name', 'sermon-manager' ), + 'menu_name' => _x( 'Books', 'Admin menu name', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search books', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All books', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -155,7 +155,7 @@ public static function register_taxonomies() { 'labels' => array( 'name' => __( 'Service Types', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Service Types', 'Admin menu name', 'sermon-manager' ), + 'menu_name' => _x( 'Service Types', 'Admin menu name', 'sermon-manager-for-wordpress' ), 'search_items' => __( 'Search service types', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All service types', 'sermon-manager-for-wordpress' ), 'parent_item' => null, @@ -192,7 +192,7 @@ public static function register_post_types() { 'name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), 'singular_name' => __( 'Sermon', 'sermon-manager-for-wordpress' ), 'all_items' => __( 'All Sermons', 'sermon-manager-for-wordpress' ), - 'menu_name' => _x( 'Sermons', 'Admin menu name', 'sermon-manager' ), + 'menu_name' => _x( 'Sermons', 'Admin menu name', 'sermon-manager-for-wordpress' ), 'add_new' => __( 'Add New', 'sermon-manager-for-wordpress' ), 'add_new_item' => __( 'Add new sermon', 'sermon-manager-for-wordpress' ), 'edit' => __( 'Edit', 'sermon-manager-for-wordpress' ), @@ -221,7 +221,7 @@ public static function register_post_types() { 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_in_menu' => true, - 'menu_icon' => SERMON_MANAGER_URL . 'includes/img/sm-icon.svg', + 'menu_icon' => 'dashicons-sermon-manager', 'hierarchical' => false, 'rewrite' => array( 'slug' => $permalinks['wpfc_sermon'], 'with_front' => false ), 'query_var' => true, @@ -235,6 +235,7 @@ public static function register_post_types() { 'wpcom-markdown', 'comments', 'entry-views', + 'elementor', ) ) ) ); diff --git a/includes/class-sm-search.php b/includes/class-sm-search.php deleted file mode 100644 index 4430c70..0000000 --- a/includes/class-sm-search.php +++ /dev/null @@ -1,85 +0,0 @@ -posts}.post_status = 'publish')"; - } - - return $where; - } - - /** - * Include taxonomies to default search - * - * @global $wpdb - * - * @param string $join - * - * @return string - */ - public function join( $join ) { - global $wpdb; - - if ( is_search() ) { - $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id"; - } - - return $join; - } - - /** - * - * @global $wpdb - * - * @param int $groupby - * - * @return string - */ - public function groupby( $groupby ) { - global $wpdb; - - // we need to group on post ID - $groupby_id = "{$wpdb->posts}.ID"; - if ( ! is_search() || strpos( $groupby, $groupby_id ) !== false ) { - return $groupby; - } - // groupby was empty, use ours - if ( ! strlen( trim( $groupby ) ) ) { - return $groupby_id; - } - - // wasn't empty, append ours - return $groupby . ", " . $groupby_id; - } -} - -$search = new SM_Search; -$search->hook(); diff --git a/includes/img/README.txt b/includes/img/README.txt deleted file mode 100755 index 1092580..0000000 --- a/includes/img/README.txt +++ /dev/null @@ -1,73 +0,0 @@ -Fugue Icons - -Copyright (C) 2010 Yusuke Kamiyamane. All rights reserved. -The icons are licensed under a Creative Commons Attribution -3.0 license. - -If you can't or don't want to provide a link back, please -purchase a royalty-free license. - - -I'm unavailable for custom icon design work. But your -suggestions are always welcome! - - ------------------------------------------------------------- - -- geotag - - Copyright (C) Geotag Icon Project. All rights reserved. - - - Geotag icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license or LGPL. - - - -- language - - Copyright (C) Language Icon Project. All rights reserved. - - - Language icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license. - - -- open-share - - Copyright (C) Open Share Icon Project. All rights reserved. - - - Open Share icon is licensed under a Creative Commons - Attribution-Share Alike 3.0 license. - - -- opml - - Copyright (C) OPML Icon Project. All rights reserved. - - - OPML icon is licensed under a Creative Commons - Attribution-Share Alike 2.5 license. - - -- share - - Copyright (C) Share Icon Project. All rights reserved. - - - Share icon is licensed under a GPL or LGPL or BSD or - Creative Commons Attribution 2.5 license. - - - - - -- xfn - - Copyright (C) Wolfgang Bartelme. All rights reserved. - - - XFN icon is licensed under a Creative Commons - Attribution-Share Alike 2.5 license. - \ No newline at end of file diff --git a/includes/img/sm-icon.svg b/includes/img/sm-icon.svg deleted file mode 100644 index 8630209..0000000 --- a/includes/img/sm-icon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - sm-icon - - - - - diff --git a/includes/libraries/wp-async-request.php b/includes/libraries/wp-async-request.php new file mode 100644 index 0000000..a49a5a2 --- /dev/null +++ b/includes/libraries/wp-async-request.php @@ -0,0 +1,158 @@ +identifier = $this->prefix . '_' . $this->action; + + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); + } + + /** + * Set data used during the request + * + * @param array $data Data. + * + * @return $this + */ + public function data( $data ) { + $this->data = $data; + + return $this; + } + + /** + * Dispatch the async request + * + * @return array|WP_Error + */ + public function dispatch() { + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); + $args = $this->get_post_args(); + + return wp_remote_post( esc_url_raw( $url ), $args ); + } + + /** + * Get query args + * + * @return array + */ + protected function get_query_args() { + if ( property_exists( $this, 'query_args' ) ) { + return $this->query_args; + } + + return array( + 'action' => $this->identifier, + 'nonce' => wp_create_nonce( $this->identifier ), + ); + } + + /** + * Get query URL + * + * @return string + */ + protected function get_query_url() { + if ( property_exists( $this, 'query_url' ) ) { + return $this->query_url; + } + + return admin_url( 'admin-ajax.php' ); + } + + /** + * Get post args + * + * @return array + */ + protected function get_post_args() { + if ( property_exists( $this, 'post_args' ) ) { + return $this->post_args; + } + + return array( + 'timeout' => 0.01, + 'blocking' => false, + 'body' => $this->data, + 'cookies' => $_COOKIE, + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), + ); + } + + /** + * Maybe handle + * + * Check for correct nonce and pass to handler. + */ + public function maybe_handle() { + // Don't lock up other requests while processing + session_write_close(); + + check_ajax_referer( $this->identifier, 'nonce' ); + + $this->handle(); + + wp_die(); + } + + /** + * Handle + * + * Override this method to perform any actions required + * during the async request. + */ + abstract protected function handle(); +} diff --git a/includes/libraries/wp-background-process.php b/includes/libraries/wp-background-process.php new file mode 100644 index 0000000..1323ee5 --- /dev/null +++ b/includes/libraries/wp-background-process.php @@ -0,0 +1,502 @@ +cron_hook_identifier = $this->identifier . '_cron'; + $this->cron_interval_identifier = $this->identifier . '_cron_interval'; + + add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); + add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); + } + + /** + * Dispatch + * + * @access public + * @return array|WP_Error + */ + public function dispatch() { + // Schedule the cron healthcheck. + $this->schedule_event(); + + // Perform remote post. + return parent::dispatch(); + } + + /** + * Push to queue + * + * @param mixed $data Data. + * + * @return $this + */ + public function push_to_queue( $data ) { + $this->data[] = $data; + + return $this; + } + + /** + * Save queue + * + * @return $this + */ + public function save() { + $key = $this->generate_key(); + + if ( ! empty( $this->data ) ) { + update_site_option( $key, $this->data ); + } + + return $this; + } + + /** + * Update queue + * + * @param string $key Key. + * @param array $data Data. + * + * @return $this + */ + public function update( $key, $data ) { + if ( ! empty( $data ) ) { + update_site_option( $key, $data ); + } + + return $this; + } + + /** + * Delete queue + * + * @param string $key Key. + * + * @return $this + */ + public function delete( $key ) { + delete_site_option( $key ); + + return $this; + } + + /** + * Generate key + * + * Generates a unique key based on microtime. Queue items are + * given a unique key so that they can be merged upon save. + * + * @param int $length Length. + * + * @return string + */ + protected function generate_key( $length = 64 ) { + $unique = md5( microtime() . rand() ); + $prepend = $this->identifier . '_batch_'; + + return substr( $prepend . $unique, 0, $length ); + } + + /** + * Maybe process queue + * + * Checks whether data exists within the queue and that + * the process is not already running. + */ + public function maybe_handle() { + // Don't lock up other requests while processing + session_write_close(); + + if ( $this->is_process_running() ) { + // Background process already running. + wp_die(); + } + + if ( $this->is_queue_empty() ) { + // No data to process. + wp_die(); + } + + check_ajax_referer( $this->identifier, 'nonce' ); + + $this->handle(); + + wp_die(); + } + + /** + * Is queue empty + * + * @return bool + */ + protected function is_queue_empty() { + global $wpdb; + + $table = $wpdb->options; + $column = 'option_name'; + + if ( is_multisite() ) { + $table = $wpdb->sitemeta; + $column = 'meta_key'; + } + + $key = $this->identifier . '_batch_%'; + + $count = $wpdb->get_var( $wpdb->prepare( " + SELECT COUNT(*) + FROM {$table} + WHERE {$column} LIKE %s + ", $key ) ); + + return ( $count > 0 ) ? false : true; + } + + /** + * Is process running + * + * Check whether the current process is already running + * in a background process. + */ + protected function is_process_running() { + if ( get_site_transient( $this->identifier . '_process_lock' ) ) { + // Process already running. + return true; + } + + return false; + } + + /** + * Lock process + * + * Lock the process so that multiple instances can't run simultaneously. + * Override if applicable, but the duration should be greater than that + * defined in the time_exceeded() method. + */ + protected function lock_process() { + $this->start_time = time(); // Set start time of current process. + + $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute + $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); + + set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); + } + + /** + * Unlock process + * + * Unlock the process so that other instances can spawn. + * + * @return $this + */ + protected function unlock_process() { + delete_site_transient( $this->identifier . '_process_lock' ); + + return $this; + } + + /** + * Get batch + * + * @return stdClass Return the first batch from the queue + */ + protected function get_batch() { + global $wpdb; + + $table = $wpdb->options; + $column = 'option_name'; + $key_column = 'option_id'; + $value_column = 'option_value'; + + if ( is_multisite() ) { + $table = $wpdb->sitemeta; + $column = 'meta_key'; + $key_column = 'meta_id'; + $value_column = 'meta_value'; + } + + $key = $this->identifier . '_batch_%'; + + $query = $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$table} + WHERE {$column} LIKE %s + ORDER BY {$key_column} ASC + LIMIT 1 + ", $key ) ); + + $batch = new stdClass(); + $batch->key = $query->$column; + $batch->data = maybe_unserialize( $query->$value_column ); + + return $batch; + } + + /** + * Handle + * + * Pass each queue item to the task handler, while remaining + * within server memory and time limit constraints. + */ + protected function handle() { + $this->lock_process(); + + do { + $batch = $this->get_batch(); + + foreach ( $batch->data as $key => $value ) { + $task = $this->task( $value ); + + if ( false !== $task ) { + $batch->data[ $key ] = $task; + } else { + unset( $batch->data[ $key ] ); + } + + if ( $this->time_exceeded() || $this->memory_exceeded() ) { + // Batch limits reached. + break; + } + } + + // Update or delete current batch. + if ( ! empty( $batch->data ) ) { + $this->update( $batch->key, $batch->data ); + } else { + $this->delete( $batch->key ); + } + } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); + + $this->unlock_process(); + + // Start next batch or complete process. + if ( ! $this->is_queue_empty() ) { + $this->dispatch(); + } else { + $this->complete(); + } + } + + /** + * Memory exceeded + * + * Ensures the batch process never exceeds 90% + * of the maximum WordPress memory. + * + * @return bool + */ + protected function memory_exceeded() { + $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory + $current_memory = memory_get_usage( true ); + $return = false; + + if ( $current_memory >= $memory_limit ) { + $return = true; + } + + return apply_filters( $this->identifier . '_memory_exceeded', $return ); + } + + /** + * Get memory limit + * + * @return int + */ + protected function get_memory_limit() { + if ( function_exists( 'ini_get' ) ) { + $memory_limit = ini_get( 'memory_limit' ); + } else { + // Sensible default. + $memory_limit = '128M'; + } + + if ( ! $memory_limit || - 1 === intval( $memory_limit ) ) { + // Unlimited, set to 32GB. + $memory_limit = '32000M'; + } + + return intval( $memory_limit ) * 1024 * 1024; + } + + /** + * Time exceeded. + * + * Ensures the batch never exceeds a sensible time limit. + * A timeout limit of 30s is common on shared hosting. + * + * @return bool + */ + protected function time_exceeded() { + $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds + $return = false; + + if ( time() >= $finish ) { + $return = true; + } + + return apply_filters( $this->identifier . '_time_exceeded', $return ); + } + + /** + * Complete. + * + * Override if applicable, but ensure that the below actions are + * performed, or, call parent::complete(). + */ + protected function complete() { + // Unschedule the cron healthcheck. + $this->clear_scheduled_event(); + } + + /** + * Schedule cron healthcheck + * + * @access public + * + * @param mixed $schedules Schedules. + * + * @return mixed + */ + public function schedule_cron_healthcheck( $schedules ) { + $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); + + if ( property_exists( $this, 'cron_interval' ) ) { + $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier ); + } + + // Adds every 5 minutes to the existing schedules. + $schedules[ $this->identifier . '_cron_interval' ] = array( + 'interval' => MINUTE_IN_SECONDS * $interval, + 'display' => sprintf( __( 'Every %d minutes', 'sermon-manager' ), $interval ), + ); + + return $schedules; + } + + /** + * 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. + exit; + } + + if ( $this->is_queue_empty() ) { + // No data to process. + $this->clear_scheduled_event(); + exit; + } + + $this->handle(); + + exit; + } + + /** + * Schedule event + */ + protected function schedule_event() { + if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { + wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); + } + } + + /** + * Clear scheduled event + */ + protected function clear_scheduled_event() { + $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); + + if ( $timestamp ) { + wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); + } + } + + /** + * Cancel Process + * + * Stop processing queue items, clear cronjob and delete batch. + * + */ + public function cancel_process() { + if ( ! $this->is_queue_empty() ) { + $batch = $this->get_batch(); + + $this->delete( $batch->key ); + + wp_clear_scheduled_hook( $this->cron_hook_identifier ); + } + + } + + /** + * Task + * + * Override this method to perform any actions required on each + * queue item. Return the modified item for further processing + * in the next pass through. Or, return false to remove the + * item from the queue. + * + * @param mixed $item Queue item to iterate over. + * + * @return mixed + */ + abstract protected function task( $item ); + +} diff --git a/includes/options.php b/includes/options.php index a8d82fb..f5b8cb1 100755 --- a/includes/options.php +++ b/includes/options.php @@ -7,7 +7,6 @@ class Sermon_Manager_Settings { - /* Construct */ public function __construct() { // Flush rewrite rules before everything else (if required) add_action( 'init', array( $this, 'maybe_flush_rewrite_rules' ) ); @@ -15,10 +14,6 @@ public function __construct() { add_action( 'admin_init', array( $this, 'wpfc_init' ) ); // Settings Menu Page add_action( 'admin_menu', array( $this, 'wpfc_add_options_page' ) ); - // Link for Settings on Plugin Page - add_filter( 'plugin_action_links', array( $this, 'wpfc_plugin_action_links' ), 10, 2 ); - // Plugin Meta Links - add_filter( 'plugin_row_meta', array( $this, 'wpfc_sermon_manager_plugin_row_meta' ), 10, 2 ); } static function wpfc_validate_options( $input ) { @@ -33,16 +28,15 @@ static function wpfc_validate_options( $input ) { update_option( '_sm_recovery_do_not_catch', '0' ); } - if ( SermonManager::getOption( 'archive_slug' ) != $input['archive_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' ); } return $input; } - // Init plugin options to white list our options - /** * Checks if archive slug has changed and flushes rewrite rules if necessary * @@ -55,8 +49,6 @@ function maybe_flush_rewrite_rules() { } } - // Add menu page - function wpfc_init() { global $wp_version; @@ -75,41 +67,14 @@ function wpfc_init() { } } - // Plugin Meta Links. - function wpfc_add_options_page() { - $page = add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Settings', 'sermon-manager' ), __( 'Settings', 'sermon-manager-for-wordpress' ), 'manage_options', __FILE__, array( + $page = add_submenu_page( 'edit.php?post_type=wpfc_sermon', __( 'Sermon Manager Settings', 'sermon-manager-for-wordpress' ), __( 'Settings', 'sermon-manager-for-wordpress' ), 'manage_options', __FILE__, array( $this, 'wpfc_sermon_options_render_form' ) ); add_action( 'admin_print_styles-' . $page, array( $this, 'wpfc_sermon_admin_styles' ) ); } - // Settings Page Link. - - function wpfc_sermon_manager_plugin_row_meta( $links, $file ) { - static $plugin_name = ''; - - if ( empty( $plugin_name ) ) { - $plugin_name = plugin_basename( __FILE__ ); - } - - if ( $plugin_name != $file ) { - return $links; - } - - $link = wpfc_sermon_manager_settings_page_link( __( 'Settings', 'sermon-manager-for-wordpress' ) ); - if ( ! empty( $link ) ) { - $links[] = $link; - } - - $links[] = '' . __( 'Support', 'sermon-manager-for-wordpress' ) . ''; - - return $links; - } - - // Add scripts - function wpfc_sermon_manager_settings_page_link( $link_text = '' ) { if ( empty( $link_text ) ) { $link_text = __( 'Manage Settings', 'sermon-manager-for-wordpress' ); @@ -117,14 +82,12 @@ function wpfc_sermon_manager_settings_page_link( $link_text = '' ) { $link = ''; if ( current_user_can( 'manage_options' ) ) { - $link = '' . esc_html( $link_text ) . ''; + $link = '' . esc_html( $link_text ) . ''; } return $link; } - // Render the Plugin options form - function wpfc_sermon_admin_styles() { wp_enqueue_script( 'media-upload' ); wp_enqueue_script( 'jquery-ui-tabs' ); @@ -133,8 +96,6 @@ function wpfc_sermon_admin_styles() { wp_enqueue_script( 'jquery-ui-droppable' ); } - // Sanitize and validate input. Accepts an array, return a sanitized array. - function wpfc_sermon_options_render_form() { if ( ! isset( $_REQUEST['settings-updated'] ) ) { $_REQUEST['settings-updated'] = false; @@ -201,22 +162,22 @@ function wpfc_sermon_options_render_form() {

    -

    +

    -

    +

    @@ -225,25 +186,23 @@ function wpfc_sermon_options_render_form() {
    -

    +

    -

    Sign up today and get support from the developers who are building the Sermon Manager.', 'sermon-manager' ); ?>

    -
    +

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

    +
    Free Support Priority - Support + target="_blank" class="button-secondary">  +
    -
    - We offer limited free support via WordPress.org +
    +
    -

    +

    - - -
    - Find out more in our Knowledgebase +
    + ' . esc_html__( 'knowledge base', 'sermon-manager-for-wordpress' ) . '' ); ?>
    -

    +

    - -

    - -
    +

    +
    Submit Your Idea + target="_blank" class="button-secondary">
    -
    @@ -288,82 +241,84 @@ function wpfc_sermon_options_render_form() {
    -

    +

    - + - + - + - + - + - + - + - + - + - + - + - - + +
    + value="" + placeholder=""/>
    + value="" + placeholder=""/>
    ' . esc_html__( 'sermons/preacher', 'sermon-manager-for-wordpress' ) . '', '' . esc_html__( 'sermons/series', 'sermon-manager-for-wordpress' ) . '' ); ?>




    @@ -371,7 +326,7 @@ function wpfc_sermon_options_render_form() {

    - + value=""/> +
    @@ -417,24 +371,24 @@ function wpfc_sermon_options_render_form() {
    -

    +

    - + - + @@ -467,7 +426,7 @@ function wpfc_sermon_options_render_form() {
    -

    +


    - bib.ly.', 'sermon-manager' ); ?> + ESV', + 'NET', + 'KJV', + 'LEB', + '' . esc_html__( 'bib.ly', 'sermon-manager-for-wordpress' ) . '' ); ?>
    - + ESV' ); ?>
    - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + -
    + placeholder="" + value=""/>
    + placeholder="" + value=""/>
    + placeholder="" + value=""/>
    + placeholder="" + value=""/>
    + placeholder="" + value=""/>

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

    + placeholder="" + value=""/>
    + placeholder="" + value=""/>
    + placeholder="" + value=""/> -

    +

    + placeholder="" + value=""/> -

    +

    + placeholder=""> -

    +

    + placeholder="" + value=""/> -

    +

    + placeholder="" + value=""/> -

    +

    + value=""/> + value=""/> -

    +

    + placeholder="" + value=""/> -

    +

    + placeholder="" + value=""/> -

    +


    -

    podtrac.com', 'sermon-manager' ); ?>

    +

    podtrac.com' ); ?>

    Enable HTML desciption
    -

    Enables showing of HTML in iTunes description field. Uncheck if - description looks messy.

    +

    Number of podcasts to show -

    Shows custom podcast count. If not defined, it uses WordPress - default count.

    +


    - -

    -
    - - -

    - -

    -

    - -

    - -

    - -

    - -

    - -

    -

    - +

    +
    + +

    + +

    ' . esc_html__( 'Feed Validator', 'sermon-manager-for-wordpress' ) . '' ); ?> +

    + +

    ' . esc_html__( 'Submit Your Podcast', 'sermon-manager-for-wordpress' ) . '' ); ?> +

    + +

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

    + +

    ' . esc_html__( 'iTunes FAQ for Podcast Makers', 'sermon-manager-for-wordpress' ) . '' ); ?> +

    + value=""/>

    @@ -767,19 +713,6 @@ class="itunes_cover_image_field"
    ' . __( 'Settings' ) . ''; - // make the 'Settings' link appear first - array_unshift( $links, $wpfc_links ); - } - - return $links; - } } $Sermon_Manager_Settings = new Sermon_Manager_Settings(); diff --git a/includes/podcast-functions.php b/includes/podcast-functions.php index fae7f85..594286d 100644 --- a/includes/podcast-functions.php +++ b/includes/podcast-functions.php @@ -73,7 +73,7 @@ function wpfc_podcast_render() { if ( $overridden_template = locate_template( 'wpfc-podcast-feed.php' ) ) { load_template( $overridden_template ); } else { - load_template( SERMON_MANAGER_PATH . 'views/wpfc-podcast-feed.php' ); + load_template( SM_PATH . 'views/wpfc-podcast-feed.php' ); } } diff --git a/includes/shortcodes.php b/includes/shortcodes.php index b33dcdd..a1c10df 100755 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -96,12 +96,21 @@ public function displaySermonsList( $atts ) { return 'Error: Invalid "list" parameter.
    Possible values are: "series", "preachers", "topics" and "books".
    You entered: "' . $args['display'] . '"'; } + $query_args = array( + 'taxonomy' => $args['display'], + 'orderby' => $args['orderby'], + 'order' => $args['order'], + ); + + if ( $query_args['orderby'] === 'date' ) { + $query_args['orderby'] = 'meta_value_num'; + $query_args['meta_key'] = 'sermon_date'; + $query_args['meta_compare'] = '<='; + $query_args['meta_value'] = time(); + } // get items - $terms = get_terms( $args['display'], array( - 'orderby' => $args['orderby'], - 'order' => $args['order'], - ) ); + $terms = get_terms( $query_args ); if ( count( $terms ) > 0 ) { // sort books by order @@ -605,6 +614,11 @@ public function displaySermonSorting( $atts = array() ) { * @return string */ function displaySermons( $atts = array() ) { + // enqueue scripts and styles + if ( ! defined( 'SM_ENQUEUE_SCRIPTS_STYLES' ) ) { + define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); + } + // default options $args = array( 'per_page' => '10', @@ -774,6 +788,11 @@ function displaySermons( $atts = array() ) { $listing = new WP_Query( $query_args ); + // set image size + add_filter( 'wpfc_sermon_excerpt_sermon_image_size', function () use ( $args ) { + return $args['image_size']; + } ); + if ( $listing->have_posts() ) { ob_start(); ?>
    diff --git a/includes/sm-cmb-functions.php b/includes/sm-cmb-functions.php index 7991898..3b58784 100755 --- a/includes/sm-cmb-functions.php +++ b/includes/sm-cmb-functions.php @@ -54,7 +54,7 @@ function wpfc_sermon_metaboxes() { $cmb = new_cmb2_box( array( 'id' => 'wpfc_sermon_details', - 'title' => __( 'Sermon Details', 'sermon-manager-for-wordpress' ), + 'title' => esc_html__( 'Sermon Details', 'sermon-manager-for-wordpress' ), 'object_types' => array( 'wpfc_sermon', ), // Post type 'context' => 'normal', 'priority' => 'high', @@ -82,30 +82,30 @@ function wpfc_sermon_metaboxes() { } $cmb->add_field( array( - 'name' => __( 'Date Preached', 'sermon-manager-for-wordpress' ), - 'desc' => '(optional)
    (format: ' . $date_format . ')', + 'name' => esc_html__( 'Date Preached', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( '(optional)', 'sermon-manager-for-wordpress' ) . '
    ' . wp_sprintf( esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), $date_format ), 'id' => 'sermon_date', 'type' => 'text_date_timestamp', 'date_format' => $date_format, ) ); $cmb->add_field( array( - 'name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Select the type of service. Modify service types in Sermons -> Service Types.', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Service Type', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Select the type of service. Modify service types in Sermons → Service Types.', 'sermon-manager-for-wordpress' ), 'id' => 'wpfc_service_type', 'type' => 'select', 'show_option_none' => true, 'options' => cmb2_get_term_options( 'wpfc_service_type' ), ) ); $cmb->add_field( array( - 'name' => __( 'Main Bible Passage', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Enter the Bible passage with the full book names,e.g. "John 3:16-18".', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Main Bible Passage', 'sermon-manager-for-wordpress' ), + 'desc' => wp_sprintf( esc_html__( 'Enter the Bible passage with the full book names, e.g. %s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'John 3:16-18', 'sermon-manager-for-wordpress' ) . '' ), 'id' => 'bible_passage', 'type' => 'text', ) ); $cmb->add_field( array( - 'name' => __( 'Description', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Description', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_description', 'type' => 'wysiwyg', 'options' => array( 'textarea_rows' => 7, 'media_buttons' => true, ), @@ -113,7 +113,7 @@ function wpfc_sermon_metaboxes() { $cmb2 = new_cmb2_box( array( 'id' => 'wpfc_sermon_files', - 'title' => __( 'Sermon Files', 'sermon-manager-for-wordpress' ), + 'title' => esc_html__( 'Sermon Files', 'sermon-manager-for-wordpress' ), 'object_types' => array( 'wpfc_sermon', ), // Post type 'context' => 'normal', 'priority' => 'high', @@ -122,8 +122,8 @@ function wpfc_sermon_metaboxes() { // 'closed' => true, // Keep the metabox closed by default ) ); $cmb2->add_field( array( - 'name' => __( 'Location of MP3', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Upload an audio file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Location of MP3', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload an audio file or enter an URL.', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_audio', 'type' => 'file', 'text' => array( @@ -131,40 +131,40 @@ function wpfc_sermon_metaboxes() { ), ) ); $cmb2->add_field( array( - 'name' => __( 'MP3 Duration', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Length in hh:mm:ss format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'MP3 Duration', 'sermon-manager-for-wordpress' ), + 'desc' => wp_sprintf( esc_html__( 'Length in %s format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'hh:mm:ss', 'sermon-manager-for-wordpress' ) . '' ), 'id' => '_wpfc_sermon_duration', 'type' => 'text', ) ); $cmb2->add_field( array( - 'name' => __( 'Video Embed Code', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Paste your embed code for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Video Embed Code', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Paste your embed code for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_video', 'type' => 'textarea_code' ) ); $cmb2->add_field( apply_filters( 'sm_cmb2_field_sermon_video_link', array( - 'name' => __( 'Video Link', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Paste your link for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Video Link', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Paste your link for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_video_link', 'type' => 'text' ) ) ); $cmb2->add_field( array( - 'name' => __( 'Sermon Notes', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Sermon Notes', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_notes', 'type' => 'file', 'text' => array( - 'add_upload_file_text' => 'Add File' // Change upload button text. Default: "Add or Upload File" + 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" ), ) ); $cmb2->add_field( array( - 'name' => __( 'Bulletin', 'sermon-manager-for-wordpress' ), - 'desc' => __( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'name' => esc_html__( 'Bulletin', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), 'id' => 'sermon_bulletin', 'type' => 'file', 'text' => array( - 'add_upload_file_text' => 'Add File' // Change upload button text. Default: "Add or Upload File" + 'add_upload_file_text' => esc_html__( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" ), ) ); } diff --git a/includes/sm-core-functions.php b/includes/sm-core-functions.php index 0091a59..3f1fd1a 100644 --- a/includes/sm-core-functions.php +++ b/includes/sm-core-functions.php @@ -118,12 +118,12 @@ function sm_get_permalink_structure() { ) ); // Ensure rewrite slugs are set. - $permalinks['wpfc_preacher'] = untrailingslashit( empty( $permalinks['wpfc_preacher'] ) ? _x( 'preacher', 'slug', 'sermon-manager' ) : $permalinks['wpfc_preacher'] ); - $permalinks['wpfc_sermon_series'] = untrailingslashit( empty( $permalinks['wpfc_sermon_series'] ) ? _x( 'series', 'slug', 'sermon-manager' ) : $permalinks['wpfc_sermon_series'] ); - $permalinks['wpfc_sermon_topics'] = untrailingslashit( empty( $permalinks['wpfc_sermon_topics'] ) ? _x( 'topics', 'slug', 'sermon-manager' ) : $permalinks['wpfc_sermon_topics'] ); - $permalinks['wpfc_bible_book'] = untrailingslashit( empty( $permalinks['wpfc_bible_book'] ) ? _x( 'book', 'slug', 'sermon-manager' ) : $permalinks['wpfc_bible_book'] ); - $permalinks['wpfc_service_type'] = untrailingslashit( empty( $permalinks['wpfc_service_type'] ) ? _x( 'service-type', 'slug', 'sermon-manager' ) : $permalinks['wpfc_service_type'] ); - $permalinks['wpfc_sermon'] = untrailingslashit( empty( $permalinks['wpfc_sermon'] ) ? _x( 'sermons', 'slug', 'sermon-manager' ) : $permalinks['wpfc_sermon'] ); + $permalinks['wpfc_preacher'] = untrailingslashit( empty( $permalinks['wpfc_preacher'] ) ? _x( 'preacher', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_preacher'] ); + $permalinks['wpfc_sermon_series'] = untrailingslashit( empty( $permalinks['wpfc_sermon_series'] ) ? _x( 'series', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_sermon_series'] ); + $permalinks['wpfc_sermon_topics'] = untrailingslashit( empty( $permalinks['wpfc_sermon_topics'] ) ? _x( 'topics', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_sermon_topics'] ); + $permalinks['wpfc_bible_book'] = untrailingslashit( empty( $permalinks['wpfc_bible_book'] ) ? _x( 'book', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_bible_book'] ); + $permalinks['wpfc_service_type'] = untrailingslashit( empty( $permalinks['wpfc_service_type'] ) ? _x( 'service-type', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_service_type'] ); + $permalinks['wpfc_sermon'] = untrailingslashit( empty( $permalinks['wpfc_sermon'] ) ? _x( 'sermons', 'slug', 'sermon-manager-for-wordpress' ) : $permalinks['wpfc_sermon'] ); if ( \SermonManager::getOption( 'common_base_slug' ) ) { foreach ( $permalinks as $name => &$permalink ) { @@ -174,4 +174,4 @@ function sm_restore_locale() { // Init Sermon Manager locale. SermonManager::load_translations(); } -} \ No newline at end of file +} diff --git a/includes/sm-deprecated-functions.php b/includes/sm-deprecated-functions.php index 3c68f3b..fd5d3bb 100644 --- a/includes/sm-deprecated-functions.php +++ b/includes/sm-deprecated-functions.php @@ -7,6 +7,13 @@ defined( 'ABSPATH' ) or die; // exit if accessed directly +// deprecated +define( 'SM___FILE__', __FILE__ ); +define( 'SERMON_MANAGER_PATH', SM_PATH ); +define( 'SERMON_MANAGER_URL', SM_URL ); +define( 'SERMON_MANAGER_VERSION', SM_VERSION ); + + /** * Outputs Sermon date. Wrapper for sm_the_date() * diff --git a/includes/sm-update-functions.php b/includes/sm-update-functions.php new file mode 100644 index 0000000..21b60f0 --- /dev/null +++ b/includes/sm-update-functions.php @@ -0,0 +1,98 @@ +get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) ) as $sermon ) { + if ( get_post_meta( $sermon->ID, 'sermon_date', true ) === '' && + $date = get_post_meta( $sermon->ID, 'sermon_date_old', true ) !== '' ) { + update_post_meta( $sermon->ID, 'sermon_date', is_numeric( $date ) ?: strtotime( $date ) ); + delete_post_meta( $sermon->ID, 'sermon_date_old' ); + } + } + + // clear all cached data + wp_cache_flush(); +} + +/** + * Final dates conversion for users who skipped converters in previous SM versions + * + * Basically, converts "sermon_date" value to Unix time if it's not numeric + */ +function sm_update_28_convert_dates_to_unix() { + global $wpdb; + + // All sermons + $sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) ); + + foreach ( $sermons as $sermon ) { + if ( $date = get_post_meta( $sermon->ID, 'sermon_date', true ) ) { + if ( ! is_numeric( $date ) ) { + update_post_meta( $sermon->ID, 'sermon_date', strtotime( $date ) ); + } + } + } + + // clear all cached data + wp_cache_flush(); +} + +/** + * Fills out dates of sermons that don't have `sermon_date` set. Takes "Published" date for them and marks + * them as auto-filled, so they get updated when Published date gets updated + */ +function sm_update_28_fill_out_empty_dates() { + global $wpdb; + + // All sermons + $sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_date FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('auto-draft', 'inherit')", 'wpfc_sermon' ) ); + + foreach ( $sermons as $sermon ) { + if ( get_post_meta( $sermon->ID, 'sermon_date', true ) === '' ) { + update_post_meta( $sermon->ID, 'sermon_date', strtotime( $sermon->post_date ) ); + update_post_meta( $sermon->ID, 'sermon_date_auto', '1' ); + } + } + + // clear all cached data + wp_cache_flush(); +} + +/** + * For enabling sorting by series date + * + * @see SM_Dates_WP::update_series_date() + */ +function sm_update_28_fill_out_series_dates() { + SM_Dates_WP::update_series_date(); +} + +function sm_update_28_save_sermon_render_into_post_content() { + global $wpdb; + + // All sermons + $sermons = $wpdb->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' => wp_filter_post_kses( wpfc_sermon_single( true, $sermon ) ) + ) ); + } + + // clear all cached data + wp_cache_flush(); +} diff --git a/includes/taxonomy-images/public-filters.php b/includes/taxonomy-images/public-filters.php index c684452..b03761c 100755 --- a/includes/taxonomy-images/public-filters.php +++ b/includes/taxonomy-images/public-filters.php @@ -382,10 +382,13 @@ function sermon_images_plugin_get_queried_term_image_id( $default ) { /* Return early is we are not in a term archive. */ if ( ! isset( $obj->term_taxonomy_id ) ) { - trigger_error( sprintf( esc_html__( '%1$s is not a property of the current queried object. This usually happens when the %2$s filter is used in an unsupported template file. This filter has been designed to work in taxonomy archives which are traditionally served by one of the following template files: category.php, tag.php or taxonomy.php. Learn more about %3$s.', 'sermon-manager-for-wordpress' ), + trigger_error( wp_sprintf( esc_html__( '%1$s is not a property of the current queried object. This usually happens when the %2$s filter is used in an unsupported template file. This filter has been designed to work in taxonomy archives which are traditionally served by one of the following template files: %3$s, %4$s or %5$s. Learn more about %6$s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'term_taxonomy_id', 'sermon-manager-for-wordpress' ) . '', '' . esc_html( $filter ) . '', - '' . esc_html( 'template hierarchy', 'sermon-manager' ) . '' + 'category.php', + 'tag.php', + 'taxonomy.php', + '' . esc_html__( 'template hierarchy', 'sermon-manager-for-wordpress' ) . '' ) ); return 0; @@ -558,4 +561,4 @@ function sermon_images_plugin_get_queried_term_image_data( $default, $args = arr } return array(); -} \ No newline at end of file +} diff --git a/includes/taxonomy-images/taxonomy-images.php b/includes/taxonomy-images/taxonomy-images.php old mode 100755 new mode 100644 index 9d31309..899ce1a --- a/includes/taxonomy-images/taxonomy-images.php +++ b/includes/taxonomy-images/taxonomy-images.php @@ -127,8 +127,8 @@ function sermon_image_plugin_modal_button( $fields, $post ) { $image_id = (int) $post->ID; $o = '
    '; - $o .= '' . sprintf( esc_html__( 'Associate with %1$s', 'sermon-manager' ), '' . esc_html__( 'this term', 'sermon-manager-for-wordpress' ) . '' ) . ''; - $o .= '' . sprintf( esc_html__( 'Remove association with %1$s', 'sermon-manager' ), '' . esc_html__( 'this term', 'sermon-manager-for-wordpress' ) . '' ) . ''; + $o .= '' . wp_sprintf( esc_html__( 'Associate with %1$s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'this term', 'sermon-manager-for-wordpress' ) . '' ) . ''; + $o .= '' . wp_sprintf( esc_html__( 'Remove association with %1$s', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'this term', 'sermon-manager-for-wordpress' ) . '' ) . ''; $o .= ''; $o .= ''; $o .= ''; @@ -843,9 +843,9 @@ function sermon_image_plugin_control_image( $term_id, $taxonomy ) { $thickbox_class = version_compare( get_bloginfo( 'version' ), 3.5 ) >= 0 ? '' : 'thickbox'; $o = "\n" . '
    '; - $o .= "\n" . ''; - $o .= "\n" . '' . esc_html__( 'Upload.', 'sermon-images' ) . ''; - $o .= "\n" . '' . esc_html__( 'Delete', 'sermon-images' ) . ''; + $o .= "\n" . ''; + $o .= "\n" . '' . esc_html__( 'Upload.', 'sermon-manager-for-wordpress' ) . ''; + $o .= "\n" . '' . esc_html__( 'Delete', 'sermon-manager-for-wordpress' ) . ''; $o .= "\n" . ''; $o .= "\n" . ''; @@ -879,8 +879,8 @@ function sermon_image_plugin_media_upload_popup_js() { sermon_image_plugin_version() ); wp_localize_script( 'sermon-images-media-upload-popup', 'TaxonomyImagesModal', array( - 'termBefore' => esc_html__( '“', 'sermon-manager-for-wordpress' ), - 'termAfter' => esc_html__( '”', 'sermon-manager-for-wordpress' ), + 'termBefore' => esc_html__( '“', 'sermon-manager-for-wordpress' ), + 'termAfter' => esc_html__( '”', 'sermon-manager-for-wordpress' ), 'associating' => esc_html__( 'Associating …', 'sermon-manager-for-wordpress' ), 'success' => esc_html__( 'Successfully Associated', 'sermon-manager-for-wordpress' ), 'removing' => esc_html__( 'Removing …', 'sermon-manager-for-wordpress' ), @@ -1159,7 +1159,7 @@ function sermon_image_plugin_cache_queried_images() { */ function sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) { if ( ! taxonomy_exists( $taxonomy ) ) { - trigger_error( sprintf( esc_html__( 'The %1$s argument for %2$s is set to %3$s which is not a registered taxonomy. Please check the spelling and update the argument.', 'sermon-manager-for-wordpress' ), + trigger_error( wp_sprintf( esc_html__( 'The %1$s argument for %2$s is set to %3$s which is not a registered taxonomy. Please check the spelling and update the argument.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'taxonomy', 'sermon-manager-for-wordpress' ) . '', '' . esc_html( $filter ) . '', '' . esc_html( $taxonomy ) . '' @@ -1171,13 +1171,13 @@ function sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) { $settings = get_option( 'sermon_image_plugin_settings' ); if ( ! isset( $settings['taxonomies'] ) ) { - trigger_error( sprintf( esc_html__( 'No taxonomies have image support. %1$s', 'sermon-manager-for-wordpress' ), sermon_images_plugin_settings_page_link() ) ); + trigger_error( wp_sprintf( esc_html__( 'No taxonomies have image support. %1$s', 'sermon-manager-for-wordpress' ), sermon_images_plugin_settings_page_link() ) ); return false; } if ( ! in_array( $taxonomy, (array) $settings['taxonomies'] ) ) { - trigger_error( sprintf( esc_html__( 'The %1$s taxonomy does not have image support. %2$s', 'sermon-manager-for-wordpress' ), + trigger_error( wp_sprintf( esc_html__( 'The %1$s taxonomy does not have image support. %2$s', 'sermon-manager-for-wordpress' ), '' . esc_html( $taxonomy ) . '', sermon_images_plugin_settings_page_link() ) ); @@ -1203,7 +1203,7 @@ function sermon_image_plugin_check_taxonomy( $taxonomy, $filter ) { * @since 0.7 */ function sermon_image_plugin_please_use_filter( $function, $filter ) { - trigger_error( sprintf( esc_html__( 'The %1$s has been called directly. Please use the %2$s filter instead.', 'sermon-manager-for-wordpress' ), + trigger_error( wp_sprintf( esc_html__( 'The %1$s has been called directly. Please use the %2$s filter instead.', 'sermon-manager-for-wordpress' ), '' . esc_html( $function . '()' ) . '', '' . esc_html( $filter ) . '' ) ); @@ -1299,10 +1299,10 @@ function sermon_images_admin_enqueue_scripts() { wp_localize_script( 'sermon-images-media-modal', 'taxonomyImagesMediaModal', array( 'wp_media_post_id' => 0, 'attachment_id' => 0, - 'uploader_title' => __( 'Set ' . ( \SermonManager::getOption( 'preacher_label' ) ?: 'Preacher' ) . '\'s image', 'sermon-manager-for-wordpress' ), - 'uploader_button_text' => __( 'Set ' . ( \SermonManager::getOption( 'preacher_label' ) ?: 'Preacher' ) . '\'s image', 'sermon-manager-for-wordpress' ), - 'series_title' => __( 'Set Series image', 'sermon-manager-for-wordpress' ), - 'series_button_text' => __( 'Set Series image', 'sermon-manager-for-wordpress' ), + 'uploader_title' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? : esc_html__ ( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'uploader_button_text' => wp_sprintf( esc_html__( 'Set %s’s image', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? : esc_html__ ( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'series_title' => esc_html__( 'Set Series image', 'sermon-manager-for-wordpress' ), + 'series_button_text' => esc_html__( 'Set Series image', 'sermon-manager-for-wordpress' ), 'default_img_src' => sermon_image_plugin_url( 'default.png' ) ) ); diff --git a/includes/template-tags.php b/includes/template-tags.php index 0b602b6..540df0f 100755 --- a/includes/template-tags.php +++ b/includes/template-tags.php @@ -17,8 +17,6 @@ add_action( 'sermon_audio', 'wpfc_sermon_audio', 5 ); add_action( 'sermon_single', 'wpfc_sermon_single' ); add_action( 'sermon_excerpt', 'wpfc_sermon_excerpt' ); -// Add sermon content -add_filter( 'the_content', 'add_wpfc_sermon_content' ); // Include template for displaying sermons function sermon_template_include( $template ) { @@ -28,13 +26,13 @@ function sermon_template_include( $template ) { return get_stylesheet_directory() . '/archive-wpfc_sermon.php'; } - return SERMON_MANAGER_PATH . 'views/archive-wpfc_sermon.php'; + return SM_PATH . 'views/archive-wpfc_sermon.php'; else : if ( file_exists( get_stylesheet_directory() . '/single-wpfc_sermon.php' ) ) { return get_stylesheet_directory() . '/single-wpfc_sermon.php'; } - return SERMON_MANAGER_PATH . 'views/single-wpfc_sermon.php'; + return SM_PATH . 'views/single-wpfc_sermon.php'; endif; } @@ -48,7 +46,7 @@ function sermon_topics_template_include( $template ) { return get_stylesheet_directory() . '/taxonomy-wpfc_sermon_topics.php'; } - return SERMON_MANAGER_PATH . 'views/taxonomy-wpfc_sermon_topics.php'; + return SM_PATH . 'views/taxonomy-wpfc_sermon_topics.php'; } return $template; @@ -61,7 +59,7 @@ function preacher_template_include( $template ) { return get_stylesheet_directory() . '/taxonomy-wpfc_preacher.php'; } - return SERMON_MANAGER_PATH . 'views/taxonomy-wpfc_preacher.php'; + return SM_PATH . 'views/taxonomy-wpfc_preacher.php'; } return $template; @@ -74,7 +72,7 @@ function series_template_include( $template ) { return get_stylesheet_directory() . '/taxonomy-wpfc_sermon_series.php'; } - return SERMON_MANAGER_PATH . 'views/taxonomy-wpfc_sermon_series.php'; + return SM_PATH . 'views/taxonomy-wpfc_sermon_series.php'; } return $template; @@ -87,7 +85,7 @@ function service_type_template_include( $template ) { return get_stylesheet_directory() . '/taxonomy-wpfc_service_type.php'; } - return SERMON_MANAGER_PATH . 'views/taxonomy-wpfc_service_type.php'; + return SM_PATH . 'views/taxonomy-wpfc_service_type.php'; } return $template; @@ -100,7 +98,7 @@ function bible_book_template_include( $template ) { return get_stylesheet_directory() . '/taxonomy-wpfc_bible_book.php'; } - return SERMON_MANAGER_PATH . 'views/taxonomy-wpfc_bible_book.php'; + return SM_PATH . 'views/taxonomy-wpfc_bible_book.php'; } return $template; @@ -180,21 +178,21 @@ function render_wpfc_sorting( $args = array() ) {
    - +
    - +
    @@ -382,8 +380,13 @@ function render_wpfc_sermon_single() { } // single sermon action -function wpfc_sermon_single() { - global $post; ?> +function wpfc_sermon_single( $return = false, $post = '' ) { + if ( $post === '' ){ + global $post; + } + + ob_start(); + ?>
    @@ -410,10 +413,17 @@ function wpfc_sermon_single() { - ID, 'wpfc_sermon_topics', '

    ' . __( 'Sermon Topics: ', 'sermon-manager-for-wordpress' ), ',', '', '

    ' ); ?> + ID, 'wpfc_sermon_topics', '

    ' . __( 'Sermon Topics: ', 'sermon-manager-for-wordpress' ), ',', '

    ' ); ?>
    - +

    @@ -551,7 +561,12 @@ function wpfc_get_term_dropdown( $taxonomy, $default = '' ) { // reset var $html = ''; - foreach ( get_terms( $taxonomy ) as $term ) { + foreach ( + get_terms( array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, // todo: add option to disable/enable this globally + ) ) as $term + ) { $html .= ''; } diff --git a/includes/types-taxonomies.php b/includes/types-taxonomies.php new file mode 100644 index 0000000..6b9d5d1 --- /dev/null +++ b/includes/types-taxonomies.php @@ -0,0 +1,408 @@ +slug; + + wp_set_object_terms( $post_ID, $service_type, 'wpfc_service_type' ); + } + + return $post; + } +} + +/* + * Creation of Sermon Post Types and Taxonomies + * Also all meta boxes + */ + +// Determine the correct slug name based on options +function generate_wpfc_slug( $slug_name = null ) { + if ( trim( \SermonManager::getOption( 'archive_slug' ) ) === '' ) { + $archive_slug = 'sermons'; + } else { + $archive_slug = \SermonManager::getOption( 'archive_slug' ); + } + + if ( ! isset( $slug_name ) ) { + return array( 'slug' => $archive_slug, 'with_front' => false ); + } + + if ( \SermonManager::getOption( 'common_base_slug' ) ) { + return array( 'slug' => $archive_slug . "/" . $slug_name, 'with_front' => false ); + } else { + return array( 'slug' => $slug_name, 'with_front' => false ); + } +} + +// Create sermon Custom Post Type +function create_wpfc_sermon_types() { + + $labels = array( + 'name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), + 'singular_name' => __( 'Sermon', 'sermon-manager-for-wordpress' ), + 'add_new' => __( 'Add New', 'sermon-manager-for-wordpress' ), + 'add_new_item' => __( 'Add New Sermon', 'sermon-manager-for-wordpress' ), + 'edit_item' => __( 'Edit Sermon', 'sermon-manager-for-wordpress' ), + 'new_item' => __( 'New Sermon', 'sermon-manager-for-wordpress' ), + 'view_item' => __( 'View Sermon', 'sermon-manager-for-wordpress' ), + 'search_items' => __( 'Search Sermons', 'sermon-manager-for-wordpress' ), + 'not_found' => __( 'No sermons found', 'sermon-manager-for-wordpress' ), + 'not_found_in_trash' => __( 'No sermons found in Trash', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Sermons', 'sermon-manager-for-wordpress' ), + ); + + $args = array( + 'labels' => $labels, + 'public' => true, + 'publicly_queryable' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'query_var' => true, + 'menu_icon' => SM_URL . 'includes/img/sm-icon.svg', + 'capability_type' => 'post', + 'has_archive' => true, + 'rewrite' => generate_wpfc_slug(), + 'hierarchical' => false, + 'supports' => array( 'title', 'comments', 'thumbnail', 'entry-views' ) + ); + register_post_type( 'wpfc_sermon', $args ); +} + +// Create new taxonomies: preachers, sermon series, bible books & topics +function create_wpfc_sermon_taxonomies() { + + //Preachers + $labels = array( + 'name' => \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ), + 'singular_name' => \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Preachers', 'sermon-manager-for-wordpress' ), + 'search_items' => wp_sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'popular_items' => wp_sprintf( __( 'Most frequent %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'all_items' => wp_sprintf( __( 'All %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), + 'edit_item' => wp_sprintf( __( 'Edit %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'update_item' => wp_sprintf( __( 'Update %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'add_new_item' => wp_sprintf( __( 'Add new %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'new_item_name' => wp_sprintf( __( 'New %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'separate_items_with_commas' => wp_sprintf( __( 'Separate multiple %s with commas', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), + 'add_or_remove_items' => wp_sprintf( __( 'Add or remove %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preacher', 'sermon-manager-for-wordpress' ) ), + 'choose_from_most_used' => wp_sprintf( __( 'Choose from most frequent %s', 'sermon-manager-for-wordpress' ), \SermonManager::getOption( 'preacher_label' ) ? \SermonManager::getOption( 'preacher_label' ) : __( 'Preachers', 'sermon-manager-for-wordpress' ) ), + 'parent_item' => null, + 'parent_item_colon' => null, + ); + + register_taxonomy( 'wpfc_preacher', 'wpfc_sermon', array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'query_var' => true, + 'rewrite' => generate_wpfc_slug( \SermonManager::getOption( 'preacher_label' ) ? sanitize_title( \SermonManager::getOption( 'preacher_label' ) ) : 'preacher' ), + ) ); + + //Sermon Series + $labels = array( + 'name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), + 'singular_name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Sermon Series', 'sermon-manager-for-wordpress' ), + 'search_items' => __( 'Search sermon series', 'sermon-manager-for-wordpress' ), + 'popular_items' => __( 'Most frequent sermon series', 'sermon-manager-for-wordpress' ), + 'all_items' => __( 'All sermon series', 'sermon-manager-for-wordpress' ), + 'edit_item' => __( 'Edit sermon series', 'sermon-manager-for-wordpress' ), + 'update_item' => __( 'Update sermon series', 'sermon-manager-for-wordpress' ), + 'add_new_item' => __( 'Add new sermon series', 'sermon-manager-for-wordpress' ), + 'new_item_name' => __( 'New sermon series name', 'sermon-manager-for-wordpress' ), + 'separate_items_with_commas' => __( 'Separate sermon series with commas', 'sermon-manager-for-wordpress' ), + 'add_or_remove_items' => __( 'Add or remove sermon series', 'sermon-manager-for-wordpress' ), + 'choose_from_most_used' => __( 'Choose from most used sermon series', 'sermon-manager-for-wordpress' ), + 'parent_item' => null, + 'parent_item_colon' => null, + ); + + register_taxonomy( 'wpfc_sermon_series', 'wpfc_sermon', array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'query_var' => true, + 'rewrite' => generate_wpfc_slug( 'series' ), + ) ); + + //Sermon Topics + $labels = array( + 'name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), + 'singular_name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Sermon Topics', 'sermon-manager-for-wordpress' ), + 'search_items' => __( 'Search sermon topics', 'sermon-manager-for-wordpress' ), + 'popular_items' => __( 'Most popular sermon topics', 'sermon-manager-for-wordpress' ), + 'all_items' => __( 'All sermon topics', 'sermon-manager-for-wordpress' ), + 'edit_item' => __( 'Edit sermon topic', 'sermon-manager-for-wordpress' ), + 'update_item' => __( 'Update sermon topic', 'sermon-manager-for-wordpress' ), + 'add_new_item' => __( 'Add new sermon topic', 'sermon-manager-for-wordpress' ), + 'new_item_name' => __( 'New sermon topic', 'sermon-manager-for-wordpress' ), + 'separate_items_with_commas' => __( 'Separate sermon topics with commas', 'sermon-manager-for-wordpress' ), + 'add_or_remove_items' => __( 'Add or remove sermon topics', 'sermon-manager-for-wordpress' ), + 'choose_from_most_used' => __( 'Choose from most used sermon topics', 'sermon-manager-for-wordpress' ), + 'parent_item' => null, + 'parent_item_colon' => null, + ); + + register_taxonomy( 'wpfc_sermon_topics', 'wpfc_sermon', array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'query_var' => true, + 'rewrite' => generate_wpfc_slug( 'topics' ), + ) ); + + //Books of the Bible + $labels = array( + 'name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), + 'singular_name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Book of the Bible', 'sermon-manager-for-wordpress' ), + 'search_items' => __( 'Search books of the Bible', 'sermon-manager-for-wordpress' ), + 'popular_items' => __( 'Most popular books of the Bible', 'sermon-manager-for-wordpress' ), + 'all_items' => __( 'All books of the Bible', 'sermon-manager-for-wordpress' ), + 'edit_item' => __( 'Edit book of the Bible', 'sermon-manager-for-wordpress' ), + 'update_item' => __( 'Update book of the Bible', 'sermon-manager-for-wordpress' ), + 'add_new_item' => __( 'Add new books of the Bible', 'sermon-manager-for-wordpress' ), + 'new_item_name' => __( 'New book of the Bible', 'sermon-manager-for-wordpress' ), + 'separate_items_with_commas' => __( 'Separate books of the Bible with commas', 'sermon-manager-for-wordpress' ), + 'add_or_remove_items' => __( 'Add or remove books of the Bible', 'sermon-manager-for-wordpress' ), + 'choose_from_most_used' => __( 'Choose from most used books of the Bible', 'sermon-manager-for-wordpress' ), + 'parent_item' => null, + 'parent_item_colon' => null, + ); + + register_taxonomy( 'wpfc_bible_book', 'wpfc_sermon', array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'query_var' => true, + 'rewrite' => generate_wpfc_slug( 'book' ), + ) ); + + //Service Type + $labels = array( + 'name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), + 'singular_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), + 'menu_name' => __( 'Service Type', 'sermon-manager-for-wordpress' ), + 'search_items' => __( 'Search service types', 'sermon-manager-for-wordpress' ), + 'popular_items' => __( 'Most popular service types', 'sermon-manager-for-wordpress' ), + 'all_items' => __( 'All service types', 'sermon-manager-for-wordpress' ), + 'edit_item' => __( 'Edit service type', 'sermon-manager-for-wordpress' ), + 'update_item' => __( 'Update service type', 'sermon-manager-for-wordpress' ), + 'add_new_item' => __( 'Add new service types', 'sermon-manager-for-wordpress' ), + 'new_item_name' => __( 'New Service Type', 'sermon-manager-for-wordpress' ), + 'separate_items_with_commas' => __( 'Separate service types with commas', 'sermon-manager-for-wordpress' ), + 'add_or_remove_items' => __( 'Add or remove service types', 'sermon-manager-for-wordpress' ), + 'choose_from_most_used' => __( 'Choose from most used service types', 'sermon-manager-for-wordpress' ), + 'parent_item' => null, + 'parent_item_colon' => null, + ); + + register_taxonomy( 'wpfc_service_type', 'wpfc_sermon', array( + 'hierarchical' => false, + 'labels' => $labels, + 'show_ui' => true, + 'query_var' => true, + 'rewrite' => generate_wpfc_slug( 'service-type' ), + ) ); +} + +/** + * Gets a number of terms and displays them as options + * + * @param string $taxonomy Taxonomy terms to retrieve. Default is category. + * @param string|array $args Optional. get_terms optional arguments + * + * @return array An array of options that matches the CMB2 options array + */ +function cmb2_get_term_options( $taxonomy = 'category' ) { + + $args['taxonomy'] = $taxonomy; + + // $defaults = array( 'taxonomy' => 'category' ); + + $taxonomy = $args['taxonomy']; + + $args = array( + 'hide_empty' => false + ); + + $terms = (array) get_terms( $taxonomy, $args ); + + // Initate an empty array + $term_options = array(); + if ( ! empty( $terms ) ) { + foreach ( $terms as $term ) { + $term_options[ $term->term_id ] = $term->name; + } + } + + return $term_options; +} + +// sanitize the field +add_filter( 'cmb2_sanitize_text_number', 'sm_cmb2_sanitize_text_number', 10, 2 ); +function sm_cmb2_sanitize_text_number( $null, $new ) { + $new = preg_replace( "/[^0-9]/", "", $new ); + + return $new; +} + +// Define the metabox and field configurations +function wpfc_sermon_metaboxes() { + + $cmb = new_cmb2_box( array( + 'id' => 'wpfc_sermon_details', + 'title' => esc_html__( 'Sermon Details', 'sermon-manager-for-wordpress' ), + 'object_types' => array( 'wpfc_sermon', ), // Post type + 'context' => 'normal', + 'priority' => 'high', + 'show_names' => true, // Show field names on the left + // 'cmb_styles' => false, // false to disable the CMB stylesheet + // 'closed' => true, // Keep the metabox closed by default + ) ); + + $date_format = 'm/d/Y'; + if ( \SermonManager::getOption( 'date_format' ) !== '' ) { + switch ( \SermonManager::getOption( 'date_format' ) ) { + case '0': + $date_format = 'm/d/Y'; + break; + case '1': + $date_format = 'd/m/Y'; + break; + case '2': + $date_format = 'Y/m/d'; + break; + case '3': + $date_format = 'Y/d/m'; + break; + } + } + + $cmb->add_field( array( + 'name' => esc_html__( 'Date Preached', 'sermon-manager-for-wordpress' ), + 'desc' => '
    ' . wp_sprintf( esc_html__( 'format: %s', 'sermon-manager-for-wordpress' ), '' . $date_format . '' ), + 'id' => 'sermon_date', + 'type' => 'text_date_timestamp', + 'date_format' => $date_format, + ) ); + + $cmb->add_field( array( + 'name' => esc_html__( 'Service Type', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Select the type of service. Modify service types in Sermons → Service Types.', 'sermon-manager-for-wordpress' ), + 'id' => 'wpfc_service_type', + 'type' => 'select', + 'show_option_none' => true, + 'options' => cmb2_get_term_options( 'wpfc_service_type' ), + ) ); + $cmb->add_field( array( + 'name' => esc_html__( 'Main Bible Passage', 'sermon-manager-for-wordpress' ), + 'desc' => wp_sprintf( esc_html__( 'Enter the Bible passage with the full book names, e.g. %s.', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'John 3:16-18', 'sermon-manager-for-wordpress' ) . '' ), + 'id' => 'bible_passage', + 'type' => 'text', + ) ); + $cmb->add_field( array( + 'name' => esc_html__( 'Description', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_description', + 'type' => 'wysiwyg', + 'options' => array( 'textarea_rows' => 7, 'media_buttons' => true, ), + ) ); + + $cmb2 = new_cmb2_box( array( + 'id' => 'wpfc_sermon_files', + 'title' => esc_html__( 'Sermon Files', 'sermon-manager-for-wordpress' ), + 'object_types' => array( 'wpfc_sermon', ), // Post type + 'context' => 'normal', + 'priority' => 'high', + 'show_names' => true, // Show field names on the left + // 'cmb_styles' => false, // false to disable the CMB stylesheet + // 'closed' => true, // Keep the metabox closed by default + ) ); + $cmb2->add_field( array( + 'name' => esc_html__( 'Location of MP3', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload an audio file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_audio', + 'type' => 'file', + 'text' => array( + 'add_upload_file_text' => __( 'Add Sermon Audio', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" + ), + ) ); + $cmb2->add_field( array( + 'name' => esc_html__( 'MP3 Duration', 'sermon-manager-for-wordpress' ), + 'desc' => wp_sprintf( esc_html__( 'Length in %s format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager-for-wordpress' ), '' . esc_html__( 'hh:mm:ss', 'sermon-manager-for-wordpress' ) . '' ), + 'id' => '_wpfc_sermon_duration', + 'type' => 'text', + ) ); + $cmb2->add_field( array( + 'name' => esc_html__( 'Video Embed Code', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Paste your embed code for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_video', + 'type' => 'textarea_code' + ) ); + $cmb2->add_field( apply_filters( 'sm_cmb2_field_sermon_video_link', array( + 'name' => esc_html__( 'Video Link', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Paste your link for Vimeo, Youtube, or other service here', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_video_link', + 'type' => 'text' + ) ) + ); + $cmb2->add_field( array( + 'name' => esc_html__( 'Sermon Notes', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_notes', + 'type' => 'file', + 'text' => array( + 'add_upload_file_text' => __( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" + ), + ) ); + $cmb2->add_field( array( + 'name' => esc_html__( 'Bulletin', 'sermon-manager-for-wordpress' ), + 'desc' => esc_html__( 'Upload a pdf file or enter an URL.', 'sermon-manager-for-wordpress' ), + 'id' => 'sermon_bulletin', + 'type' => 'file', + 'text' => array( + 'add_upload_file_text' => __( 'Add File', 'sermon-manager-for-wordpress' ) // Change upload button text. Default: "Add or Upload File" + ), + ) ); + +} + +/** + * Build