class can be filtered now. * * @since 1.0.0 * * @param void * @return bool True if image exists and was not removed, false otherwise. */ function calib_has_header_image() { if ( ! has_header_image() ) : return false; endif; return (bool) apply_filters( 'calib_has_header_image', true ); } endif; if ( ! function_exists( 'calib_content_format_gallery' ) ) : /** * Extract first gallery shortcode from the content to use it in the template * * @since 1.0.0 * * @param string $more_link_text Optional. Content for when there is more text. * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. * @return array Raw content of the post and the first gallery shortcode found in the content */ function calib_content_format_gallery( $more_link_text = null, $strip_teaser = false ) { $content = get_the_content( $more_link_text, $strip_teaser ); $content_gallery = array( 'content' => str_replace( ']]>', ']]>', $content ), 'gallery' => '' ); preg_match_all( '/'. get_shortcode_regex() .'/s', $content, $matches, PREG_SET_ORDER ); if ( ! empty( $matches ) ) : foreach ( $matches as $shortcode ) : if ( 'gallery' === $shortcode[2] ) : /** * Filters the limit number for the query. * * @since 1.0.0 * * @param int Limit number. Unlimited by default. * @param array $shortcode_atts Extracted gallery shortcode attributes. */ $limit = apply_filters( 'calib_gallery_shortcode_limit', -1, shortcode_parse_atts( $shortcode[3] ) ); // Trick to limit attachments number and reset after query performed add_filter( 'calib_gallery_attachments_query_limit', function() use ( &$limit ) { return $limit; } ); add_action( 'pre_get_posts', 'calib_limit_gallery_attachments_query' ); add_filter( 'gallery_style', 'calib_reset_gallery_attachments_query' ); // Store shortcode to be returned at the end $content_gallery['gallery'] = $shortcode[0]; // Store content without the extracted shortcode $pos = strpos( $content, $shortcode[0] ); if ( false !== $pos ) : $content_gallery['content'] = substr_replace( $content, '', $pos, strlen( $shortcode[0] ) ); break; endif; endif; endforeach; endif; return $content_gallery; } endif; if ( ! function_exists( 'calib_the_archive_title' ) ) : /** * Display the archive title based on the queried object. * * @since 1.0.0 * * @param string $before Optional. Content to prepend to the title. Default empty. * @param string $after Optional. Content to append to the title. Default empty. * @return void */ function calib_the_archive_title( $before = '', $after = '' ) { if ( is_category() ) : $title = sprintf( __( 'Category: %s', 'calibration' ), '' . single_cat_title( '', false ) . '' ); elseif ( is_tag() ) : $title = sprintf( __( 'Tag: %s', 'calibration' ), '' . single_tag_title( '', false ) . '' ); elseif ( is_author() ) : $title = sprintf( __( 'Author: %s', 'calibration' ), '' . get_the_author() . '' ); elseif ( is_year() ) : $title = sprintf( __( 'Year: %s', 'calibration' ), '' . get_the_date( _x( 'Y', 'yearly archives date format', 'calibration' ) ) . '' ); elseif ( is_month() ) : $title = sprintf( __( 'Month: %s', 'calibration' ), '' . get_the_date( _x( 'F Y', 'monthly archives date format', 'calibration' ) ) . '' ); elseif ( is_day() ) : $title = sprintf( __( 'Day: %s', 'calibration' ), '' . get_the_date( _x( 'F j, Y', 'daily archives date format', 'calibration' ) ) . '' ); elseif ( is_tax( 'post_format' ) ) : if ( is_tax( 'post_format', 'post-format-aside' ) ) : $title = '' . _x( 'Asides', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) : $title = '' . _x( 'Galleries', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-image' ) ) : $title = '' . _x( 'Images', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-video' ) ) : $title = '' . _x( 'Videos', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-quote' ) ) : $title = '' . _x( 'Quotes', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-link' ) ) : $title = '' . _x( 'Links', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-status' ) ) : $title = '' . _x( 'Statuses', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-audio' ) ) : $title = '' . _x( 'Audio', 'post format archive title', 'calibration' ) . ''; elseif ( is_tax( 'post_format', 'post-format-chat' ) ) : $title = '' . _x( 'Chats', 'post format archive title', 'calibration' ) . ''; endif; elseif ( is_post_type_archive() ) : $title = sprintf( __( 'Archives: %s', 'calibration' ), '' . post_type_archive_title( '', false ) . '' ); elseif ( is_tax() ) : $tax = get_taxonomy( get_queried_object()->taxonomy ); /* translators: 1: Taxonomy singular label, 2: Single term title */ $title = sprintf( __( '%1$s: %2$s', 'calibration' ), $tax->labels->singular_name, '' . single_term_title( '', false ) . '' ); elseif ( is_search() ) : /* translators: %s: Searched term */ $title = sprintf( esc_html__( 'Search for: %s', 'calibration' ), '' . get_search_query() . '' ); else : $title = '' . __( 'Archives', 'calibration' ) . ''; endif; /** * Filters the archive title. * * @since 1.0.0 * * @param string $title Archive title to be displayed. */ $title = apply_filters( 'calib_the_archive_title', $title ); if ( ! empty( $title ) ) : echo $before . $title . $after; endif; } endif; if ( ! function_exists( 'calib_the_author' ) ) : /** * Display the post author * * @since 1.0.0 * * @return void */ function calib_the_author() { $output = "
\n"; $output .= sprintf( "%1s\n%2s\n%3s\n

%4s

\n%6s\n", esc_html__( 'Author:', 'calibration' ), get_avatar( get_the_author_meta( 'ID' ) ), esc_html( get_the_author() ), get_the_author_meta( 'description' ), get_author_posts_url( get_the_author_meta( 'ID' ) ), esc_html__( 'View posts', 'calibration' ) ); if ( get_the_author_meta( 'url' ) ) $output .= sprintf( "%2s\n", get_the_author_meta( 'url' ), esc_html__( 'Visit website', 'calibration' ) ); $output .= "
\n"; /** * Filters the post author HTML * * @since 1.0.0 * * @param string $output Author info code. */ $output = apply_filters( 'calib_the_author_html', $output ); echo $output; } endif; if ( ! function_exists( 'calib_entry_date' ) ) : /** * Display entry date wrapped in