%3$s', esc_attr($date_type), esc_attr($date_w3c), esc_html($date) ); $line = ' '; if (filter_var($icon, FILTER_VALIDATE_BOOLEAN)) { $line = ''; } $posted_on = sprintf( '%2$s', esc_url(get_permalink()), $time_string ); $output = '' . wp_kses_post($line . $posted_on) . ''; wp_cache_set($cache_key, $output, '', 3600); } echo $output; } endif; if (!function_exists('author_personal_blog_time')) : /** * Displays the post date/time. * * @return void */ function author_personal_blog_time() { $time_string = ''; 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()) ); echo '' . wp_kses_post($time_string) . ''; } endif; if (!function_exists('author_personal_blog_reading_time')) : /** * Estimates reading time for the current post. * * @return string HTML output with reading time estimate. */ function author_personal_blog_reading_time() { global $post; if (!isset($post->post_content)) { return ''; } $thecontent = wp_strip_all_tags($post->post_content); $words = str_word_count($thecontent); $m = floor($words / 200); $s = floor($words % 200 / (200 / 60)); $estimate = sprintf( '%d minute%s, %d second%s', $m, $m == 1 ? '' : 's', $s, $s == 1 ? '' : 's' ); $output = sprintf( ' %s', esc_html($estimate) ); return $output; } endif; if (!function_exists('author_personal_blog_posted_by')) : /** * Displays the post author with optional avatar. * * @param bool $author_image Whether to display the author image. * @return void */ function author_personal_blog_posted_by($author_image = true) { $post_author_id = get_post_field('post_author', get_queried_object_id()); if (!$post_author_id) { return; } $cache_key = 'post_author_' . get_the_ID(); $posted_by = wp_cache_get($cache_key); if (false === $posted_by) { $get_author_image = filter_var($author_image, FILTER_VALIDATE_BOOLEAN) ? ' ' : ''; $posted_by = sprintf( '%2$s%3$s', esc_url(get_author_posts_url($post_author_id)), wp_kses_post($get_author_image), esc_html(get_the_author_meta('display_name', $post_author_id)) ); wp_cache_set($cache_key, $posted_by, '', 3600); } echo '' . wp_kses_post($posted_by) . ''; } endif; if (!function_exists('author_personal_blog_comment_popuplink')) : /** * Displays a comment link if comments are open or there are comments. * * @return void */ function author_personal_blog_comment_popuplink() { if (post_password_required() || (!comments_open() && !get_comments_number())) { return; } echo ''; $number = (int) get_comments_number(get_the_ID()); $css_class = $number === 0 ? 'zero-comments' : ($number === 1 ? 'one-comment' : 'multiple-comments'); comments_popup_link( esc_html__('Add Comment', 'author-personal-blog'), esc_html__('1 Comment', 'author-personal-blog'), esc_html__('% Comments', 'author-personal-blog'), esc_attr($css_class), esc_html__('Comments are Closed', 'author-personal-blog') ); echo ''; } endif; if (!function_exists('author_personal_blog_categories')) : /** * Displays post categories. * * @return void */ function author_personal_blog_categories() { if (get_post_type() !== 'post') { return; } $cache_key = 'post_categories_' . get_the_ID(); $categories_list = wp_cache_get($cache_key); if (false === $categories_list) { $categories_list = get_the_category_list(' '); wp_cache_set($cache_key, $categories_list, '', 3600); } if ($categories_list) { echo '' . wp_kses_post($categories_list) . ''; } } endif; if (!function_exists('author_personal_blog_post_tag')) : /** * Displays post tags. * * @return void */ function author_personal_blog_post_tag() { if (get_post_type() !== 'post') { return; } $tags_list = get_the_tag_list('', ' '); if ($tags_list) { echo ''; } } endif; if (!function_exists('author_personal_blog_post_thumbnail')) : /** * Displays an optional post thumbnail. * * @return void */ function author_personal_blog_post_thumbnail() { if (!has_post_thumbnail()) { return; } $cache_key = 'post_thumbnail_' . get_the_ID() . '_' . (is_single() || is_page() ? 'large' : 'grid'); $output = wp_cache_get($cache_key); if (false === $output) { if (is_single() || is_page()) { $output = get_the_post_thumbnail(null, 'author-personal-blog-thumbnail-large', ['loading' => 'lazy']); } else { $settings = author_personal_blog_get_theme_settings(); $sidebar_layouts = 'no'; $get_post_column_layout = '3'; if (is_home()) { $sidebar_layouts = get_theme_mod('blog_page_sidebar', 'no'); $get_post_column_layout = $settings['blog_page_post_column']; } elseif (is_search()) { $sidebar_layouts = get_theme_mod('search_page_sidebar', 'no'); $get_post_column_layout = $settings['search_page_post_column']; } elseif (is_archive()) { $sidebar_layouts = get_theme_mod('archive_page_sidebar', 'no'); $get_post_column_layout = $settings['archive_page_post_column']; } $thumbnail_size = 'author-personal-blog-grid-thumbnail'; if ($sidebar_layouts === 'no' && $get_post_column_layout === '2') { $thumbnail_size = 'author-personal-blog-thumbnail-medium'; } elseif (($sidebar_layouts === 'right' || $sidebar_layouts === 'left') && $get_post_column_layout === '2') { $thumbnail_size = 'author-personal-blog-grid-thumbnail'; } $output = sprintf( '%2$s', esc_url(get_the_permalink()), get_the_post_thumbnail(null, $thumbnail_size, ['loading' => 'lazy']) ); } wp_cache_set($cache_key, $output, '', 3600); } echo $output; } endif; if (!function_exists('author_personal_blog_navigation')) : /** * Displays post navigation. * * @return void */ function author_personal_blog_navigation() { $pagination_alignment = get_theme_mod('blog_page_pagination', 'center'); echo '