diff --git a/enfold-cille/functions.php b/enfold-cille/functions.php index ec3e9d0..e683dbd 100644 --- a/enfold-cille/functions.php +++ b/enfold-cille/functions.php @@ -65,7 +65,7 @@ function xf_tag_cloud( $tag_string ) { * Remove Pingbacks from Recent Comments Widget. * http://ronangelo.com/remove-pingbacks-on-recent-comments-widget */ - add_filter( 'widget_comments_args', 'remove_pingbacks_recent_comments' ); +add_filter( 'widget_comments_args', 'remove_pingbacks_recent_comments' ); function remove_pingbacks_recent_comments( $array ) { $array['type'] = 'comment'; return $array; @@ -89,9 +89,9 @@ function avia_same_category_filter( $settings ) { add_filter( 'avf_title_args', 'fix_single_post_title', 10, 2 ); function fix_single_post_title( $args, $id ) { $category = get_the_category(); - if ( $args['title'] == __( 'Blog - Latest News', 'avia_framework' ) && !empty( $category ) ) { + if ( ! empty( $category ) && is_single() && get_post_type() == 'post' ) { // Social title for Twitter, Facebook & LinkedIn categories: - $args['title'] = in_array( $category[0]->term_id, array( 1562, 1563, 1564 ) ) ? 'Social' : $category[0]->name; + $args['title'] = in_array( $category[0]->name, array( 'Twitter', 'Facebook', 'LinkedIn' ) ) ? 'Social' : $category[0]->name; $args['link'] = NULL; $args['heading'] = 'h1'; } @@ -366,6 +366,197 @@ function publish_social_post( $ID, $post ) { } } */ +/* + * New widget for Enfold theme. Display the single post header with the slider, + * title and meta info. + */ +add_action( 'widgets_init', function() { + register_widget( 'enfold_post_header_widget' ); +}); +class enfold_post_header_widget extends WP_Widget { + function __construct() { + parent::__construct( + // Base ID: + 'enfold_post_header_widget', + // Widget name will appear in UI: + __( 'Enfold Cille Post Header', 'avia_framework' ), + // Widget description: + array( 'description' => __( 'Display the single post header with the slider, title and meta info', 'avia_framework' ) ) + ); + } + public function widget( $args, $instance ) { + global $avia_config; + + echo $args['before_widget']; + + $blog_style = avia_get_option( 'single_post_style', 'single-big' ); + $blog_global_style = avia_get_option( 'blog_global_style', '' ); + $the_id = get_the_ID(); + + // Get the current post id, the current post class and current post format: + $url = ''; + $current_post = array(); + $current_post['the_id'] = $the_id; + $current_post['post_type'] = get_post_type( $current_post['the_id'] ); + $current_post['post_class'] = 'post-entry-' . $current_post['the_id'] . ' ' . $blog_style; + $current_post['post_class'] .= $current_post['post_type'] == 'post' ? '' : ' post'; + $current_post['post_format'] = get_post_format() ? get_post_format() : 'standard'; + $current_post['post_layout'] = avia_layout_class( 'main', false ); + + // Retrieve slider and title for this post... + $size = strpos( $blog_style, 'big' ) ? strpos( $current_post['post_layout'], 'sidebar' ) !== false ? 'entry_with_sidebar' : 'entry_without_sidebar' : 'square'; + if ( ! empty( $avia_config['preview_mode'] ) && ! empty( $avia_config['image_size'] ) && $avia_config['preview_mode'] == 'custom' ) { + $size = $avia_config['image_size']; + } + $current_post['slider'] = get_the_post_thumbnail( $current_post['the_id'], $size ); + + if ( get_post_meta( $current_post['the_id'], '_avia_hide_featured_image', true ) ) { + $current_post['slider'] = ''; + } + + $current_post['title'] = get_the_title(); + + // Now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php): + $current_post = apply_filters( 'post-format-' . $current_post['post_format'], $current_post ); + + // Extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc... + extract( $current_post ); + + // Default link and preview image description: + $link = avia_image_by_id( get_post_thumbnail_id(), 'large', 'url' ); + $desc = get_post( get_post_thumbnail_id() ); + if ( is_object( $desc ) ) { + $desc = $desc->post_excerpt; + } + $featured_img_desc = $desc != '' ? $desc : the_title_attribute( 'echo=0' ); + + // Echo preview image: + if ( strpos( $blog_global_style, 'elegant-blog' ) === false ) { + if ( strpos( $blog_style, 'big' ) !== false ) { + if ( $slider ) $slider = "$slider"; + if ( $slider ) echo "