%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: link to post date */ esc_html_x( '%s ago', 'post date', 'blogito' ), '' . $time_string . '' ); $byline = sprintf( /* translators: link to author page */ esc_html_x( ' by %s', 'post author', 'blogito' ), '' . esc_html( get_the_author() ) . '' ); echo '' . $posted_on . ' ' . $byline . ''; // WPCS: XSS OK. } else { $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_attr( get_the_date() ) ); $posted_on = sprintf( /* translators: link to post date */ esc_html_x( '%s ', 'post date', 'blogito' ), '' . $time_string . '' ); echo '' . $posted_on . ''; // WPCS: XSS OK. } } endif; if ( ! function_exists( 'blogito_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function blogito_entry_footer() { blogito_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__( ', ', 'blogito' ) ); if ( $tags_list ) { /* translators: related tag list */ printf( '' . esc_html__( 'Tagged: %1$s', 'blogito' ) . '', $tags_list ); // WPCS: XSS OK. } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; comments_popup_link( '', ' 1', '' . esc_html__( ' %', 'blogito' ) ) . ''; echo ''; } edit_post_link( esc_html__( 'Edit', 'blogito' ), '', '' ); } endif; if ( ! function_exists( 'blogito_categorized_blog' ) ) : /** * Returns true if a blog has more than 1 category. * * @return bool */ function blogito_categorized_blog() { $all_the_cool_cats = get_transient( 'blogito_categories' ); if ( ! $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( 'blogito_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so blogito_categorized_blog should return true. return true; } else { // This blog has only 1 category so blogito_categorized_blog should return false. return false; } } endif; /** * Flush out the transients used in blogito_categorized_blog. */ function blogito_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'blogito_categories' ); } add_action( 'edit_category', 'blogito_category_transient_flusher' ); add_action( 'save_post', 'blogito_category_transient_flusher' ); if ( ! function_exists( 'blogito_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since blogito 1.0 * @param type $comment comment. * @param type $args comment args. * @param type $depth comments depth. */ function blogito_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', 'blogito_comments_fields' ); endif; /** * 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. * @return string */ function blogito_get_excerpt_by_id( $post_id ) { $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 = 35; // Sets excerpt length by word count. $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 ); array_push( $words, '...' ); $the_excerpt = implode( ' ', $words ); endif; $the_excerpt = '

    ' . $the_excerpt . '

    '; return $the_excerpt; } if ( ! function_exists( 'blogito_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 blogito_custom_popular_posts_html_list( $mostpopular, $instance ) { $output = ''; return $output; } add_filter( 'wpp_custom_html', 'blogito_custom_popular_posts_html_list', 10, 2 ); endif; if ( ! function_exists( 'blogito_content' ) ) : /** * Template for displaying content in different post formats. * * @since blogito 1.0 */ function blogito_content() { $format = get_post_format(); if ( 'audio' === $format ) { return blogito_media_content(); } elseif ( 'video' === $format ) { return blogito_media_content(); } elseif ( 'gallery' === $format ) { return blogito_gallery_content(); } else { $content = get_the_content( sprintf( '', esc_html__( 'Read more', 'blogito' ) ) ); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); echo $content; // WPCS: XSS OK. } } endif; if ( ! function_exists( 'blogito_gallery_content' ) ) : /** * Template for cutting images from gallery post format. * * @since blogito 1.0 */ function blogito_gallery_content() { // $content = get_the_content( sprintf( __( '', 'blogito' ), the_title( '"', '"', false ) ) ); $content = get_the_content( sprintf( '', esc_html__( 'Read more', 'blogito' ) ) ); $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( 'blogito_media_content' ) ) : /** * Template for cutting media from audio/video post formats. * * @since blogito 1.0 */ function blogito_media_content() { // $content = get_the_content( sprintf( __( '', 'blogito' ), the_title( '"', '"', false ) ) ); $content = get_the_content( sprintf( '', esc_html__( 'Read more', 'blogito' ) ) ); $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( 'blogito_gallery_shortcode' ) ) : /** * Custom gallery shortcode output. * * @param type $output gellery shortcode output. * @param array $atts gellery shortcode atts. * @param type $instance gellery shortcode instance. * @return type */ function blogito_gallery_shortcode( $output = '', $atts, $instance ) { $return = $output; // Fallback. $atts = array( 'size' => 'medium', ); return $output; } add_filter( 'post_gallery', 'blogito_gallery_shortcode', 10, 3 ); endif; if ( ! function_exists( 'blogito_post_format_icon' ) ) : /** * Function for getting post format icon. * * @param type $post_id WP post ID. * @return string */ function blogito_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( 'blogito_customize_css' ) ) : /** * Custom css header output */ function blogito_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 ); ?> 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', 'blogito_submenu_span', 10, 4 ); /** * Function for displaying related posts on single post. */ function blogito_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() ) : ?> ' . wp_kses_post( sharing_display( '', false ) ) . ''; } 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 '
    ' . wp_kses_post( sharing_display( '', false ) ) . '
    '; } } } } /** * Remove Jetpack sharing filters. */ function blogito_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', 'blogito_jetpack_sharing_remove_filters' );