astra_get_blog_layout_class( string $class = '' )
Retrieve the classes for the body element as an array.
Description
Parameters
- $class
-
(string) (Optional) Class.
Default value: ''
Source
File: inc/blog/blog-config.php
function astra_get_blog_layout_class( $class = '' ) {
// array of class names.
$classes = array();
$post_format = get_post_format();
if ( $post_format ) {
$post_format = 'standard';
}
$classes[] = 'ast-post-format-' . $post_format;
if ( ! has_post_thumbnail() || ! wp_get_attachment_image_src( get_post_thumbnail_id() ) ) {
switch ( $post_format ) {
case 'aside':
$classes[] = 'ast-no-thumb';
break;
case 'image':
$has_image = astra_get_first_image_from_post();
if ( empty( $has_image ) || is_single() ) {
$classes[] = 'ast-no-thumb';
}
break;
case 'video':
$post_featured_data = astra_get_video_from_post( get_the_ID() );
if ( empty( $post_featured_data ) ) {
$classes[] = 'ast-no-thumb';
}
break;
case 'quote':
$classes[] = 'ast-no-thumb';
break;
case 'link':
$classes[] = 'ast-no-thumb';
break;
case 'gallery':
$post_featured_data = get_post_gallery();
if ( empty( $post_featured_data ) || is_single() ) {
$classes[] = 'ast-no-thumb';
}
break;
case 'audio':
$has_audio = astra_get_audios_from_post( get_the_ID() );
if ( empty( $has_audio ) || is_single() ) {
$classes[] = 'ast-no-thumb';
} else {
$classes[] = 'ast-embeded-audio';
}
break;
case 'standard':
default:
if ( ! has_post_thumbnail() || ! wp_get_attachment_image_src( get_post_thumbnail_id() ) ) {
$classes[] = 'ast-no-thumb';
}
break;
}
}
if ( ! empty( $class ) ) {
if ( ! is_array( $class ) ) {
$class = preg_split( '#\s+#', $class );
}
$classes = array_merge( $classes, $class );
} else {
// Ensure that we always coerce class to being an array.
$class = array();
}
/**
* Filter primary div class names
*/
$classes = apply_filters( 'astra_blog_layout_class', $classes, $class );
$classes = array_map( 'sanitize_html_class', $classes );
return array_unique( $classes );
}
Expand full source code Collapse full source code View on Trac