%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( esc_html_x( '%s', 'post date', 'sagablog-light' ), '' . $time_string .'' ); echo '' . $posted_on . ''; // WPCS: XSS OK. } endif; /************************************************************************/ if ( ! function_exists( 'sagablog_category' ) ) : /** * Prints HTML with meta information for the categories. */ function sagablog_category() { // 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__( ' ', 'sagablog-light' ) ); if ( $categories_list && sagablog_categorized_blog() ) { printf( '' . esc_html__( '%1$s', 'sagablog-light' ) . '', $categories_list ); // WPCS: XSS OK. } } } endif; /************************************************************************/ if ( ! function_exists( 'sagablog_category_5' ) ) : /** * Prints HTML with meta information for the categories. */ function sagablog_category_5() { // 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__( ', ', 'sagablog-light' ) ); //Show not more then 5 category $findme = ','; $pos = mb_substr_count($categories_list, $findme)+1; if ($pos>5){$pos=5;} $categories_list_array = explode(",", $categories_list); $categories_list_array_new = array_chunk($categories_list_array, $pos); $categories_list_back = implode(" ", $categories_list_array_new[0]); if ( $categories_list && sagablog_categorized_blog() ) { printf( '
' . esc_html__( '%1$s', 'sagablog-light' ) . '
', $categories_list_back ); // WPCS: XSS OK. } } } endif; /************************************************************************/ if ( ! function_exists( 'sagablog_meta_data' ) ) : /** * Prints HTML with meta information for author, comments and edit link. */ function sagablog_meta_data() { $byline = sprintf( esc_html_x( 'Posted by %s', 'post author', 'sagablog-light' ), '' . esc_html( get_the_author() ) . '' ); echo '
'; echo ' ' . $byline . ''; // WPCS: XSS OK. if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; /* translators: %s: post title */ comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment on %s', 'sagablog-light' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'sagablog-light' ), the_title( '"', '"', false ) ), '', '' ); //Add social share links $sagablog_share_links_options=esc_html(get_theme_mod( 'sagablog_social_share_links_options', 'share-posts' )); if ($sagablog_share_links_options==='share-posts' || $sagablog_share_links_options==='share-posts-pages'){ get_template_part( 'inc/share', 'links' ); } echo '
'; } endif; /************************************************************************/ if ( ! function_exists( 'sagablog_tags' ) ) : /** * Prints HTML with meta information for tags. */ function sagablog_tags() { // 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( '', esc_html__( ' ', 'sagablog-light' ) ); if ( $tags_list ) { printf( '', $tags_list ); // WPCS: XSS OK. } } } endif; /************************************************************************/ if ( ! function_exists( 'sagablog_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function sagablog_entry_footer() { // 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__( ', ', 'sagablog-light' ) ); if ( $categories_list && sagablog_categorized_blog() ) { printf( '' . esc_html__( 'Posted in %1$s', 'sagablog-light' ) . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'sagablog-light' ) ); if ( $tags_list ) { printf( '' . esc_html__( 'Tagged %1$s', 'sagablog-light' ) . '', $tags_list ); // WPCS: XSS OK. } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; /* translators: %s: post title */ comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment on %s', 'sagablog-light' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'sagablog-light' ), the_title( '"', '"', false ) ), '', '' ); } endif; /************************************************************************ * Returns true if a blog has more than 1 category. * * @return bool */ function sagablog_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'sagablog_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( 'sagablog_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so sagablog_categorized_blog should return true. return true; } else { // This blog has only 1 category so sagablog_categorized_blog should return false. return false; } } /************************************************************************/ /** * Flush out the transients used in sagablog_categorized_blog. */ function sagablog_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } delete_transient( 'sagablog_categories' ); } add_action( 'edit_category', 'sagablog_category_transient_flusher' ); add_action( 'save_post', 'sagablog_category_transient_flusher' ); /************************************************************************/ if ( ! function_exists( 'sagablog_paging_nav' ) ) : /** * Display navigation to next/previous set of posts when applicable. * * @global WP_Query $wp_query WordPress Query object. * @global WP_Rewrite $wp_rewrite WordPress Rewrite object. */ function sagablog_paging_nav() { global $wp_query, $wp_rewrite; // Don't print empty markup if there's only one page. if ( $wp_query->max_num_pages < 2 ) { return; } $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $pagenum_link = html_entity_decode( get_pagenum_link() ); $query_args = array(); $url_parts = explode( '?', $pagenum_link ); if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; // Set up paginated links. $links = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map( 'urlencode', $query_args ), 'prev_text' => __( 'Previous', 'sagablog-light' ), 'next_text' => __( 'Next', 'sagablog-light' ), 'type' => 'list', ) ); if ( $links ) : ?> post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); $css = ''; if ( is_attachment() && 'attachment' == $previous->post_type ) { return; } if ( $previous && has_post_thumbnail( $previous->ID ) ) { $prevthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'sagablog-nav-thumb' ); $css .= ' @media screen and (min-width: 40em) { .post-navigation .nav-previous .addbgpic { background-image: url(' . esc_url( $prevthumb[0] ) . '); background-repeat: no-repeat; background-position: right top; background-origin: content-box; background-size: 100px 100px; border: 2px #f7f7f7 solid; min-height:100px;} .post-navigation .nav-previous a .nav-text {display:block; width:60%;float:left;padding: 0.5em;} .nav-previous .nav-text{border: 0 #f7f7f7 solid;min-height: 100px;} .nav-previous{border: 0 #f7f7f7 solid;} }'; } else { $css .= ' @media screen and (min-width: 40em) { .post-navigation .nav-previous .addbgpic { border: 2px #f7f7f7 solid; min-height:100px;} }'; } if ( $next && has_post_thumbnail( $next->ID ) ) { $nextthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'sagablog-nav-thumb' ); $css .= ' @media screen and (min-width: 40em) { .post-navigation .nav-next .addbgpic { background-image: url(' . esc_url( $nextthumb[0] ) . '); background-repeat: no-repeat; background-position: left top; background-origin: content-box; background-size: 100px 100px; border: 2px #f7f7f7 solid; min-height:100px;} .post-navigation .nav-next a .nav-text {display:block; width:60%;float:right;padding: 0.5em;} .nav-next .nav-text{border: 0 #f7f7f7 solid;min-height: 100px;} .nav-next{border: 0 #f7f7f7 solid;} }'; }else { $css .= ' @media screen and (min-width: 40em) { .post-navigation .nav-previous .addbgpic { border: 2px #f7f7f7 solid; min-height:100px;} }'; } wp_add_inline_style( 'sagablog-style', $css ); } add_action( 'wp_enqueue_scripts', 'sagablog_post_nav_background' ); /************************************************************************/ if ( ! function_exists( 'sagablog_popular_posts_slider' ) ) : /** * Add popular posts in widget */ function sagablog_popular_posts_slider($numbofposts) { $posts_per_page=$numbofposts; $q = new WP_Query( apply_filters( 'popular_posts_args', array( 'posts_per_page' => $posts_per_page, 'post_status' => 'publish', 'orderby' => 'comment_count', 'ignore_sticky_posts' => true ) ) ); if( $q->have_posts() ): ?> $posts_per_page, 'post_status' => 'publish', 'orderby' => 'comment_count', 'ignore_sticky_posts' => true ) ) ); if( $q->have_posts() ): ?> $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($recent_posts->have_posts()) : ?> $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($popular_posts->have_posts()) : ?> have_posts() ) : $popular_posts->the_post(); ?>
  • $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($popular_posts->have_posts()) : ?> have_posts() ) : $popular_posts->the_post(); ?>
  • $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($recent_posts->have_posts()) : ?> $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($recent_posts->have_posts()) : ?> have_posts() ) : $recent_posts->the_post(); ?>
  • $number_of_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($recent_posts->have_posts()) : ?> have_posts() ) : $recent_posts->the_post(); ?>
  • ' . esc_html( get_the_author() ) . '' ); echo '
    '; $time_string = ''; 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( esc_html_x( '%s', 'post date', 'sagablog-light' ), '' . $time_string .'' ); echo '' . $posted_on . ''; // WPCS: XSS OK. echo ' ' . $byline . ''; // WPCS: XSS OK. if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; /* translators: %s: post title */ comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment on %s', 'sagablog-light' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'sagablog-light' ), the_title( '"', '"', false ) ), '', '' ); echo '
    '; } endif;