You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many instances for the purposes of design/styles (especially when using BULP) when it becomes necessary to identify if the content editor is empty or if there is a Banner being used on the page. This function would add classes to the body if either is true.
* Add 'no-banner' and/or 'has-bu-banner' class to BODY to the page.
*
* @param string $classes The class or classes to be added to the body.
* @param number $_post The post ID.
* @param string $content The post content from the editor.
* @param bool $banner_visible Check if there is a BU Banner.
* @return string $classes The class or classes to be added to the body.
*/
function responsi_banner_content_class( $classes ) {
// Get post ID. Return if none.
$_post = get_post();
if ( empty( $_post ) ) {
return;
}
// Get Post Content from content editor.
$content = $_post->post_content;
// If no content, add class to Body.
if ( empty( $content ) ) {
$classes[] = 'no-content';
}
// Check that BU Banners is installed and if there is a banner on the current page.
$banner_visible = false;
if ( function_exists( 'bu_has_banner' ) ) {
$banner_visible = bu_has_banner();
}
// If there is a banner, add class to Body.
if ( $banner_visible ) {
$classes[] = 'has-bu-banner';
}
// Add $classes array to body.
return $classes;
}
add_filter( 'body_class', 'responsi_banner_content_class' );```
The text was updated successfully, but these errors were encountered:
There are many instances for the purposes of design/styles (especially when using BULP) when it becomes necessary to identify if the content editor is empty or if there is a Banner being used on the page. This function would add classes to the body if either is true.
The text was updated successfully, but these errors were encountered: