'; /** * Sticky post badge. */ if ( is_sticky() ) { printf( '
', esc_html__( 'Pinned Post', 'counter' ) ); // WPCS: XSS OK. } /* * Category. * * Translators: used between list items, there is a space after the comma. */ $categories_list = get_the_category_list( ', ' ); if ( $categories_list && counter_categorized_blog() ) { printf( '
%s
', $categories_list ); // WPCS: XSS OK. } /* * Date. */ if ( in_array( 'posted-on', $meta_items ) || $is_customizer ) { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); printf( '%2$s', // WPCS: XSS OK. esc_url( get_permalink() ), $time_string ); } /* * Author. */ if ( in_array( 'byline', $meta_items ) || $is_customizer ) { echo ''; printf( '%2$s', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_html( get_the_author() ) ); echo ''; } // Print the closing tag. echo ''; endif; } /** * Prints HTML with meta information for the categories, tags and comments. */ function counter_entry_meta_footer() { // Hide category and tag text for pages. if ( 'post' == get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', '' ); if ( $tags_list ) { printf( '', $tags_list ); // WPCS: XSS OK. } } } /** * Displays site title and tagline. */ function counter_site_title_tagline() { $title = get_bloginfo( 'name' ); $tagline = get_bloginfo( 'description', 'display' ); if ( $title || is_customize_preview() ) { printf( '<%1$s class="site-title">%3$s', is_front_page() ? 'h1' : 'p', esc_url( home_url( '/' ) ), esc_html( $title ) ); } if ( $tagline || is_customize_preview() ) { printf( '

%s

', esc_html( $tagline ) ); } } /** * Displays post thumbnail. * * Wraps the post thumbnail in an anchor element on index * view, or a div element on single view. */ function counter_post_thumbnail() { if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { return; } $size = is_active_sidebar( 'sidebar-1' ) ? 'counter-thumbnail' : 'counter-thumbnail-full'; if ( is_singular( array() ) ) { echo '
'; the_post_thumbnail( $size ); echo '
'; } else { printf( '', esc_url( apply_filters( 'the_permalink', get_permalink() ) ) ); the_post_thumbnail( $size ); echo ''; } } /** * Displays Posts Navigation a.k.a Older/Newer posts links on a blog page. */ function counter_posts_navigation() { $args = array( 'prev_text' => __( 'Older', 'counter' ), 'next_text' => __( 'Newer', 'counter' ), 'screen_reader_text' => __( 'Posts navigation', 'counter' ), ); the_posts_navigation( $args ); } /** * Displays Post Navigation a.k.a Next/Previous Post links on a single post page. */ function counter_post_navigation() { $args = array( 'prev_text' => '%title', 'next_text' => '%title', 'screen_reader_text' => __( 'Post navigation', 'counter' ), ); $previous = get_previous_post_link( '', $args['prev_text'] ); $next = get_next_post_link( '', $args['next_text'] ); // Only add markup if there's somewhere to navigate to. if ( $previous || $next ) { echo _navigation_markup( $next . $previous, 'post-navigation', $args['screen_reader_text'] ); // WPCS: XSS OK. } } /** * Displays Comment Navigation. */ function counter_comment_navigation() { if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?> ThemePatio' ); } /** * Returns true if a blog has more than 1 category. * * @return bool */ function counter_categorized_blog() { $categories = get_transient( 'counter_categories' ); if ( false === $categories ) { // Create an array of all the categories that are attached to posts. $categories = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, 'number' => 2, // We only need to know if there is more than one. ) ); // Count the number of categories that are attached to the posts. $categories = count( $categories ); set_transient( 'counter_categories', $categories ); } if ( $categories > 1 ) { // This blog has more than 1 category so counter_categorized_blog should return true. return true; } else { // This blog has only 1 category so counter_categorized_blog should return false. return false; } } /** * Flush out the transients used in counter_categorized_blog. */ function counter_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'counter_categories' ); } add_action( 'edit_category', 'counter_category_transient_flusher' ); add_action( 'save_post', 'counter_category_transient_flusher' ); /** * Displays panel thumbnail. */ function counter_panel_thumbnail() { if ( post_password_required() || is_attachment() ) { return; } if ( has_post_thumbnail() ) { echo '
'; the_post_thumbnail( 'counter-panel-full' ); echo '
'; } } /** * Displays panel content. */ function counter_panel_content() { if ( get_the_content() ) { ?>
#panel-%s', esc_html( $num ) ); } else { echo ''; printf( '#%s', esc_html( $num ) ); echo ' · '; edit_post_link( __( 'Edit', 'counter' ), '', '', $id ); echo ' · '; printf( '%s', esc_url( admin_url( 'customize.php?autofocus[section]=panel_' . $num ) ), esc_html__( 'Customize', 'counter' ) ); echo ''; } } } /** * Displays the template part for panels on the frontpage. * * Also used as a render callback to update the panel content, CSS class, and * background image from the Customizer. * * Keep in mind that it is used to render the hero panel as well as other panels * in the Customizer, meaning that it's not being executed from within the * loop, so we have to check what page is used as the front page, otherwise * the_content() won't work in the preview. * * It would be an overkill to call this function from the front-page.php to * display the hero panel because the_content() does work there. That's why * front-page.php uses this funciton to only display secondary panels. * * @param object $partial The partial object. * @param int $num Number of the panel. */ function counter_panel( $partial = null, $num = 0 ) { // If this function is called from the Customizer, get the panel number // from the theme mod option. if ( is_a( $partial, 'WP_Customize_Partial' ) ) { $num = preg_replace( '/panel_(content|class|bg_image)_/', '', $partial->id ); } // Temporarily modify the post object. global $post; // Set the variables that will be available within the template part. set_query_var( 'counter_panel_num', $num ); set_query_var( 'counter_panel_class', counter_panel_class( $num ) ); // Hero panel case. if ( 0 == $num ) { // Get the static front page id. $post = get_post( get_option( 'page_on_front' ) ); // wpcs: override ok. // Set the post object to the static front page. setup_postdata( $post ); // Display the panel. get_template_part( 'template-parts/panel' ); // Regular panel case. } elseif ( get_theme_mod( 'panel_content_' . $num ) ) { // Get the page id assigned to the current panel. $post = get_post( get_theme_mod( 'panel_content_' . $num ) ); // wpcs: override ok. // Set the post object to the page assigned to the current panel. setup_postdata( $post ); // Display the panel. get_template_part( 'template-parts/panel' ); // Empty panel in Cutomizer. } elseif ( ! get_theme_mod( 'panel_content_' . $num ) && is_customize_preview() ) { // Display panel content. get_template_part( 'template-parts/panel', 'empty' ); } // Reset the whole thing. wp_reset_postdata(); }