array( $post_id ), 'ignore_sticky_posts' => true, 'posts_per_page' => 4, ); $query_by = get_theme_mod( 'buzzo_query_related_posts_by', 'post_tag' ); if ( 'category' == $query_by ) { $cats = get_the_category( $post_id ); if ( $cats ) { $cats_id = wp_list_pluck( $cats, 'term_id' ); $query_args['category__in'] = $cats_id; } } else { $tags = get_the_tags( $post_id ); if ( $tags ) { $tags_id = wp_list_pluck( $tags, 'term_id' ); $query_args['tag__in'] = $tags_id; } } $query_args = apply_filters( 'buzzo_related_posts_query_args', $query_args ); return new WP_Query( $query_args ); } /** * Get excluded categories. * * @return array */ function buzzo_get_excluded_categories() { $value = get_theme_mod( 'buzzo_excluded_categories' ); if ( ! $value ) { $excluded = array(); } else { $excluded = explode( ',', $value ); $excluded = array_map( 'trim', $excluded ); } return apply_filters( 'buzzo_excluded_categories', $excluded ); } /** * Adds custom classes to the array of body classes. * * @param array $classes Classes for the body element. * @return array */ function buzzo_body_classes( $classes ) { // Adds a class of group-blog to blogs with more than 1 published author. if ( is_multi_author() ) { $classes[] = 'group-blog'; } // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; } return $classes; } add_filter( 'body_class', 'buzzo_body_classes' ); /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function buzzo_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'buzzo_pingback_header' ); /** * Display content bottom sidebar. */ function buzzo_content_bottom_sidebar() { if ( is_active_sidebar( 'buzzo-content-bottom' ) ) : ?>
have_posts() ) { return; } ?>
' . $user_avatar . '

'; } add_filter( 'comment_form_field_comment', 'buzzo_comment_form_field_comment' ); /** * Filter comment fields. * * @param array $fields Comment fields. * @return array */ function buzzo_comment_form_default_fields( $fields ) { $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $html_req = ( $req ? " required='required'" : '' ); $fields = array( 'author' => '

' . '

', 'email' => '

' . '

', 'url' => '

' . '

', ); return $fields; } add_filter( 'comment_form_default_fields', 'buzzo_comment_form_default_fields' ); /** * Print comemnt fields open row. */ function buzzo_comment_form_before_fields() { echo '
'; } add_action( 'comment_form_before_fields', 'buzzo_comment_form_before_fields' ); /** * Print comemnt fields close row. */ function buzzo_comment_form_after_fields() { echo '
'; } add_action( 'comment_form_after_fields', 'buzzo_comment_form_after_fields' ); /** * Filter comment form args. * * @param array $args Comment form args. * @return array */ function buzzo_comment_form_defaults( $args ) { $args['class_submit'] = 'submit buzzo-button'; $args['submit_button'] = ''; return $args; } add_filter( 'comment_form_defaults', 'buzzo_comment_form_defaults' ); /** * Add bg gray class to content. * * @param string $classes Content classes. * @return string */ function buzzo_content_bg_gray_class( $classes ) { if ( is_page() && get_post_meta( get_the_ID(), '_buzzo_bg_gray', true ) ) { $classes .= ' bg-gray'; } return $classes; } add_filter( 'buzzo_layout_class', 'buzzo_content_bg_gray_class' ); /** * Filter archive title. * * @param string $title Archive title. * @return string */ function buzzo_archive_title( $title ) { if ( is_home() || is_single() ) { return __( 'Blog', 'buzzo' ); } if ( is_search() ) { /* translators: search query. */ return sprintf( __( 'Search results for: %s', 'buzzo' ), get_search_query() ); } if ( is_404() ) { return __( 'Not found', 'buzzo' ); } return $title; } add_filter( 'get_the_archive_title', 'buzzo_archive_title' );