'.esc_html__('Read more…','best-blog').''; } elseif ( is_front_page() ) { // static homepage return '...'; } elseif ( is_home() ) { // blog page return ''.esc_html__('Read more…','best-blog').''; } else { //everything else return ' '.esc_html__('Read more…','best-blog').''; } else : return '...'; endif; } add_filter('excerpt_more', 'bestblog_excerpt_more'); /** * Link thumbnails to their posts based on attr * * @param $html * @param int $pid * @param int $post_thumbnail_id * @param int $size * @param array $attr * * @return string */ function bestblog_filter_post_thumbnail_html( $html, $pid, $post_thumbnail_id, $size, $attr ) { if ( ! empty( $attr[ 'link_thumbnail' ] ) ) { $html = sprintf( '%s', esc_url(get_permalink( $pid )), esc_attr( get_the_title( $pid ) ), $html ); } return $html; } add_filter( 'post_thumbnail_html', 'bestblog_filter_post_thumbnail_html', 10, 5 ); /** * comments meta */ if (! function_exists('bestblog_meta_comment')) : function bestblog_meta_comment() { if (! post_password_required() && (comments_open() || get_comments_number())) { echo ''; /* translators: %s: post title */ comments_popup_link(sprintf(wp_kses(__('Leave a Comment on %s', 'best-blog'), array( 'span' => array( 'class' => array() ) )), get_the_title())); echo ''; } } endif; /** * Prints categories list. */ if (! function_exists('bestblog_category_list')) : function bestblog_category_list() { $categories = get_the_category(); $output = ''; if (is_single()) { $separator = ''; if (! empty($categories)) { foreach ($categories as $category) { $output .= '' . esc_html($category->name) . '' . $separator; } } } else { $separator = ''; if (! empty($categories)) { foreach ($categories as $category) { $output .= '' . esc_html($category->name) . '' . $separator; } } } echo trim($output, $separator); } endif; // Print categories for slider_setup if (! function_exists('bestblog_category_slider')) : function bestblog_category_slider() { $categories = get_the_category(); $output = ''; $separator = ''; if (! empty($categories)) { foreach ($categories as $category) { $output .= '' . esc_html($category->name) . '' . $separator; } } echo trim($output, $separator); } endif; // Print categories for widgets if (! function_exists('bestblog_category_widgtesmission')) : function bestblog_category_widgtesmission() { $categories = get_the_category(); $output = ''; $separator = ''; if (! empty($categories)) { foreach ($categories as $category) { $output .= '' . esc_html($category->name) . '' . $separator; } } echo trim($output, $separator); } endif; /** * Prints first category link and name */ if (! function_exists('bestblog_firstcategory_link')) : function bestblog_firstcategory_link() { $categories = get_the_category(); if (! empty($categories)) { echo '' . esc_html($categories[0]->name) . ''; } } endif; if (! function_exists('bestblog_meta_tag')) : /** * Prints HTML with meta information for the tags . */ function bestblog_meta_tag() { // 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) { echo ''; _e('Tagged:', 'best-blog'); echo ''; echo $tags_list; } } } endif; if (! function_exists('bestblog_edit_link')) : /** * Prints HTML with meta information for the tags . */ function bestblog_edit_link() { edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__('Edit %s', 'best-blog'), the_title('"', '"', false) ), '' ); } endif; if (! function_exists('bestblog_time_link')) : /** * Gets a nicely formatted string for the published date. */ function bestblog_time_link() { $time_string = ''; $time_string = sprintf( $time_string, get_the_date(DATE_W3C), get_the_date(), get_the_modified_date(DATE_W3C), get_the_modified_date() ); $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __('Posted on %s', 'best-blog'), ' ' . $time_string . '' ); } endif; /* Function which displays your post date in time ago format */ function bestblog_time_ago() { return human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ).' '.esc_html__( 'ago','best-blog' ); } if (! function_exists('bestblog_author_bio')) : function bestblog_author_bio() { // Post meta author $author = sprintf( esc_html_x('Posts by: %s', 'post author', 'best-blog'), esc_html(get_the_author()) ); echo $author ; } endif; /** * Post page title “Category:”, “Tag:”, “Author:”, “Archives:” and “Other taxonomy name:” */ if (! function_exists('bestblog_getpost_page_title')) : function bestblog_getpost_page_title() { if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('', false); } elseif (is_author()) { $title = bestblog_author_bio(); } elseif (is_archive()) { $title = the_archive_title(); } elseif (is_tax()) { $title = single_term_title('', false); } elseif (is_search()) { $title = sprintf(esc_html__('Search Results for: %s', 'best-blog'), esc_html(get_search_query())); } return $title; } endif; /** * Post page main title “Category:”, “Tag:”, “Author:”, “Archives:” and “Other taxonomy name:” */ if (! function_exists('bestblog_mainpost_page_title')) : function bestblog_mainpost_page_title() { echo '
'; echo '
'; echo '
'; echo '
'; echo '

'; echo bestblog_getpost_page_title(); echo '

'; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '
'; } endif; if (! function_exists('bestblog_mainpost_blog_title')) : function bestblog_mainpost_blog_title() { echo '
'; echo '
'; echo '
'; echo '

'; echo esc_html__('Blog', 'best-blog'); echo '

'; echo '
'; echo '
'; echo '
'; } endif; /** * Converts Hex color code into RGB * * @param string $color hex color code. * @param string $percentage rgba format. * @return string converted rgb value */ function bestblog_hex2rgba($color, $percentage = 0.5) { $color = trim($color, '#'); if (strlen($color) === 3) { $r = hexdec(substr($color, 0, 1) . substr($color, 0, 1)); $g = hexdec(substr($color, 1, 1) . substr($color, 1, 1)); $b = hexdec(substr($color, 2, 1) . substr($color, 2, 1)); } elseif (strlen($color) === 6) { $r = hexdec(substr($color, 0, 2)); $g = hexdec(substr($color, 2, 2)); $b = hexdec(substr($color, 4, 2)); } else { return $color; } return "rgba( $r, $g, $b, $percentage )"; }