From e90481b6a2cf78a3b73577181a5901a029774afa Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Mon, 30 Oct 2017 19:01:22 +0100 Subject: [PATCH] =?UTF-8?q?Creaci=C3=B3n=20de=20dos=20widgets=20para=20sim?= =?UTF-8?q?ular=20una=20entrada=20cuando=20se=20usa=20el=20editor=20avanza?= =?UTF-8?q?do?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enfold-cille/functions.php | 197 ++++++++++++++++++++++++++++++++++++- enfold-cille/style.css | 10 +- 2 files changed, 202 insertions(+), 5 deletions(-) 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 "
$slider
"; + } + } + + echo '
'; + if ( strpos( $blog_style, 'multi' ) !== false ) { + $author_name = apply_filters( 'avf_author_name', get_the_author_meta( 'display_name', $post->post_author ), $post->post_author ); + $author_email = apply_filters( 'avf_author_email', get_the_author_meta( 'email', $post->post_author ), $post->post_author ); + $link = get_author_posts_url( $post->post_author ); + } + echo '
'; + + echo '
'; + + $taxonomies = get_object_taxonomies( get_post_type( $the_id ) ); + $cats = ''; + $excluded_taxonomies = array_merge( get_taxonomies( array( 'public' => false ) ), array( 'post_tag', 'post_format' ) ); + $excluded_taxonomies = apply_filters( 'avf_exclude_taxonomies', $excluded_taxonomies, get_post_type( $the_id ), $the_id ); + + if ( ! empty( $taxonomies ) ) { + foreach ( $taxonomies as $taxonomy ) { + if ( ! in_array( $taxonomy, $excluded_taxonomies ) ) { + $cats .= get_the_term_list( $the_id, $taxonomy, '', ', ', '') . ' '; + } + } + } + + if ( strpos( $blog_global_style, 'elegant-blog' ) !== false ) { + $cat_output = ''; + if ( ! empty( $cats ) ) { + $cat_output .= ''; + $cat_output .= $cats; + $cat_output .= ''; + $cats = ''; + } + echo strpos( $blog_global_style, 'modern-blog' ) === false ? $cat_output . $title : $title . $cat_output; + + echo ''; + + if ( strpos( $blog_style, 'big' ) !== false ) { + if ( $slider ) $slider = "$slider"; + if ( $slider ) echo "
$slider
"; + } + + $cats = ''; + $title = ''; + } + + echo $title; + + echo ''; + + echo '
'; + + echo $args['after_widget']; + } +} + +/* + * New widget for Enfold theme. Display the single post footer with the tags, + * social share links and related posts. + * See http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-wordpress-widget/ + */ +add_action( 'widgets_init', function() { + register_widget( 'enfold_post_footer_widget' ); +}); +class enfold_post_footer_widget extends WP_Widget { + function __construct() { + parent::__construct( + // Base ID: + 'enfold_post_footer_widget', + // Widget name will appear in UI: + __( 'Enfold Cille Post Footer', 'avia_framework' ), + // Widget description: + array( 'description' => __( 'Display the single post footer with the tags, social share links and related posts', 'avia_framework' ) ) + ); + } + public function widget( $args, $instance ) { + echo $args['before_widget']; + echo ''; + echo '
'; + echo get_template_part( '../enfold/includes/related-posts'); + echo '
'; + echo $args['after_widget']; + } +} + /* * Remove Avia Framework debug information in child theme. * See http://www.kriesi.at/support/topic/removal-of-theme-debug-info/#post-386207 diff --git a/enfold-cille/style.css b/enfold-cille/style.css index 8f8c83c..16d6115 100644 --- a/enfold-cille/style.css +++ b/enfold-cille/style.css @@ -28,6 +28,7 @@ div .av_one_fourth { .related_posts { padding-right: 0; margin-right: 0px !important; + border-top-width: 0; } body.tag .content { padding-top: 12px; @@ -171,11 +172,12 @@ body.home .content { .entry-content-wrapper { line-height: 1.42857; } -.entry-content-wrapper .post-title, +.entry-content-header .post-title, #top .flex_column .template-blog .post-title { - color: #ff3300; + text-transform: none !important; font-size: 41px !important; line-height: 1em; + color: #ff3300; } .entry-content-wrapper h2, .entry-content-wrapper h3, @@ -298,6 +300,10 @@ footer.entry-footer { margin-bottom: 30px; } /* Comments */ +.comment_container h3 { + color: #e9146c; + font-size: 28px; +} #top .comment_text { font-size: 16px; } /*