%2$s'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( DATE_W3C ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( DATE_W3C ) ), esc_html( get_the_modified_date() ) ); $posted_on = sprintf( /* translators: %s: post date. */ __( 'Posted on %s', 'dan' ), '' . $time_string . '' ); $byline = sprintf( /* translators: %s: post author. */ __( 'by %s', 'dan' ), '' . esc_html( get_the_author() ) . '' ); echo '' . $posted_on . '' . $byline . ''; // WPCS: XSS OK. } endif; if ( ! function_exists( 'dan_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function dan_entry_footer() { $format = get_post_format(); if ( current_theme_supports( 'post-formats', $format ) ) { printf( '%1$s%3$s', sprintf( '%s ', _x( 'Format', 'Used before post format.', 'dan' ) ), esc_url( get_post_format_link( $format ) ), get_post_format_string( $format ) ); } // Hide category and tag text for pages. if ( 'post' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( esc_html( ' ' ) ); if ( $categories_list && dan_categorized_blog() ) { printf( '%1$s %2$s', esc_html__( 'Categories', 'dan' ), $categories_list ); } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html( ' ' ) ); if ( $tags_list ) { printf( '%1$s %2$s', esc_html__( 'Tags', 'dan' ), $tags_list ); } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment on %s', 'dan' ), array( 'span' => array( 'class' => array(), ), ) ), get_the_title() ) ); echo ''; } dan_edit_link(); } endif; if ( ! function_exists( 'dan_edit_link' ) ) : function dan_edit_link() { edit_post_link( sprintf( wp_kses( /* translators: %s: Name of current post. Only visible to screen readers */ __( 'Edit %s', 'dan' ), array( 'span' => array( 'class' => array(), ), ) ), get_the_title() ), '', '' ); } endif; if ( ! function_exists( 'dan_excerpt_more' ) && ! is_admin() ) : /** * Replaces "[...]" (appended to automatically generated excerpts) with ... and * a 'Continue reading' link. * * Create your own dan_excerpt_more() function to override in a child theme. * * @return string 'Continue reading' link prepended with an ellipsis. */ function dan_excerpt_more() { $link = sprintf( '%2$s', esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading "%s"', 'dan' ), get_the_title( get_the_ID() ) ) ); return ' … ' . $link; } add_filter( 'excerpt_more', 'dan_excerpt_more' ); endif; /** * Display a front page section. * * @param WP_Customize_Partial $partial Partial associated with a selective refresh request. * @param integer $id Front page section to display. */ function dan_front_page_section( $partial = null, $id = 0 ) { if ( is_a( $partial, 'WP_Customize_Partial' ) ) { // Find out the id and set it up during a selective refresh. global $dan_counter; $id = str_replace( 'panel_', '', $partial->id ); $dan_counter = $id; } global $post; // Modify the global post object before setting up post data. if ( get_theme_mod( 'panel_' . $id ) ) { $post = get_post( get_theme_mod( 'panel_' . $id ) ); setup_postdata( $post ); set_query_var( 'panel', $id ); get_template_part( 'template-parts/content', 'front-page-panels' ); wp_reset_postdata(); } elseif ( is_customize_preview() ) { // The output placeholder anchor. echo '
' . sprintf( __( 'Front Page Section %1$s Placeholder', 'dan' ), $id ) . '
'; } } /** * Returns true if a blog has more than 1 category. * * @return bool */ function dan_categorized_blog() { $all_the_cool_cats = get_transient( 'dan_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( 'dan_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 || is_preview() ) { // This blog has more than 1 category so dan_categorized_blog should return true. return true; } else { // This blog has only 1 category so dan_categorized_blog should return false. return false; } } /** * Flush out the transients used in dan_categorized_blog. */ function dan_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'dan_categories' ); } add_action( 'edit_category', 'dan_category_transient_flusher' ); add_action( 'save_post', 'dan_category_transient_flusher' );