Add body classes.

This commit is contained in:
Hoang Huu 2019-11-08 09:16:13 +07:00
parent b244e8de6b
commit 6ffab80093
2 changed files with 32 additions and 0 deletions

View File

@ -10,6 +10,33 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly
} }
/**
* Add body classes for Opalestate pages.
*
* @param array $classes Body Classes.
* @return array
*/
function opalestate_body_class( $classes ) {
$classes = (array) $classes;
$classes[] = 'opalestate-active';
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
if ( $current_user ) {
$roles = $current_user->roles;
if ( $roles && is_array( $roles ) ) {
foreach ( $roles as $role ) {
$classes[] = 'opalestate-role-' . esc_attr( $role );
}
}
}
}
return array_unique( $classes );
}
function opalestate_archive_search_block() { function opalestate_archive_search_block() {
echo opalestate_load_template_path( 'parts/archive-search-block' ); echo opalestate_load_template_path( 'parts/archive-search-block' );
} }

View File

@ -1,4 +1,9 @@
<?php <?php
/**
* Body classes.
*/
add_filter( 'body_class', 'opalestate_body_class' );
/** /**
* Archive Page * Archive Page
*/ */