%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( '%s', 'post date', 'aniro-hotel-light' ), '' . $time_string .'' ); echo '' . $posted_on . '';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } endif; /************************************************************************/ if ( ! function_exists( 'anirohotellight_category' ) ) : /** * Prints HTML with meta information for the categories. */ function anirohotellight_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( ' ', 'aniro-hotel-light' ) ); if ( $categories_list && anirohotellight_categorized_blog() ) { printf( '' . esc_html( '%1$s', 'aniro-hotel-light' ) . '', $categories_list );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } endif; /************************************************************************/ if ( ! function_exists( 'anirohotellight_category_5' ) ) : /** * Prints HTML with meta information for the categories. */ function anirohotellight_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__( ', ', 'aniro-hotel-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 && anirohotellight_categorized_blog() ) { printf( '
' . esc_html( '%1$s', 'aniro-hotel-light' ) . '
', $categories_list_back ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } endif; /************************************************************************/ if ( ! function_exists( 'anirohotellight_meta_data' ) ) : /** * Prints HTML with meta information for author, comments and edit link. */ function anirohotellight_meta_data() { $byline = sprintf( esc_html_x( 'Posted by ', 'post author', 'aniro-hotel-light' ).'%s', '' . esc_html( get_the_author() ) . '' ); echo '
'; echo ' ' . $byline . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 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', 'aniro-hotel-light' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'aniro-hotel-light' ), the_title( '"', '"', false ) ), '', '' ); echo '
'; } endif; /************************************************************************/ if ( ! function_exists( 'anirohotellight_index_meta_data' ) ) : /** * Prints HTML with meta information for author, comments and edit link. */ function anirohotellight_index_meta_data() { $byline = sprintf( esc_html_x( 'Posted by ', 'post author', 'aniro-hotel-light' ).'%s', '' . 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( '%s', 'post date', 'aniro-hotel-light' ), '' . $time_string .'' ); echo '' . $posted_on . '';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ' ' . $byline . '';// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 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', 'aniro-hotel-light' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'aniro-hotel-light' ), the_title( '"', '"', false ) ), '', '' ); echo '
'; } endif; /************************************************************************/ if ( ! function_exists( 'anirohotellight_tags' ) ) : /** * Prints HTML with meta information for tags. */ function anirohotellight_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( ' ', 'aniro-hotel-light' ) ); if ( $tags_list ) { printf( '', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } endif; /************************************************************************ * Returns true if a blog has more than 1 category. * * @return bool */ function anirohotellight_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'anirohotellight_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( 'anirohotellight_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so anirohotellight_categorized_blog should return true. return true; } else { // This blog has only 1 category so anirohotellight_categorized_blog should return false. return false; } } /************************************************************************/ /** * Flush out the transients used in anirohotellight_categorized_blog. */ function anirohotellight_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } delete_transient( 'anirohotellight_categories' ); } add_action( 'edit_category', 'anirohotellight_category_transient_flusher' ); add_action( 'save_post', 'anirohotellight_category_transient_flusher' ); /************************************************************************/ if ( ! function_exists( 'anirohotellight_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 anirohotellight_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', 'aniro-hotel-light' ), 'next_text' => __( 'Next', 'aniro-hotel-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 ), 'anirohotellight-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 center; background-origin: content-box; background-size: 200px 200px; 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 ), 'anirohotellight-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 center; background-origin: content-box; background-size: 200px 200px; 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( 'anirohotellight-style', $css ); } add_action( 'wp_enqueue_scripts', 'anirohotellight_post_nav_background' ); /************************************************************************/ if ( ! function_exists( 'anirohotellight_popular_posts' ) ) : /** * Add popular posts in widget */ function anirohotellight_popular_posts($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() ): ?>
$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()) : ?> have_posts() ) : $recent_posts->the_post(); ?>
'attachment', 'post_status' => 'inherit', 'fields' => 'ids', 'meta_query' => array( array( 'value' => $file, 'compare' => 'LIKE', 'key' => '_wp_attachment_metadata', ), ) ); $query = new WP_Query($query_args); if ($query->have_posts()) { foreach ($query->posts as $post_id) { $meta = wp_get_attachment_metadata($post_id); $original_file = basename($meta['file']); $cropped_image_files = wp_list_pluck($meta['sizes'], 'file'); if ($original_file === $file || in_array($file, $cropped_image_files)) { $attachment_id = $post_id; break; } } } } return $attachment_id; } endif;