Skip to content

Commit

Permalink
Merge branch 'release/2.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola committed Dec 19, 2017
2 parents ed1640e + 373dc18 commit 3e0c8e2
Show file tree
Hide file tree
Showing 23 changed files with 433 additions and 274 deletions.
9 changes: 0 additions & 9 deletions assets/css/bibly.min.css

This file was deleted.

42 changes: 42 additions & 0 deletions assets/js/admin/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Hide or show fields on checkbox change
*/
jQuery('#enable_podcast_redirection').change(function () {
podcast_redirect(this.checked);
});

/**
* Hide or show the fields on document load
*/
jQuery(document).ready(function () {
var check = jQuery('#enable_podcast_redirection');

if (check.length) {
podcast_redirect(check.is(':checked'));
}
});

/**
* Shows or hides podcast redirection fields
*
* @param {bool} show True to show, false to hide
*/
function podcast_redirect(show) {
if (typeof(show) !== 'boolean')
return;

var el = [
jQuery('#podcast_redirection_old_url'),
jQuery('#podcast_redirection_new_url')
];

for (var i = 0; i < el.length; i++) {
var temp = el[i];

while (!temp.is("tr")) {
temp = temp.parent();
}

show ? temp.show() : temp.hide();
}
}
54 changes: 0 additions & 54 deletions assets/js/bibly.min.js

This file was deleted.

11 changes: 11 additions & 0 deletions assets/js/verse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var refTagger = {
settings: {
bibleVersion: verse.bible_version
}
};

(function (d, t) {
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = "//api.reftagger.com/v2/RefTagger.js";
s.parentNode.insertBefore(g, s);
}(document, "script"));
4 changes: 2 additions & 2 deletions includes/CMB2/includes/CMB2_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(), '', SM_URL ) . 'includes/CMB2/' . $path;
return str_replace( home_url(), '', SM_URL ) . 'includes/CMB2/' . $path;

