Skip to content

Commit

Permalink
Revert deleted code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Miljković committed Mar 2, 2018
1 parent 66a9071 commit 36eb00f
Showing 1 changed file with 54 additions and 22 deletions.
76 changes: 54 additions & 22 deletions sermons.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,16 @@ public function __construct() {

$skip_content_check = true;

$sm = SermonManager::get_instance();

// All sermons
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );

foreach ( $sermons as $sermon ) {
$sermon_ID = $sermon->ID;

if ( $value === 11 ) {
$this->render_sermon_into_content( $sermon_ID, null, true );
$sm->render_sermon_into_content( $sermon_ID, null, true );
} else {
$wpdb->query( "UPDATE $wpdb->posts SET `post_content` = '' WHERE `ID` = $sermon_ID" );
}
Expand All @@ -263,14 +265,16 @@ public function __construct() {

$skip_excerpt_check = true;

$sm = SermonManager::get_instance();

// All sermons
$sermons = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s", 'wpfc_sermon' ) );

foreach ( $sermons as $sermon ) {
$sermon_ID = $sermon->ID;

if ( $value === 11 ) {
$this->render_sermon_into_content( $sermon_ID, null, true );
$sm->render_sermon_into_content( $sermon_ID, null, true );
} else {
$wpdb->query( "UPDATE $wpdb->posts SET `post_excerpt` = '' WHERE `ID` = $sermon_ID" );
}
Expand Down Expand Up @@ -309,7 +313,7 @@ private function _includes() {
'includes/entry-views.php', // Entry Views Tracking
'includes/shortcodes.php', // Shortcodes
'includes/widgets.php', // Widgets
'includes/template-tags.php', // Template Tags
'includes/sm-template-functions.php', // Template functions
'includes/podcast-functions.php', // Podcast Functions
'includes/helper-functions.php', // Global Helper Functions
);
Expand Down Expand Up @@ -356,6 +360,19 @@ public static function getOption( $name = '', $default = '' ) {
return SM_Admin_Settings::get_option( $name, $default );
}

/**
* Creates or returns an instance of this class.
*
* @return SermonManager A single instance of this class.
*/
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}

return self::$instance;
}

/**
* Saves whole Sermon HTML markup into post content for better search compatibility
*
Expand Down Expand Up @@ -485,19 +502,6 @@ public static function fix_sermons_ordering( $query ) {
}
}

/**
* Creates or returns an instance of this class.
*
* @return SermonManager A single instance of this class.
*/
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}

return self::$instance;
}

/**
* Load plugin translations
*
Expand Down Expand Up @@ -527,6 +531,13 @@ public static function enqueue_scripts_styles() {
if ( ! \SermonManager::getOption( 'css' ) ) {
wp_enqueue_style( 'wpfc-sm-styles', SM_URL . 'assets/css/sermon.css', array(), SM_VERSION );
wp_enqueue_style( 'dashicons' );

wp_enqueue_script( 'wpfc-sm-additional_classes', SM_URL . 'assets/js/additional_classes.js', array(), SM_VERSION, true );

// load theme-specific styling, if there's any
if ( file_exists( SM_PATH . 'assets/css/theme-specific/' . get_option( 'template' ) . '.css' ) ) {
wp_enqueue_style( 'wpfc-sm-style-' . get_option( 'template' ), SM_URL . 'assets/css/theme-specific/' . get_option( 'template' ) . '.css', array( 'wpfc-sm-styles' ), SM_VERSION );
}
}

switch ( \SermonManager::getOption( 'player' ) ) {
Expand All @@ -535,7 +546,7 @@ public static function enqueue_scripts_styles() {

break;
case 'plyr':
wp_enqueue_script( 'wpfc-sm-plyr', SM_URL . 'assets/js/plyr.js', array(), SM_VERSION, \SermonManager::getOption('player_js_footer') );
wp_enqueue_script( 'wpfc-sm-plyr', SM_URL . 'assets/js/plyr.js', array(), SM_VERSION, \SermonManager::getOption( 'player_js_footer' ) );
wp_enqueue_style( 'wpfc-sm-plyr-css', SM_URL . 'assets/css/plyr.css', array(), SM_VERSION );
wp_add_inline_script( 'wpfc-sm-plyr', 'window.addEventListener(\'DOMContentLoaded\', function() {plyr.setup(document.querySelectorAll(\'.wpfc-sermon-player, .wpfc-sermon-video-player\'));})' );

Expand Down Expand Up @@ -575,11 +586,17 @@ public static function enqueue_scripts_styles() {
*
* @param array $classes An array of existing post classes
* @param array $class An array of additional classes added to the post (not needed)
* @param int $ID The post ID
* @param int $post_id The post ID
*
* @return array Modified class list
*/
public static function add_additional_sermon_classes( $classes, $class, $ID ) {
public static function add_additional_sermon_classes( $classes, $class, $post_id ) {
if ( get_post_type( $post_id ) !== 'wpfc_sermon' ) {
return $classes;
}

$additional_classes = array();

$taxonomies = array(
'wpfc_preacher',
'wpfc_sermon_series',
Expand All @@ -588,7 +605,7 @@ public static function add_additional_sermon_classes( $classes, $class, $ID ) {
);

foreach ( $taxonomies as $taxonomy ) {
foreach ( (array) get_the_terms( $ID, $taxonomy ) as $term ) {
foreach ( (array) get_the_terms( $post_id, $taxonomy ) as $term ) {
if ( empty( $term->slug ) ) {
continue;
}
Expand All @@ -600,12 +617,27 @@ public static function add_additional_sermon_classes( $classes, $class, $ID ) {
$term_class = $term->term_id;
}

$classes[] = esc_attr( sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ) );
$additional_classes[] = esc_attr( sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ) );
}
}
}

return $classes;
if ( is_archive() ) {
$additional_classes[] = 'wpfc-sermon';
} else {
$additional_classes[] = 'wpfc-sermon-single';
}

/**
* Allows filtering of additional Sermon Manager classes
*
* @param array $classes The array of added classes
*
* @since 2.12.0
*/
$additional_classes = apply_filters( 'wpfc_sermon_classes', $additional_classes, $classes, $post_id );

return $additional_classes + $classes;
}

/**
Expand Down

0 comments on commit 36eb00f

Please sign in to comment.