%2$s';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '' .
esc_attr__( '', 'anyonepage' ) .
'' .
'' .
'%4$s ';
}
$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', 'anyonepage' ),
'' . 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( __( '
', 'anyonepage' ) );
} elseif ( 'jetpack-portfolio' === get_post_type() ) {
$categories_list = get_the_term_list( $post->ID, 'jetpack-portfolio-type', '', ' ', '' );
}
}
}
endif;
if ( ! function_exists( 'anyonepage_entry_footer' ) ) :
/**
* Prints HTML with meta information for the categories, tags and comments.
*/
function anyonepage_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__( ', ', 'anyonepage' ) );
} 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.', 'anyonepage' ), '');
}
if ( $categories_list && anyonepage_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 '';
}
}
endif;
/**
* Returns true if a blog has more than 1 category.
*
* @return bool
*/
function anyonepage_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'anyonepage_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( 'anyonepage_categories', $all_the_cool_cats );
}
if ( $all_the_cool_cats > 1 ) {
// This blog has more than 1 category so anyonepage_categorized_blog should return true.
return true;
} else {
// This blog has only 1 category so anyonepage_categorized_blog should return false.
return false;
}
}
/**
* Flush out the transients used in anyonepage_categorized_blog.
*/
function anyonepage_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
// Like, beat it. Dig?
delete_transient( 'anyonepage_categories' );
}
add_action( 'edit_category', 'anyonepage_category_transient_flusher' );
add_action( 'save_post', 'anyonepage_category_transient_flusher' );
/*==============================================================================
* anyonepage CUSTOM TAGS BELOW
=============================================================================*/
/**
* Fancy excerpts
*
* @link: http://wptheming.com/2015/01/excerpt-versus-content-for-archives/
*/
function anyonepage_fancy_excerpt() {
global $post;
if( is_archive() ) {
the_excerpt();
echo '';
} elseif ( is_page_template( 'page-templates/page-child-pages.php' ) ) {
the_excerpt();
echo '';
} elseif ( has_excerpt() || is_page_template( 'page-templates/frontpage-portfolio.php' ) ) {
the_excerpt();
echo '';
} elseif ( strpos ( $post->post_content, '' ) ) {
the_content();
echo '';
} elseif ( str_word_count ( $post->post_content ) < 200 ) {
the_content();
} else {
the_excerpt();
echo '';
}
}
/*
* Customize the read-more indicator for excerpts
*/
function anyonepage_excerpt_more( $more ) {
if( is_admin() ) {
return $more;
}
return " …";
}
add_filter( 'excerpt_more', 'anyonepage_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 anyonepage_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 = '';
$author_details .= '' . esc_html__( 'About ', 'anyonepage' );
if ( is_author() ) $author_details .= $display_name; // If an author archive, just show the author name
else $author_details .= esc_html__( 'the Author', 'anyonepage' ); // If a regular page, show "About the Author"
$author_details .= ' ';
$author_details .= '';
$author_details .= '
' . get_avatar( get_the_author_meta( 'user_email' ), 120 ) . ' ';
$author_details .= '
';
if ( ! empty( $display_name ) && ! is_author() ) { // Don't show this name on an author archive page
$author_details .= '';
$author_details .= '' . $display_name . ' ';
$author_details .= ' ';
}
if ( ! empty( $user_desc ) )
$author_details .= '' . $user_desc . '
';
if ( ! is_author() ) { // Don't show the meta info on an author archive page
$author_details .= '' . esc_html__( 'All posts by', 'anyonepage' ) . '' . $display_name . ' ';
// Check if author has a website in their profile
if ( ! empty( $user_site ) )
$author_details .= '' . esc_html__( 'Website', 'anyonepage' ) . '
';
else $author_details .= '';
}
$author_details .= ' ';
$author_details .= '
';
$author_details .= '' . esc_html__( 'Hide', 'anyonepage' ) . '
';
$author_details .= ' ';
echo wp_kses_post( $author_details );
}
}
function anyonepage_portfolio_index_footer() {
$time_string = '%2$s ';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '' .
esc_attr__( 'First posted: ', 'anyonepage' ) .
'%2$s ' .
' ' .
'%4$s ';
}
$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.', 'anyonepage' ), ' ' );
$output = '';
echo wp_kses_post( $output );
}
if ( ! function_exists( 'anyonepage_breadcrumbs' ) ) :
/**
* Display Post breadcrumbs when applicable.
*
* @since anyonepage 1.0
*
* @link: https://www.branded3.com/blog/creating-a-really-simple-breadcrumb-function-for-pages-in-wordpress/
*/
function anyonepage_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 anyonepage_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 anyonepage_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 anyonepage_the_post_icon() {
echo wp_kses( anyonepage_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 anyonepage_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 anyonepage_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;
}
?>
' . esc_html_x( 'Previous Post:', 'Previous post', 'anyonepage' ) . '
%link ', '%title' );
next_post_link( '' . esc_html_x( 'Next Post:', 'Next post', 'anyonepage' ) . '
%link ', '%title' );
?>
3,
'prev_text' => __( 'Previous', 'anyonepage' ),
'next_text' => __( 'Next', 'anyonepage' ),
'type' => 'list',
));
}
endif;
if ( ! function_exists( 'anyonepage_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 anyonepage_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;
/**
* Display a front page section.
*
* @param $partial WP_Customize_Partial Partial associated with a selective refresh request.
* @param $id integer Front page section to display.
*/
function anyonepage_front_page_section( $partial = null, $page_name = "" ) {
if ( is_a( $partial, 'WP_Customize_Partial' ) ) {
// Find out the id and set it up during a selective refresh.
// Check TwentySeventeen theme if implementing this in the future
}
global $post; // Modify the global post object before setting up post data.
if ( get_theme_mod( 'panel_' . $page_name ) ) {
global $post;
$post = get_post( get_theme_mod( 'panel_' . $page_name ) );
setup_postdata( $post );
set_query_var( 'panel', $page_name );
get_template_part( 'template-parts/page/content', 'front-page-panels' );
wp_reset_postdata();
} elseif ( is_customize_preview() ) {
// The output placeholder anchor.
echo '' . sprintf( __( '%1$s Page Placeholder', 'anyonepage' ), $page_name ) . ' ';
}
}