%2$s'; if ( is_single() ) { $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ); $posted_on = sprintf( // Translators: post date in "ago" format. esc_html_x( '%s ago', 'post date', 'blover' ), '' . $time_string . '' ); $byline = '' . get_avatar( get_the_author_meta( 'ID' ) ) . '' . esc_html( get_the_author() ) . ''; echo ' ' . $byline . '
' . $posted_on . ''; // WPCS: XSS OK. blover_jetpack_sharing(); echo '
'; } else { $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_attr( get_the_date() ) ); $posted_on = sprintf( // Translators: date. esc_html_x( '%s ', 'post date', 'blover' ), '' . $time_string . '' ); echo '' . $posted_on . ''; // WPCS: XSS OK. } } endif; if ( ! function_exists( 'blover_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function blover_entry_footer() { blover_jetpack_sharing(); // Hide category and tag text for pages. if ( is_single() && 'post' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'blover' ) ); if ( $tags_list ) { // Translators: tag list. printf( '' . esc_html__( 'Tagged: %1$s', 'blover' ) . '', $tags_list ); // WPCS: XSS OK. } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; comments_popup_link( '', ' 1', ' %' ); echo ''; } edit_post_link( esc_html__( 'Edit', 'blover' ), '', '' ); } endif; if ( ! function_exists( 'blover_categorized_blog' ) ) : /** * Returns true if a blog has more than 1 category. * * @return bool */ function blover_categorized_blog() { $all_the_cool_cats = get_transient( 'blover_categories' ); if ( false === ( $all_the_cool_cats ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'blover_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so blover_categorized_blog should return true. return true; } else { // This blog has only 1 category so blover_categorized_blog should return false. return false; } } endif; /** * Flush out the transients used in blover_categorized_blog. */ function blover_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'blover_categories' ); } add_action( 'edit_category', 'blover_category_transient_flusher' ); add_action( 'save_post', 'blover_category_transient_flusher' ); if ( ! function_exists( 'blover_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since blover 1.0 * @param type $comment comment. * @param type $args comment args. * @param type $depth comments depth. */ function blover_comment( $comment, $args, $depth ) { // $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-">
    comment_approved ) : ?>
    exists() ? $user->display_name : ''; if ( ! isset( $args['format'] ) ) { $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; } $req = get_option( 'require_name_email' ); $aria_req = ( $req ? ' aria-required="true"' : '' ); $html_req = ( $req ? ' required="required"' : '' ); $html5 = 'html5' === $args['format']; $fields = array( 'author' => '

    ', 'email' => '', 'url' => '

    ', ); return $fields; } add_filter( 'comment_form_default_fields', 'blover_comments_fields' ); endif; if ( ! function_exists( 'blover_get_excerpt_by_id' ) ) : /** * Gets the excerpt using the post ID outside the loop. * * @author Withers David * @link http://uplifted.net/programming/wordpress-get-the-excerpt-automatically-using-the-post-id-outside-of-the-loop/ * @param int $post_id WP post ID. * @param int $excerpt_length excerpt length. * @return string */ function blover_get_excerpt_by_id( $post_id, $excerpt_length = 15 ) { $the_post = get_post( $post_id ); // Gets post ID. $the_excerpt = $the_post->post_content; // Gets post_content to be used as a basis for the excerpt. // $excerpt_length = absint( get_theme_mod( 'wpp_excerpt_length' , 15 ) ); // Excerpt length. // $excerpt_length = 15; $the_excerpt = strip_tags( strip_shortcodes( $the_excerpt ) ); // Strips tags and images. $words = explode( ' ', $the_excerpt, $excerpt_length + 1 ); if ( count( $words ) > $excerpt_length ) : array_pop( $words ); $the_excerpt = implode( ' ', $words ); endif; $the_excerpt = '

    ' . $the_excerpt . '

    '; return $the_excerpt; } endif; if ( ! function_exists( 'blover_custom_popular_posts_html_list' ) ) : /** * Builds custom HTML * * With this function, I can alter WPP's HTML output from my theme's functions.php. * This way, the modification is permanent even if the plugin gets updated. * * @param array $mostpopular WPP mostpopular. * @param array $instance WPP instance. * @return string */ function blover_custom_popular_posts_html_list( $mostpopular, $instance ) { $output = '
      '; // loop the array of popular posts objects. foreach ( $mostpopular as $popular ) { $stats = array(); // placeholder for the stats tag. // Comment count option active, display comments. if ( $instance['stats_tag']['comment_count'] ) { // display text in singular or plural, according to comments count. $stats[] = '' . sprintf( // Translators: comment count. _n( '%s comment', '%s comments', absint( $popular->comment_count ), 'blover' ), number_format_i18n( $popular->comment_count ) ) . ''; } // Pageviews option checked, display views. if ( $instance['stats_tag']['views'] ) { // If sorting posts by average views. if ( 'avg' === $instance['order_by'] ) { // display text in singular or plural, according to views count. $stats[] = '' . sprintf( // Translators: pageviews. _n( '%s view per day', '%s views per day', absint( $popular->pageviews ), 'blover' ), number_format_i18n( $popular->pageviews, 2 ) ) . ''; } else { // Sorting posts by views // display text in singular or plural, according to views count. $stats[] = '' . sprintf( // Translators: pageviews. _n( '%s view', '%s views', absint( $popular->pageviews ), 'blover' ), number_format_i18n( $popular->pageviews ) ) . ''; } } // Author option checked. if ( $instance['stats_tag']['author'] ) { $author = get_the_author_meta( 'display_name', $popular->uid ); $display_name = '' . esc_html( $author ) . ''; // Translators: author name. $stats[] = '' . sprintf( esc_html__( 'by %s', 'blover' ), $display_name ) . ''; } // Date option checked. if ( $instance['stats_tag']['date']['active'] ) { $date = date_i18n( $instance['stats_tag']['date']['format'], strtotime( $popular->date ) ); $stats[] = '' . esc_html( $date ) . ''; } // Category option checked. if ( $instance['stats_tag']['category'] ) { $post_cat = get_the_category( $popular->id ); $post_cat = ( isset( $post_cat[0] ) ) ? '' . esc_html( $post_cat[0]->cat_name ) . '' : ''; if ( '' !== $post_cat ) { $stats[] = '' . $post_cat . ''; } } // Build stats tag. if ( ! empty( $stats ) ) { $stats = '
      ' . join( ' / ', $stats ) . '
      '; } $excerpt = ''; // Excerpt placeholder. // Excerpt option checked, build excerpt tag. if ( $instance['post-excerpt']['active'] ) { $excerpt = blover_get_excerpt_by_id( $popular->id, $instance['post-excerpt']['length'] ); if ( ! empty( $excerpt ) ) { $excerpt = '
      ' . wp_kses_post( $excerpt ) . '
      '; } } if ( has_post_thumbnail( $popular->id ) ) { $thumb_url = get_the_post_thumbnail_url( $popular->id, get_theme_mod( 'wpp_img_size', 'medium' ) ); $background = ' style="background:url(' . esc_url( $thumb_url ) . ') no-repeat center;background-size: cover;"'; } $output .= '
    1. '; $output .= ( ! empty( $thumb_url ) ) ? '' : ''; $output .= '

      ' . esc_html( $popular->title ) . '

      '; $output .= $excerpt; $output .= $stats; $output .= '
    2. '; }// End foreach(). $output .= '
    '; return $output; } if ( ! get_theme_mod( 'wpp_styling', 0 ) ) { add_filter( 'wpp_custom_html', 'blover_custom_popular_posts_html_list', 10, 2 ); } endif; if ( ! function_exists( 'blover_content' ) ) : /** * Template for displaying content in different post formats. * * @since blover 1.0 */ function blover_content() { $format = get_post_format(); if ( 'audio' === $format ) { return blover_media_content(); } elseif ( 'video' === $format ) { return blover_media_content(); } elseif ( 'gallery' === $format ) { return blover_gallery_content(); } else { // Translators: page/post title. $content = get_the_content( sprintf( '' . esc_html__( 'Read more %s', 'blover' ) . '', the_title( '"', '"', false ) ) ); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); echo $content; // WPCS: XSS OK. } } endif; if ( ! function_exists( 'blover_gallery_content' ) ) : /** * Template for cutting images from gallery post format. * * @since blover 1.0 */ function blover_gallery_content() { // Translators: page/post title. $content = get_the_content( sprintf( '' . esc_html__( 'Read more %s', 'blover' ) . '', the_title( '"', '"', false ) ) ); $pattern = '#\[gallery[^\]]*\]#'; $replacement = ''; $newcontent = preg_replace( $pattern, $replacement, $content, 1 ); $newcontent = apply_filters( 'the_content', $newcontent ); $newcontent = str_replace( ']]>', ']]>', $newcontent ); echo $newcontent; // WPCS: XSS OK. } endif; if ( ! function_exists( 'blover_media_content' ) ) : /** * Template for cutting media from audio/video post formats. * * @since blover 1.0 */ function blover_media_content() { // Translators: page/post title. $content = get_the_content( sprintf( '' . esc_html__( 'Read more %s', 'blover' ) . '', the_title( '"', '"', false ) ) ); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); $tags = 'audio|video|object|embed|iframe'; $replacement = ''; $newcontent = preg_replace( '#<(?P' . $tags . ')[^<]*?(?:>[\s\S]*?<\/(?P=tag)>|\s*\/>)#', $replacement, $content, 1 ); echo $newcontent; // WPCS: XSS OK. } endif; if ( ! function_exists( 'blover_post_format_icon' ) ) : /** * Function for getting post format icon. * * @param type $post_id WP post ID. * @return string */ function blover_post_format_icon( $post_id ) { if ( empty( $post_id ) ) { return; } $format = get_post_format( $post_id ); if ( ! $format ) { return; } else { if ( 'audio' === $format ) { return '
    '; } elseif ( 'video' === $format ) { return '
    '; } elseif ( 'gallery' === $format ) { return '
    '; } } } endif; /* * CSS output from customizer settings */ if ( ! function_exists( 'blover_customize_css' ) ) : /** * Custom css header output */ function blover_customize_css() { $hide_title_on_home_archive = get_theme_mod( 'hide_title_on_home_archive', 0 ); $hide_meta_on_home_archive = get_theme_mod( 'hide_meta_on_home_archive', 0 ); $show_title_on_shop_page = get_theme_mod( 'woocommerce_show_page_title', 0 ); $custom_css = ''; if ( ! display_header_text() ) { $custom_css .= '.site-title, .site-description {display:none;} .site-branding {padding:0;}'; } $custom_css .= '.blover-featured-slider, .blover-featured-slider .featured-image, .blover-featured-slider .no-featured-image {height:' . ( absint( get_theme_mod( 'home_page_slider_height', 500 ) ) * 0.6 ) . 'px;} #secondary .widget:nth-of-type(3n+1), #secondary .widget:nth-of-type(3n+1) .widget-title span {background-color:' . esc_attr( get_theme_mod( 'sidebar_bg_color_1', '#f8f8f8' ) ) . ';} #secondary .widget:nth-of-type(3n+2), #secondary .widget:nth-of-type(3n+2) .widget-title span {background-color:' . esc_attr( get_theme_mod( 'sidebar_bg_color_2', '#f8f8f8' ) ) . ';} #secondary .widget:nth-of-type(3n+3), #secondary .widget:nth-of-type(3n+3) .widget-title span {background-color:' . esc_attr( get_theme_mod( 'sidebar_bg_color_3', '#f8f8f8' ) ) . ';} #footer-widget, #footer-widget .widget-title span {background-color:' . esc_attr( get_theme_mod( 'footer_bg_color', '#f8f8f8' ) ) . '}'; if ( $hide_title_on_home_archive ) { $custom_css .= '.blog .content-area .entry-title, .archive .content-area .entry-title, .search .content-area .entry-title {display:none;}'; } if ( $hide_meta_on_home_archive ) { $custom_css .= '.blog .content-area .entry-meta, .archive .content-area .entry-meta, .search .content-area .entry-meta {display:none;}'; } if ( ! $show_title_on_shop_page ) { $custom_css .= '.woocommerce .page-title {display:none;}'; } if ( get_theme_mod( 'show_full_width_image_in_header', 0 ) ) { $custom_css .= '.site-branding .site-title img {width: 100%;}'; } if ( ! get_theme_mod( 'enable_padding_for_image_in_header', 1 ) ) { $custom_css .= '.site-branding {padding:0;}'; } $custom_css .= '@media screen and (min-width:' . absint( get_theme_mod( 'show_top_menu_width', 978 ) ) . 'px ) { .menu-logo {float:left;} .navbar-navigation ul, .nav-social {display:block;} .blover-featured-slider, .blover-featured-slider .featured-image, .blover-featured-slider .no-featured-image {height:' . absint( get_theme_mod( 'home_page_slider_height', 500 ) ) . 'px;} }'; wp_add_inline_style( 'blover-style', $custom_css ); } add_action( 'wp_enqueue_scripts', 'blover_customize_css' ); endif; if ( ! function_exists( 'blover_months' ) ) : /** * Months with translations for js. * * @return type */ function blover_months() { $months = array(); $jan = esc_html__( 'January', 'blover' ); $feb = esc_html__( 'February', 'blover' ); $mar = esc_html__( 'March', 'blover' ); $apr = esc_html__( 'April', 'blover' ); $may = esc_html__( 'May', 'blover' ); $jun = esc_html__( 'June', 'blover' ); $jul = esc_html__( 'July', 'blover' ); $aug = esc_html__( 'August', 'blover' ); $sep = esc_html__( 'September', 'blover' ); $oct = esc_html__( 'October', 'blover' ); $nov = esc_html__( 'November', 'blover' ); $dec = esc_html__( 'December', 'blover' ); $months = array( $jan, $feb, $mar, $apr, $may, $jun, $jul, $aug, $sep, $oct, $nov, $dec ); return $months; } endif; if ( ! function_exists( 'blover_days' ) ) : /** * Days with translations for js. * * @return type */ function blover_days() { $days = array(); $sun = esc_html__( 'Sunday', 'blover' ); $mon = esc_html__( 'Monday', 'blover' ); $tue = esc_html__( 'Tuesday', 'blover' ); $wed = esc_html__( 'Wednesday', 'blover' ); $thu = esc_html__( 'Thursday', 'blover' ); $fri = esc_html__( 'Friday', 'blover' ); $sat = esc_html__( 'Saturday', 'blover' ); $days = array( $sun, $mon, $tue, $wed, $thu, $fri, $sat ); return $days; } endif; if ( ! function_exists( 'blover_submenu_span' ) ) : /** * Function add span to menu elements which has children. * * @param string $item_output html output. * @param type $item menu element object. * @param type $depth menu depth level. * @param type $args nwv walker args. * @return string */ function blover_submenu_span( $item_output, $item, $depth, $args ) { $needle1 = 'menu-item-has-children'; $needle2 = 'page_item_has_children'; $haystack = $item->classes; if ( in_array( $needle1, $haystack, true ) || in_array( $needle2, $haystack, true ) ) { $item_output = $item_output . '+'; } return $item_output; } add_filter( 'walker_nav_menu_start_el', 'blover_submenu_span', 10, 4 ); endif; if ( ! function_exists( 'blover_related_posts' ) ) : /** * Function for displaying related posts on single page. */ function blover_related_posts() { $show_related = get_theme_mod( 'single_page_related_posts_show', 1 ); if ( $show_related ) { $by_cat = get_theme_mod( 'single_page_related_posts_by_tag_or_cat', 1 ); $taxonomy = ( $by_cat ? 'category' : 'post_tag' ); if ( $by_cat ) { $terms = wp_get_post_categories( get_the_ID() ); } else { $terms = wp_get_post_tags( get_the_ID(), array( 'fields' => 'ids', ) ); } $args = array( 'posts_per_page' => 3, 'post__not_in' => array( get_the_ID() ), 'post_type' => 'post', 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => $taxonomy, 'terms' => $terms, ), ), ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : ?> have_comments() ? '' . esc_html__( 'Add a review', 'blover' ) . '' : sprintf( '' . esc_html__( 'Be the first to review “%s”', 'blover' ) . '', get_the_title() ), // Translators: comment title. 'title_reply_to' => esc_html__( 'Leave a Reply to %s', 'blover' ), 'comment_notes_after' => '', 'fields' => array( 'author' => '

    ', 'email' => '', ), 'label_submit' => esc_html__( 'Submit', 'blover' ), 'logged_in_as' => '', 'comment_field' => '', ); $account_page_url = wc_get_page_permalink( 'myaccount' ); if ( $account_page_url ) { // Translators: url to "my account" page. $comment_form['must_log_in'] = ''; } if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) { $comment_form['comment_field'] = '

    '; } $comment_form['comment_field'] .= '

    '; return $comment_form; } endif; add_filter( 'woocommerce_product_review_comment_form_args', 'blover_woocommerce_comment_fields' ); add_filter( 'add_to_cart_fragments', 'blover_woocommerce_header_add_to_cart_fragment' ); /** * Adding ajax calls when cart is updated. * * @param string $fragments todo. */ function blover_woocommerce_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); ?> (cart->get_cart_contents_count() ); ?>) ' . sharing_display( '', false ) . ''; // WPCS: XSS OK. } elseif ( in_array( 'index', $display_options, true ) && ( is_home() || is_front_page() || is_archive() || is_search() || in_array( get_post_type(), $display_options, true ) ) ) { echo '
    ' . sharing_display( '', false ) . '
    '; // WPCS: XSS OK. } } } } /** * Remove Jetpack sharing filters. */ function blover_jetpack_sharing_remove_filters() { if ( function_exists( 'sharing_display' ) ) { remove_filter( 'the_content', 'sharing_display', 19 ); remove_filter( 'the_excerpt', 'sharing_display', 19 ); } } add_action( 'init', 'blover_jetpack_sharing_remove_filters' ); /** * Custom number of related products in woocommerce. * * @param array $args woocommerce related products arguments. */ function blover_woocommerce_related_products_args( $args ) { $args['posts_per_page'] = 3; // 3 related products // $args['columns'] = 2; // arranged in 2 columns return $args; } add_filter( 'woocommerce_output_related_products_args', 'blover_woocommerce_related_products_args' ); if ( ! function_exists( 'blover_show_sticky' ) ) : /** * Show sticky posts below slider depends on option * * @return bool */ function blover_show_sticky() { if ( is_sticky() && ! get_theme_mod( 'home_page_show_sticky', 0 ) ) { return false; } return true; } endif; add_filter( 'get_the_archive_title', 'blover_the_archive_title' ); /** * Modify the_archive_title * * @param string $title title of archive pages. * @return string $title */ function blover_the_archive_title( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ); } return $title; }