if ( self::$url ) {
return self::$url . $path;
Expand Down Expand Up @@ -318,7 +318,7 @@ public static function get_url_from_dir( $dir ) {
// Check to see if it's anywhere in the root directory

$site_dir = self::normalize_path( self::$ABSPATH );
$site_url = trailingslashit( is_multisite() ? network_site_url() : site_url() );
$site_url = trailingslashit( is_multisite() ? network_home_url() : home_url() );

$url = str_replace(
array( $site_dir, WP_PLUGIN_DIR ),
Expand Down
9 changes: 8 additions & 1 deletion includes/admin/class-sm-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static function get_settings_pages() {
* Save the settings.
*/
public static function save() {
global $current_tab;
global $current_tab, $wpdb;

if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'sm-settings' ) ) {
die( __( 'Action failed. Please refresh the page and retry.', 'sermon-manager-for-wordpress' ) );
Expand All @@ -127,6 +127,13 @@ public static function save() {
// Clear any unwanted data and flush rules
wp_schedule_single_event( time(), 'sm_flush_rewrite_rules' );

/**
* Pass any false value to `sm_clear_feed_transients` filter to skip clearing transients
*/
if ( $current_tab === 'podcast' && apply_filters( 'sm_clear_feed_transients', true ) ) {
$wpdb->query( "DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_feed_%') OR `option_name` LIKE ('_transient_timeout_feed_%')" );
}

do_action( 'sm_settings_saved' );
}

Expand Down
16 changes: 13 additions & 3 deletions includes/admin/import/class-sm-import-sb.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,11 @@ private function _import_sermons() {
// Imported sermons
$imported = get_option( '_sm_import_sb_messages', array() );

// media upload directory
$media = wp_get_upload_dir();
// SB options
$options = get_option( 'sermonbrowser_options', array(
'upload_dir' => 'wp-content/uploads/sermons/',
) );
$options = is_array( $options ) ? $options : base64_decode( $options );

/**
* Filter sermons that will be imported
Expand Down Expand Up @@ -261,7 +264,7 @@ private function _import_sermons() {

if ( in_array( pathinfo( $url, PATHINFO_EXTENSION ), array( 'mp3', 'wav', 'ogg' ) ) ) {
if ( parse_url( $url, PHP_URL_SCHEME ) === null ) {
$url = $media['baseurl'] . '/media/audio/' . rawurlencode( $url );
$url = home_url( ( ! empty( $options['upload_dir'] ) ? $options['upload_dir'] : 'wp-content/uploads/sermons/' ) . rawurlencode( $url ) );
}

update_post_meta( $id, 'sermon_audio', $url );
Expand All @@ -288,6 +291,9 @@ private function _import_sermons() {
// set date
update_post_meta( $id, 'sermon_date', strtotime( $sermon->datetime ) );
update_post_meta( $id, 'sermon_date_auto', '1' );

// set views
update_post_meta( $id, 'Views', $wpdb->get_var( "SELECT SUM(`count`) FROM {$wpdb->prefix}sb_stuff WHERE `sermon_id` = '{$sermon->id}'" ) );
}

// update term counts
Expand All @@ -301,6 +307,10 @@ private function _import_sermons() {
) {
$terms = array();

if ( empty( $this->{$terms_array} ) ) {
continue;
}

foreach ( $this->{$terms_array} as $item ) {
$terms[] = intval( $item['new_id'] );
}
Expand Down
4 changes: 4 additions & 0 deletions includes/admin/import/class-sm-import-se.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ private function _import_messages() {
) {
$terms = array();

if ( empty( $this->{$terms_array} ) ) {
continue;
}

foreach ( $this->{$terms_array} as $item ) {
$terms[] = intval( $item['new_id'] );
}
Expand Down
15 changes: 11 additions & 4 deletions includes/admin/settings/class-sm-settings-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ public function get_settings() {
'id' => 'archive_player',
),
array(
'title' => __( 'Use old audio player', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'desc' => __( 'Use old audio player', 'sermon-manager-for-wordpress' ),
'id' => 'use_old_player',
'title' => __( 'Audio Player', 'sermon-manager-for-wordpress' ),
'type' => 'select',
'desc' => __( 'Select which player to use for playing Sermons', 'sermon-manager-for-wordpress' ),
'id' => 'player',
'options' => array(
'plyr' => 'Plyr',
'mediaelement' => 'Mediaelement',
'wordpress' => 'Old WordPress player',
'none' => 'Browser HTML5',
),
'default' => 'plyr',
),
array(
'title' => __( 'Custom label for &ldquo;Preacher&rdquo;', 'sermon-manager-for-wordpress' ),
Expand Down
29 changes: 24 additions & 5 deletions includes/admin/settings/class-sm-settings-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,28 @@ public function get_settings() {
'desc_tip' => wp_sprintf( __( 'For more info on PodTrac or to sign up for an account, visit %s', 'sermon-manager-for-wordpress' ), '<a href="http://podtrac.com">podtrac.com</a>' ),
),
array(
'title' => __( 'HTML in description', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'id' => 'enable_podcast_html_description',
'desc' => __( 'Enables showing of HTML in iTunes description field. Uncheck if description looks messy.', 'sermon-manager-for-wordpress' ),
'title' => __( 'HTML in description', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'id' => 'enable_podcast_html_description',
'desc' => __( 'Enables showing of HTML in iTunes description field. Uncheck if description looks messy.', 'sermon-manager-for-wordpress' ),
'desc_tip' => __( 'It is recommended to leave it unchecked.', 'sermon-manager-for-wordpress' ),
),
array(
'title' => __( 'Redirect', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'id' => 'enable_podcast_redirection',
'desc' => __( 'Enables redirection of podcast from old to new URL.', 'sermon-manager-for-wordpress' ),
'desc_tip' => __( 'You can use relative or absolute URLs.', 'sermon-manager-for-wordpress' ),
),
array(
'title' => __( 'Old URL', 'sermon-manager-for-wordpress' ),
'type' => 'text',
'id' => 'podcast_redirection_old_url',
),
array(
'title' => __( 'New URL', 'sermon-manager-for-wordpress' ),
'type' => 'text',
'id' => 'podcast_redirection_new_url',
),
array(
'title' => __( 'Number of podcasts to show', 'sermon-manager-for-wordpress' ),
Expand All @@ -159,7 +177,8 @@ public function after() {
<div>
<p>
<label for="feed_url"><?= __( 'Feed URL to Submit to iTunes', 'sermon-manager-for-wordpress' ) ?></label>
<input type="text" disabled="disabled" value="<?= home_url( '/' ) . '?feed=rss2&post_type=wpfc_sermon' ?>" id="feed_url">
<input type="text" disabled="disabled"
value="<?= home_url( '/' ) . '?feed=rss2&post_type=wpfc_sermon' ?>" id="feed_url">
</p>
<p>
<?= // translators: %s Feed Validator link, see msgid "Feed Validator"
Expand Down
30 changes: 20 additions & 10 deletions includes/admin/settings/class-sm-settings-verse.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,33 @@ public function get_settings() {
array(
'title' => __( 'Verse Popups', 'sermon-manager-for-wordpress' ),
'type' => 'checkbox',
'desc' => __( 'Disable Bib.ly verse popups', 'sermon-manager-for-wordpress' ),
'id' => 'bibly',
'desc' => __( 'Disable verse popups', 'sermon-manager-for-wordpress' ),
'id' => 'verse_popup',
'default' => 'no',
),
array(
'title' => __( 'Bible Version for Verse Popups', 'sermon-manager-for-wordpress' ),
'type' => 'select',
// translators: %s see effectively <code>ESV</code>
'desc' => wp_sprintf( __( 'Warning! %s is not supported if your site uses SSL (HTTPS).', 'sermon-manager-for-wordpress' ), '<code>ESV</code>' ),
'id' => 'bibly_version',
'id' => 'verse_bible_version',
'options' => array(
'KJV' => 'KJV',
'ESV' => 'ESV',
'NET' => 'NET',
'LEB' => 'LEB'
'AMP' => 'Amplified Bible (AMP)',
'ASV' => 'American Standard Version (ASV)',
'DAR' => 'Darby',
'ESV' => 'English Standard Version (ESV)',
'GW' => 'God\'s Word',
'HCSB' => 'Holman Christian Standard Bible (HCSB)',
'KJV' => 'King James Version (KJV)',
'LEB' => 'Lexham English Bible (LEB)',
'MESSAGE' => 'Message Bible',
'NASB' => 'New American Standard Bible (NASB)',
'NCV' => 'New Century Version (NCV)',
'NIRV' => 'New International Reader\'s Version (NIRV)',
'NKJV' => 'New King James Version (NKJV)',
'NLT' => 'New Living Translation (NLT)',
'DOUAYRHEIMS' => 'Douay-Rheims',
'YLT' => 'Young\'s Literal Translation (YLT)',
),
'default' => 'KJV',
'default' => 'ESV',
),
array(
'title' => __( 'Show key verse in widget', 'sermon-manager-for-wordpress' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/views/html-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$current_tab = empty( $current_tab ) ? 'general' : $current_tab;
?>
<div class="wrap sm">
<div class="wrap sm sm_settings_<?=$current_tab?>">
<div class="intro">
<h1 class="wp-heading-inline">Sermon Manager Settings</h1>
</div>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-sm-dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function get( $format = '', $post = null, $force_unix_sanitation =
}

// Format it
$date = date( $format, $date );
$date = date_i18n( $format, $date );

/**
* Filters the date a post was preached
Expand Down
67 changes: 36 additions & 31 deletions includes/class-sm-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class SM_Install {
'2.9.3' => array(
'sm_update_293_fix_import_dates',
),
'2.10' => array(
'sm_update_210_update_options'
),
);

/** @var object Background update class */
Expand All @@ -46,7 +49,9 @@ public static function init() {
* This check is done on all requests and runs if the versions do not match
*/
public static function check_version() {
if ( ! defined( 'IFRAME_REQUEST' ) && ( ( isset( $GLOBALS['sm_force_update'] ) && $GLOBALS['sm_force_update'] === true ) || get_option( 'sm_version' ) !== SM_VERSION ) ) {
global $pagenow;

if ( ! defined( 'IFRAME_REQUEST' ) && (( $pagenow === 'plugins.php' && isset($_GET['activate']) && $_GET['activate'] === 'true' ) || get_option( 'sm_version' ) !== SM_VERSION ) ) {
self::_install();
do_action( 'sm_updated' );
}
Expand Down Expand Up @@ -106,6 +111,36 @@ private static function _install() {
do_action( 'sm_installed' );
}

/**
* Default options.
*
* Sets up the default options used on the settings page.
*
* @since 2.10
*/
private static function _create_options() {
// Include settings so that we can run through defaults
include_once 'admin/class-sm-admin-settings.php';

$settings = SM_Admin_Settings::get_settings_pages();

foreach ( $settings as $section ) {
if ( ! method_exists( $section, 'get_settings' ) ) {
continue;
}
$subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );

foreach ( $subsections as $subsection ) {
foreach ( $section->get_settings( $subsection ) as $value ) {
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
}
}
}
}
}

/**
* Push all needed DB updates to the queue for processing.
*/
Expand Down Expand Up @@ -208,36 +243,6 @@ public static function plugin_row_meta( $links, $file ) {

return (array) $links;
}

/**
* Default options.
*
* Sets up the default options used on the settings page.
*
* @since 2.10
*/
private static function _create_options() {
// Include settings so that we can run through defaults
include_once 'admin/class-sm-admin-settings.php';

$settings = SM_Admin_Settings::get_settings_pages();

foreach ( $settings as $section ) {
if ( ! method_exists( $section, 'get_settings' ) ) {
continue;
}
$subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );

foreach ( $subsections as $subsection ) {
foreach ( $section->get_settings( $subsection ) as $value ) {
if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
$autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
}
}
}
}
}
}

SM_Install::init();
Loading

0 comments on commit 3e0c8e2

Please sign in to comment.