%2$s'; 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() ) ); $posted_on = sprintf( '%2$s', esc_url( get_permalink() ), wp_kses( $time_string, array( 'i' => array( 'class' => array() ), 'span' => array( 'class' => array() ), 'time' => array( 'class' => array(), 'datetime' => array() ) ) ) ); $byline = sprintf( /* translators: %s: post author name */ esc_html_x( 'By %s', 'post author', 'corporately' ), '' . esc_html( get_the_author() ) . '' ); //echo ' ' . $byline . ''; echo '' . $posted_on . ''; // WPCS: XSS OK. // Categories if ( 'post' === get_post_type() || 'jetpack-portfolio' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ if( 'post' === get_post_type() ) { $categories_list = get_the_category_list( __( '
  • ', 'corporately' ) ); } elseif ( 'jetpack-portfolio' === get_post_type() ) { $categories_list = get_the_term_list( $post->ID, 'jetpack-portfolio-type', '', '
  • ', '' ); } } } endif; if ( ! function_exists( 'corporately_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function corporately_entry_footer() { global $post; // Hide category and tag text for pages. if ( 'post' === get_post_type() || 'jetpack-portfolio' === get_post_type() ) { /* translators: used between list items, there is a space after the comma */ if( 'post' === get_post_type() ) { $categories_list = get_the_category_list( esc_html__( ', ', 'corporately' ) ); } elseif( 'jetpack-portfolio' === get_post_type() ) { $categories_list = get_the_term_list( $post->ID, 'jetpack-portfolio-type', '', esc_html_x(', ', 'Used between list items, there is a space after the comma.', 'corporately' ), ''); } if ( $categories_list && corporately_categorized_blog() ) { printf( '' . $categories_list . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ if ( 'post' === get_post_type() ) { $tags_list = get_the_tag_list( '
  • ', '
  • ', '
  • ' ); } elseif ( 'jetpack-portfolio' === get_post_type() ) { $tags_list = get_the_term_list( $post->ID, 'jetpack-portfolio-tag', '
  • ', '
  • ', '
  • ' ); } if ( $tags_list ) { echo ''; // WPCS: XSS OK. } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; comments_popup_link( esc_html__( 'Leave a comment', 'corporately' ), esc_html__( '1 Comment', 'corporately' ), esc_html__( '% Comments', 'corporately' ) ); echo ''; } } endif; /** * Returns true if a blog has more than 1 category. * * @return bool */ function corporately_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'corporately_categories' ) ) ) { // 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( 'corporately_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so corporately_categorized_blog should return true. return true; } else { // This blog has only 1 category so corporately_categorized_blog should return false. return false; } } /** * Flush out the transients used in corporately_categorized_blog. */ function corporately_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'corporately_categories' ); } add_action( 'edit_category', 'corporately_category_transient_flusher' ); add_action( 'save_post', 'corporately_category_transient_flusher' ); /*============================================================================== * corporately CUSTOM TAGS BELOW =============================================================================*/ /** * Fancy excerpts * * @link: http://wptheming.com/2015/01/excerpt-versus-content-for-archives/ */ function corporately_fancy_excerpt() { global $post; if( is_archive() ) { the_excerpt(); echo '
    '; echo '' . esc_html__( 'Continue Reading', 'corporately' ) . ''; echo '
    '; } elseif ( is_page_template( 'page-templates/page-child-pages.php' ) ) { the_excerpt(); echo '
    '; echo ''; echo '
    '; } elseif ( has_excerpt() || is_page_template( 'page-templates/frontpage-portfolio.php' ) ) { the_excerpt(); echo '
    '; echo '' . esc_html__( 'Continue Reading', 'corporately' ) . ''; echo '
    '; } elseif ( strpos ( $post->post_content, '' ) ) { the_content(); echo '
    '; echo '' . esc_html__( 'Continue Reading', 'corporately' ) . ''; echo '
    '; } elseif ( str_word_count ( $post->post_content ) < 200 ) { the_excerpt(); } else { the_excerpt(); echo '
    '; echo '' . esc_html__( 'Continue Reading', 'corporately' ) . ''; echo '
    '; } } /* * Customize the read-more indicator for excerpts */ function corporately_excerpt_more( $more ) { if( is_admin() ) { return $more; } return " …"; } add_filter( 'excerpt_more', 'corporately_excerpt_more' ); /** * Add an author box below posts * @link http://www.wpbeginner.com/wp-tutorials/how-to-add-an-author-info-box-in-wordpress-posts/ */ function corporately_author_box() { global $post; // Detect if a post author is set if ( isset( $post->post_author ) ) { /* * Get Author info */ $display_name = get_the_author_meta( 'display_name', $post->post_author ); // Get the author's display name if ( empty ( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); // If display name is not available, use nickname $user_desc = get_the_author_meta( 'user_description', $post->post_author ); // Get bio info $user_site = get_the_author_meta( 'url', $post->post_author ); // Website URL $user_posts = get_author_posts_url( get_the_author_meta( 'ID', $post->post_author ) ); // Link to author archive page /* * Create the Author box */ $author_details = ''; echo wp_kses_post( $author_details ); } } function corporately_portfolio_index_footer() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '' . esc_attr__( 'First posted: ', 'corporately' ) . '' . '' . ''; } $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() ) ); $posted_on = sprintf( '%2$s', esc_url( get_permalink() ), wp_kses( $time_string, array( 'i' => array( 'class' => array() ), 'span' => array( 'class' => array() ), 'time' => array( 'class' => array(), 'datetime' => array() ) ) ) ); $project_type = get_the_term_list( get_the_ID(), 'jetpack-portfolio-type', '', esc_html_x( ', ', 'Used between list items, there is a space after the comma.', 'corporately' ), '' ); $output = ''; echo wp_kses_post( $output ); } if ( ! function_exists( 'corporately_breadcrumbs' ) ) : /** * Display Post breadcrumbs when applicable. * * @since corporately 1.0 * * @link: https://www.branded3.com/blog/creating-a-really-simple-breadcrumb-function-for-pages-in-wordpress/ */ function corporately_breadcrumbs() { global $post; $output = ''; $breadcrumbs = array(); $separator = '»'; $breadcrumb_id = 'breadcrumbs'; $breadcrumb_class = 'entry-meta'; $page_title = '' . get_the_title( $post->ID ) . ''; $home_link = '' . $separator; $output .= "
    "; $output .= $home_link; if( $post->post_parent ) { $parent_id = $post->post_parent; while( $parent_id ) { $page = get_page( $parent_id ); $breadcrumbs[] = '' . get_the_title( $page->ID ) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse( $breadcrumbs ); $breadcrumbs_str = implode( $separator, $breadcrumbs ); $output .= $breadcrumbs_str . $separator; } $output .= $page_title; $output .= "
    "; echo wp_kses_post( $output ); } endif; /** * Social Menu */ function corporately_social_menu() { if ( has_nav_menu( 'social' ) ) { wp_nav_menu( array( 'theme_location' => 'social', 'container' => 'div', 'container_id' => 'menu-social-container', 'container_class' => 'menu-social', 'menu_id' => 'menu-social-items', 'menu_class' => 'menu-items', 'depth' => 1, 'link_before' => '', 'link_after' => '', 'fallback_cb' => '', ) ); } } /* * Post Icon - can be set in any Post or Page with Custom Fields meta value 'post_icon' * Accepts BOTH Dashicons and FontAwesome icons - or returns nothing if neither fa- nor dashicons- precedes the String */ function corporately_post_icon() { $output = ''; // Get the Page icon (if any - Set in Custom Fields for the Page) $icon = ''; $icon = get_post_meta( get_the_ID(), 'post_icon', true ); // Set in the Custom Meta of the Post if( strstr( $icon, 'dashicons-' ) ) { $icon_class = 'dashicons ' . $icon; } else if( strstr( $icon, 'fa-' ) ) { $icon_class = 'fa ' . $icon; } else { $icon_class = ''; } if ( $icon_class != '' ) { $output .= ""; } return $output; } function corporately_the_post_icon() { echo wp_kses( corporately_post_icon(), array( 'span' => array( 'class' => array() ) ) ); } /** * Function to show the Jetpack sharing and Likes only at the designated locations in Posts and Pages */ function corporately_jetpack_sharing() { if ( function_exists( 'sharing_display' ) ) { sharing_display( '', true ); } if ( class_exists( 'Jetpack_Likes' ) ) { $custom_likes = new Jetpack_Likes; echo esc_html( $custom_likes->post_likes( '' ) ); } } /** * Prints HTML with post navigation. */ function corporately_post_navigation() { // Don't print empty makrup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post ( get_post() -> post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) { return; } ?> 3, 'prev_text' => __( 'Previous', 'corporately' ), 'next_text' => __( 'Next', 'corporately' ), 'type' => 'list', )); } endif; if ( ! function_exists( 'corporately_copyright' ) ) : /** * Dynamic Copyright as per WPBeginner.com * @source: http://www.wpbeginner.com/wp-tutorials/how-to-add-a-dynamic-copyright-date-in-wordpress-footer/ */ function corporately_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results( "SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish' " ); $output = ''; $blog_name = get_bloginfo(); if ( $copyright_dates ) { $copyright = "© " . $copyright_dates[0]->firstdate; if ( $copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate ) { $copyright .= " – " . $copyright_dates[0]->lastdate; } $output = $copyright . " " . $blog_name; } return $output; } endif;