rawurlencode( implode( '|', $font_families ) ),
'subset' => rawurlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
return esc_url_raw( $fonts_url );
}
endif;
if ( ! function_exists( 'bastet_sidebar_area' ) ) :
/**
* Print HTML with dynamic sidebar
*
* @param string $sidebar Sidebar ID.
* @param string $before HTML before sidebar.
* @param string $after HTML after sidebar.
*/
function bastet_sidebar_area( $sidebar, $before = '', $after = '' ) {
$allowed_html = array(
'div' => array(
'class' => array(),
),
'h2' => array(
'class' => array(),
),
'h3' => array(
'class' => array(),
),
'span' => array(
'class' => array(),
),
);
if ( is_active_sidebar( $sidebar ) ) {
echo wp_kses( $before, $allowed_html );
dynamic_sidebar( $sidebar );
echo wp_kses( $after, $allowed_html );
}
}
endif;
/**
* Theme supported colors names
*
* @see bastet_get_theme_palette()
*/
function bastet_get_theme_colors_names() {
$names = array(
'white' => esc_html__( 'White', 'bastet' ),
'smokey' => esc_html__( 'Smokey', 'bastet' ),
'darkgray' => esc_html__( 'Dark Gray', 'bastet' ),
'dark' => esc_html__( 'Dark', 'bastet' ),
'red' => esc_html__( 'Red', 'bastet' ),
'blue' => esc_html__( 'Blue', 'bastet' ),
'peach' => esc_html__( 'Green', 'bastet' ),
'orange' => esc_html__( 'Orange', 'bastet' ),
'pink' => esc_html__( 'Pink', 'bastet' ),
'teal' => esc_html__( 'Teal', 'bastet' ),
'cyan' => esc_html__( 'Cyan', 'bastet' ),
'yellow' => esc_html__( 'Yellow', 'bastet' ),
'indigo' => esc_html__( 'Indigo', 'bastet' ),
'purple' => esc_html__( 'Purple', 'bastet' ),
);
return apply_filters( 'bastet_theme_colors_names', $names );
}
/**
* Theme supported colors values
*
* @see bastet_get_theme_palette()
*/
function bastet_get_theme_colors_values() {
$values = array(
'#fff9f6',
'#f8f6f3',
'#f3efeb',
'#F1F1F1',
'#534d50',
'#b68a63',
'#ff7346',
'#a99478',
'#caa9ac',
'#d4d2cd',
'#ef7f3d',
'#e83e8c',
'#344e5c',
'#4ab19d',
);
return apply_filters( 'bastet_theme_colors_values', $values );
}
/**
* Add class attribute for pagination active link
*
* @see bastet_get_paginate_numbers()
*
* @param string $link Page number link.
*/
function bastet_map_paginate_numbers( $link ) {
$class_attr = strpos( $link, 'current' ) ? 'class=current' : '';
$rt = sprintf(
'
%s',
esc_attr( $class_attr ),
$link
);
return apply_filters( 'bastet_get_paginate_link', $rt, $link );
}
/**
* Callback function for rest api
*
* @see bastet_add_thumbnail_to_json()
*
* @param array $object Post data.
*/
function bastet_get_image_src( $object ) {
$image_size = bastet_get_posts_layout() !== 'card' ? 'bastet_list_card_image' : 'bastet_list_grid_image';
$feat_img_array = wp_get_attachment_image_src(
$object['featured_media'],
$image_size,
true
);
return $feat_img_array[0];
}
/**
* Callback function for rest api
*
* @see bastet_add_author_to_json()
*
* @param array $object Post data.
*/
function bastet_get_author_data( $object ) {
$author_id = $object['author'];
$author_name = get_the_author_meta( 'display_name', $author_id );
$author_url = get_author_posts_url( $author_id );
return array(
'name' => esc_html( $author_name ),
'href' => esc_url( $author_url ),
);
}
/**
* Return current query object name
*/
function bastet_current_page_name() {
$out = '';
if ( is_home() || is_front_page() ) {
$out = 'home';
} elseif ( is_category() ) {
$out = 'category';
} elseif ( is_search() ) {
$out = 'search';
} elseif ( is_author() ) {
$out = 'author';
} elseif ( is_page() ) {
$out = 'page';
} elseif ( is_single() ) {
$out = 'single';
} else {
$out = 'archive';
}
return $out;
}
/**
* Supported post meta
*/
function bastet_get_layout_modes() {
$location = bastet_current_page_name();
$mods = array(
'cats' => get_theme_mod( 'bastet_cats_' . $location, 1 ),
'author' => get_theme_mod( 'bastet_author_' . $location, 1 ),
'date' => get_theme_mod( 'bastet_date_' . $location, 1 ),
'layout' => get_theme_mod( 'bastet_layout_' . $location, 'card' ),
);
return apply_filters( 'bastet_layout_theme_mods', $mods, $location );
}
/**
* Main area class based on the sidebar position
*/
function bastet_get_sidebar_classes() {
$main = 'col-xs-12 col-md-12 col-lg-12';
$sidebar = bastet_get_sidebar_position();
$layout = bastet_get_posts_layout();
if ( 'right-sidebar' === $sidebar ) {
$main = 'col-lg-8 col-sm-12 col-xs-12';
} elseif ( 'left-sidebar' === $sidebar ) {
$main = 'col-lg-8 col-sm-12 col-xs-12 order-lg-3';
} elseif ( 'card' === $layout && 'no-sidebar' === $sidebar ) {
$main = 'col-lg-10 col-md-10 col-sm-12 col-xs-12 offset-md-1 offset-lg-1';
}
return apply_filters( 'bastet_main_area_classes', $main );
}
/**
* Main area for posts class based on the sidebar position
*
* @param string $extras Additional class names.
*/
function bastet_get_post_sidebar_classes( $extras = '' ) {
$post_classes = 'col-lg-8 offset-lg-2 col-md-10 offset-md-1 col-xs-12 ' . esc_attr( $extras ) . '';
$sidebar = bastet_get_sidebar_position();
if ( 'right-sidebar' === $sidebar ) {
$post_classes = 'col-lg-8 col-sm-12 col-xs-12 ' . esc_attr( $extras ) . '';
} elseif ( 'left-sidebar' === $sidebar ) {
$post_classes = 'col-lg-8 col-sm-12 col-xs-12 order-lg-3 ' . esc_attr( $extras ) . '';
}
return apply_filters( 'bastet_post_main_area_classes', $post_classes );
}
/**
* Print class attribute with list of class names
*
* @param array $class Additional class names.
*/
function bastet_footer_widgets_classes( $class = array() ) {
$classes = array();
$classes[] = 'footer-widgets';
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
} else {
$class = array();
}
$classes = array_map( 'esc_attr', $classes );
$classes = apply_filters( 'bastet_footer_widgets_class', $classes, $class );
echo 'class="' . esc_attr( implode( ' ', $classes ) ) . '"';
}
/**
* Print class name for footer widget column
*
* @param int $index Column index.
*/
function bastet_get_footer_columns( $index = 1 ) {
$mod = get_theme_mod( 'footer_columns', 'footer-4' );
$_count = explode( '-', $mod );
$class_name = '';
switch ( $_count[1] ) {
case 1:
$class_name = 'col-lg-12 col-xs-12 col-md-12';
break;
case 2:
$class_name = 'col-md-6 col-lg-6 col-xs-12';
break;
case 3:
$class_name = 'col-md-6 col-lg-4 col-xs-12';
break;
case 4:
$class_name = 'col-lg-3 col-md-6 col-xs-12';
break;
case 62:
if ( 1 === $index ) {
$class_name = 'col-lg-6 col-md-4 col-xs-12';
} else {
$class_name = 'col-lg-2 col-md-3 col-xs-12';
}
break;
case 26:
if ( 4 === $index ) {
$class_name = 'col-lg-6 col-md-4 col-xs-12';
} else {
$class_name = 'col-lg-2 col-md-3 col-xs-12';
}
break;
case 36:
if ( 3 === $index ) {
$class_name = 'col-lg-6 col-md-6 col-xs-12';
} else {
$class_name = 'col-lg-3 col-md-6 col-xs-12';
}
break;
}
return $class_name;
}
/**
* Number of footer columns based on theme mod
*/
function bastet_get_footer_columns_count() {
$mod = get_theme_mod( 'footer_columns', 'footer-4' );
$_count = explode( '-', $mod );
if ( '36' === $_count[1] ) {
$count = 3;
} else {
$count = $_count[1] > 4 ? 4 : $_count[1];
}
return $count;
}
/**
* Print HTML with share text
*
* @param int $post_id Post ID.
*/
function bastet_share_buttons( $post_id ) {
if ( function_exists( 'bastet_blocks_share_buttons' ) ) {
if ( bastet_get_posts_layout_meta( 'share', 1 ) ) {
printf(
'%s%s
',
esc_html__( 'Share', 'bastet' ),
bastet_blocks_share_buttons( $post_id ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
}
}
}
/**
* Print HTML for user meta social icons
*
* @param int $user_id User ID.
*/
function bastet_user_social( $user_id ) {
if ( function_exists( 'bastet_blocks_get_user_social' ) ) {
bastet_blocks_get_user_social( $user_id );
}
}
/**
* Adjust hex color brightness
*
* @param string $hex Hex color value.
* @param int $steps Level of brightness.
*/
function bastet_adjust_color( $hex, $steps ) {
$steps = max( -255, min( 255, $steps ) );
$hex = str_replace( '#', '', $hex );
if ( 3 === strlen( $hex ) ) {
$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
}
$color_parts = str_split( $hex, 2 );
$return = '#';
foreach ( $color_parts as $color ) {
$color = hexdec( $color );
$color = max( 0, min( 255, $color + $steps ) );
$return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT );
}
return $return;
}
/**
* Return theme mod/post meta for single layout
*/
function bastet_get_single_layout() {
$layout = get_theme_mod( 'bastet_layout_single', 'large-header' );
if ( is_single() ) {
$meta = get_post_meta( get_the_ID(), 'bastet_post_layout_meta', true );
if ( isset( $meta ) && ! empty( $meta ) ) {
$layout = $meta;
}
}
return $layout;
}
/**
* Print Header search icon markup
*/
function bastet_get_search_html() {
return '';
}
/**
* Return Header search icon markup
*/
function bastet_search_html() {
echo wp_kses(
bastet_get_search_html(),
array(
'a' => array(
'href' => array(),
'title' => array(),
'class' => array(),
),
'div' => array(
'class' => array(),
),
'i' => array(
'class' => array(),
),
)
);
}
/**
* Return array of allowed HTML tags for svg icons
*/
function bastet_allowed_svg_markup() {
return array(
'svg' => array(
'class' => true,
'aria-hidden' => true,
'aria-labelledby' => true,
'role' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
),
'g' => array( 'fill' => true ),
'title' => array( 'title' => true ),
'path' => array(
'd' => true,
'fill' => true,
),
);
}
/**
* Return array of allowed HTML tags for links
*/
function bastet_allowed_links_markup() {
return array(
'a' => array(
'class' => array(),
'title' => array(),
'rel' => array(),
'href' => array(),
),
);
}
if ( ! function_exists( 'bastet_get_theme_palette' ) ) :
/**
* Return array of theme supported colors and values
*/
function bastet_get_theme_palette() {
$names = bastet_get_theme_colors_names();
$values = bastet_get_theme_colors_values();
$rt = array();
$x = 0;
foreach ( $names as $slug => $name ) {
$rt[] = array(
'name' => esc_html( $name ),
'slug' => esc_attr( $slug ),
'color' => esc_attr( $values[ $x ] ),
);
$x++;
}
return $rt;
}
endif;
/**
* Return content of svg icon
*
* @param string $icon Svg icon name without .svg.
*/
function bastet_get_svg_icon( $icon ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
$wp_filesystem = new WP_Filesystem_Direct( null );
$path = get_template_directory() . '/images/' . $icon . '.svg';
return $wp_filesystem->get_contents( $path );
}