%s %s
', esc_html( $excerpt ), $more ); return $rt; } endif; if ( ! function_exists( 'bastet_short_excerpt' ) ) : /** * Number of words for short excerpt. */ function bastet_short_excerpt() { return 16; } endif; if ( ! function_exists( 'bastet_categorized_blog' ) ) : /** * Are we on blog with more than 2 categories ? */ function bastet_categorized_blog() { $all_the_cool_cats = get_transient( 'bastet_categories' ); if ( false === $all_the_cool_cats ) { $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( 'bastet_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { return true; } else { return false; } } endif; if ( ! function_exists( 'bastet_sanitize_output' ) ) : /** * Wrapper function to avoid printing direct variables * * @param string $toescape escaped content. */ function bastet_sanitize_output( $toescape ) { return $toescape; } endif; if ( ! function_exists( 'bastet_header_class' ) ) : /** * Print HTML with header class and class attribute * * @param array $class List of classes. */ function bastet_header_class( $class = array() ) { $classes = array(); $classes[] = 'site-header'; $classes[] = get_theme_mod( 'header_style', 'light' ); $classes[] = get_theme_mod( 'header_style', 'light' ) === 'transparent' ? 'light transparent' : ''; if ( get_theme_mod( 'header_search', 1 ) ) { $classes[] = 'with-search'; } if ( get_theme_mod( 'header_shy', 0 ) ) { $classes[] = 'smart-mode'; } if ( get_theme_mod( 'header_fixed', 0 ) ) { $classes[] = 'fixed-mode'; } if ( is_admin_bar_showing() ) { $class[] = 'with-admin-bar'; } $classes = array_merge( $classes, $class ); $classes = array_map( 'esc_attr', $classes ); $classes = apply_filters( 'bastet_header_classes', $classes, $class ); echo 'class="' . esc_attr( join( ' ', $classes ) ) . '"'; } endif; if ( ! function_exists( 'bastet_main_nav' ) ) : /** * Print site main navigation * * @param array $args wp_nav_menu args. */ function bastet_main_nav( $args = array() ) { echo bastet_get_main_nav( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } endif; if ( ! function_exists( 'bastet_get_primary_menu' ) ) : /** * Return site main navigation * * @param array $args wp_nav_menu args. */ function bastet_get_primary_menu( $args = array() ) { $menu_args = array( 'theme_location' => 'primary', 'depth' => 3, 'container' => false, 'fallback_cb' => 'Bootstrap_Walker::fallback', 'menu_class' => 'navbar-nav', 'walker' => new Bastet_Bootstrap_Walker(), 'echo' => false, ); $menu_args = wp_parse_args( $args, $menu_args ); return wp_nav_menu( $menu_args ); } endif; if ( ! function_exists( 'bastet_get_main_nav' ) ) : /** * Return HTML with site main navigation * * @param array $args wp_nav_menu args. */ function bastet_get_main_nav( $args = array() ) { ob_start(); echo sprintf( '', esc_html__( 'Toggle navigation', 'bastet' ), wp_kses( bastet_get_svg_icon( 'menu' ), bastet_allowed_svg_markup() ) ); echo ''; return ob_get_clean(); } endif; if ( ! function_exists( 'bastet_get_sidebar_position' ) ) : /** * Return theme mod for current page sidebar position */ function bastet_get_sidebar_position() { $mod_name = 'bastet_sidebar_' . bastet_current_page_name() . ''; if ( is_home() || is_front_page() ) { return ! is_active_sidebar( 'sidebar' ) ? 'no-sidebar' : get_theme_mod( $mod_name, 'right-sidebar' ); } elseif ( is_single() ) { return ! is_active_sidebar( 'post' ) ? 'no-sidebar' : get_theme_mod( $mod_name, 'right-sidebar' ); } elseif ( is_page() ) { return ! is_active_sidebar( 'page' ) ? 'no-sidebar' : get_theme_mod( $mod_name, 'right-sidebar' ); } return ! is_active_sidebar( 'sidebar' ) ? 'no-sidebar' : get_theme_mod( $mod_name, 'right-sidebar' ); } endif; if ( ! function_exists( 'bastet_get_posts_layout' ) ) : /** * Return theme mod for query layout */ function bastet_get_posts_layout() { $mod_name = 'bastet_layout_' . bastet_current_page_name() . ''; $query_var = get_query_var( 'bastet_mods' ); if ( ! empty( $query_var ) ) { return get_query_var( $query_var['layout'] ); } return get_theme_mod( $mod_name, 'card' ); } endif; if ( ! function_exists( 'bastet_get_posts_layout_meta' ) ) : /** * Return theme mod for enabled post meta * * @param string $meta meta name. * @param bool $default default state. */ function bastet_get_posts_layout_meta( $meta, $default = 1 ) { $mod_name = 'bastet_' . $meta . '_' . bastet_current_page_name() . ''; $query_var = get_query_var( 'bastet_mods' ); if ( ! empty( $query_var ) ) { return (int) $query_var[ $meta ]; } return get_theme_mod( $mod_name, $default ); } endif; if ( ! function_exists( 'bastet_get_post_layout' ) ) : /** * Return theme mod for single post layout */ function bastet_get_post_layout() { $mod_name = 'bastet_layout_' . bastet_current_page_name() . ''; $query_var = get_query_var( 'bastet_mods' ); if ( ! empty( $query_var ) ) { return esc_attr( get_query_var( $query_var['layout'] ) ); } return get_theme_mod( $mod_name, 'large-header' ); } endif; if ( ! function_exists( 'bastet_get_post_layout_meta' ) ) : /** * Return theme mod for enabled post meta on single post * * @param string $meta meta name. * @param bool $default default state. */ function bastet_get_post_layout_meta( $meta, $default = 1 ) { $mod_name = 'bastet_' . $meta . '_' . bastet_current_page_name() . ''; $query_var = get_query_var( 'bastet_mods' ); if ( ! empty( $query_var ) ) { return (int) $query_var[ $meta ]; } return get_theme_mod( $mod_name, $default ); } endif; if ( ! function_exists( 'bastet_comments_count' ) ) : /** * Return number of comments for given post id * * @param int $id Post ID. */ function bastet_comments_count( $id = 0 ) { $num_comments = get_comments_number( $id ); if ( comments_open( $id ) ) { if ( 0 === $num_comments ) { $comments = esc_html__( '0 Comment', 'bastet' ); } elseif ( $num_comments > 1 ) { $comments = $num_comments . esc_html__( ' Comments', 'bastet' ); } else { $comments = esc_html__( '1 Comment', 'bastet' ); } $write_comments = $comments; } else { $write_comments = esc_html__( 'Comments are off', 'bastet' ); } return $write_comments; } endif; if ( ! function_exists( 'wp_body_open' ) ) : /** * Backward compatibility for WordPress older than 5.2 */ function wp_body_open() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound do_action( 'wp_body_open' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound } endif; if ( ! function_exists( 'bastet_the_archive_title' ) ) : /** * Print current archive page title and tag * * @param string $before HTML before title. * @param string $after HTML after title. */ function bastet_the_archive_title( $before = '', $after = '' ) { $allowed_html = array( 'h1' => array( 'class' => array() ), 'p' => array(), 'span' => array( 'class' => array() ), ); $tag_title = ''; if ( is_category() ) { $tag_title = '' . esc_html__( 'Category', 'bastet' ) . ''; $title = single_cat_title( '', false ); } elseif ( is_tag() ) { $tag_title = '' . esc_html__( 'Tag', 'bastet' ) . ''; $title = single_tag_title( '', false ); } elseif ( is_author() ) { $tag_title = '' . esc_html__( 'Author Archive', 'bastet' ) . ''; $title = '' . get_the_author() . ''; } elseif ( is_year() ) { $tag_title = '' . esc_html__( 'Year', 'bastet' ) . ''; $title = get_the_date( _x( 'Y', 'yearly archives date format', 'bastet' ) ); } elseif ( is_month() ) { $tag_title = '' . esc_html__( 'Month', 'bastet' ) . ''; $title = get_the_date( _x( 'F Y', 'monthly archives date format', 'bastet' ) ); } elseif ( is_day() ) { $tag_title = '' . esc_html__( 'Day', 'bastet' ) . ''; $title = get_the_date( _x( 'F j, Y', 'daily archives date format', 'bastet' ) ); } elseif ( is_tax( 'post_format', 'post-format-aside' ) ) { $title = _x( 'Asides', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { $title = _x( 'Galleries', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-image' ) ) { $title = _x( 'Images', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-video' ) ) { $title = _x( 'Videos', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { $title = _x( 'Quotes', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-link' ) ) { $title = _x( 'Links', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-status' ) ) { $title = _x( 'Statuses', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { $title = _x( 'Audio', 'post format archive title', 'bastet' ); } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { $title = _x( 'Chats', 'post format archive title', 'bastet' ); } elseif ( is_post_type_archive() ) { /* translators: %s: post type archive */ $title = sprintf( esc_html__( 'Archives: %s', 'bastet' ), post_type_archive_title( '', false ) ); } elseif ( is_tax() ) { $tax = get_taxonomy( get_queried_object()->taxonomy ); $tag_title = sprintf( '%1$s', esc_html( $tax->labels->singular_name ) ); $title = single_term_title( '', false ); } else { $title = esc_html__( 'Archives', 'bastet' ); } /** * Filter the archive title. * * @param string $title Archive title to be displayed. */ $title = apply_filters( 'bastet_the_archive_title', $title ); $tag_title = apply_filters( 'bastet_the_archive_tag_title', $tag_title ); if ( ! empty( $title ) ) { echo wp_kses( $tag_title, $allowed_html ) . wp_kses( $before, $allowed_html ) . wp_kses( $title, $allowed_html ) . wp_kses( $after, $allowed_html ); } } endif; if ( ! function_exists( 'bastet_the_archive_description' ) ) : /** * Print current archive page description * * @param string $before HTML before description. * @param string $after HTML after description. */ function bastet_the_archive_description( $before = '', $after = '' ) { $allowed_html = array( 'div' => array( 'class' => array() ), 'p' => array(), 'span' => array( 'class' => array() ), ); $description = apply_filters( 'bastet_the_archive_description', term_description() ); if ( ! empty( $description ) ) { echo wp_kses( $before, $allowed_html ) . wp_kses( $description, $allowed_html ) . wp_kses( $after, $allowed_html ); } } endif; if ( ! function_exists( 'bastet_the_search_title' ) ) : /** * Print search page query * * @param string $before HTML before search title. * @param string $after HTML after search title. */ function bastet_the_search_title( $before = '', $after = '' ) { $allowed_html = array( 'h1' => array( 'class' => array() ), 'p' => array(), 'span' => array( 'class' => array() ), ); $title = sprintf( '%s%s', esc_html__( 'Search Results For: ', 'bastet' ), get_search_query() ); echo wp_kses( $before, $allowed_html ) . apply_filters( 'bastet_the_search_title', $title ) . wp_kses( $after, $allowed_html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } endif; if ( ! function_exists( 'bastet_the_search_count' ) ) : /** * Print the number of found posts on search * * @param string $before HTML before search count. * @param string $after HTML after search count. */ function bastet_the_search_count( $before = '', $after = '' ) { global $wp_query; $allowed_html = array( 'h1' => array( 'class' => array() ), 'p' => array(), 'span' => array( 'class' => array() ), ); $title = sprintf( '%s %s', esc_html( $wp_query->found_posts ), esc_html__( 'Results', 'bastet' ) ); echo wp_kses( $before, $allowed_html ) . apply_filters( 'bastet_the_search_count', $title ) . wp_kses( $after, $allowed_html ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } endif; if ( ! function_exists( 'bastet_the_author_post_link' ) ) : /** * Print the author link with first and last name */ function bastet_get_the_author_post_link() { global $authordata; $first_name = get_the_author_meta( 'first_name', $authordata->ID ); $last_name = get_the_author_meta( 'last_name', $authordata->ID ); $link = sprintf( '%3$s', esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), /* translators: %s: Author's display name. */ esc_attr( sprintf( __( 'Posts by %s', 'bastet' ), get_the_author() ) ), empty( $first_name ) ? get_the_author() : esc_html( $first_name . ' ' . $last_name ) ); return $link; } endif; if ( ! function_exists( 'bastet_comments' ) ) : /** * Print HTML for comment * * @param object $comment Comment object. * @param array $args Comment arg. * @param string $depth Comment depth. */ function bastet_comments( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>