*
* @return string[] Classes for body with the layout class
*/
static public function layoutBodyClasses($classes) {
$layout = get_theme_mod('ltk-foundation-setting-layout', 'container');
$classes[] = "layout-$layout";
if (self::isActiveMenuLocation('fixed-top')) {
$classes[] = 'with-menu-fixed-top';
}
return $classes;
}
/**
* Prints the menu, if it is active and has elements
*
* @param string $menu Slug of the menu to show
*/
static public function getMenu($menu) {
if (self::isActiveMenuLocation($menu)) {
get_template_part("templates/menus/$menu");
}
}
/**
* Checks if given menu is active
*
* @param string $name
* @return boolean
*/
static protected function isActiveMenu($name) {
$menu = wp_get_nav_menu_object($name);
if (! $menu) {
$menus = wp_get_nav_menus(['orderby' => 'name']);
foreach ($menus as $menu_maybe) {
if ($menu_items = wp_get_nav_menu_items($menu_maybe->term_id, ['update_post_term_cache' => false])) {
$menu = $menu_maybe;
break;
}
}
}
if ($menu && ! is_wp_error($menu) && ! isset($menu_items)) {
$menu_items = wp_get_nav_menu_items($menu->term_id, ['update_post_term_cache' => false]);
}
return (bool) ! empty($menu_items);
}
/**
* Checks if given menu location has a menu
*
* @param string $location
* @return boolean
*/
static public function isActiveMenuLocation($location) {
$menu = false;
$menu_items = [];
if (($locations = get_nav_menu_locations()) && isset($locations[$location])) {
$menu = wp_get_nav_menu_object($locations[$location]);
}
if ($menu && ! is_wp_error($menu)) {
$menu_items = wp_get_nav_menu_items($menu->term_id, ['update_post_term_cache' => false]);
}
return (bool) count($menu_items);
}
static public function isCustomLogoEnabled() {
return (bool) get_theme_mod('custom_logo', false);
}
static public function getCustomLogo($alt = '', $class = '', $id = false) {
$image_id = get_theme_mod('custom_logo', false);
if ($image_id) {
$alt = esc_attr($alt);
$class = esc_attr($class);
$image = wp_get_attachment_image_src($image_id , 'full');
if ($id) {
$id = esc_attr($id);
echo "";
} else {
echo "";
}
}
}
/**
* Guess which classes to add to a column based on the active sidebars
*
* @param string $column Slug of the column to guess classes for
*/
static public function getColumnClass($column) {
$center = 'col-center';
$left = 'col-left';
$right = 'col-right';
if (is_active_sidebar('column-left')) {
if (is_active_sidebar('column-right')) {
$center .= ' col-xs-12 col-md-6 col-md-push-3';
$left .= ' col-xs-6 col-md-3 col-md-pull-6';
$right .= ' col-xs-6 col-md-3';
} else {
$center .= ' col-xs-12 col-md-9 col-md-push-3';
$left .= ' col-xs-12 col-md-3 col-md-pull-9';
}
} else {
if (is_active_sidebar('column-right')) {
$center .= ' col-xs-12 col-md-9';
$right .= ' col-xs-12 col-md-3';
} else {
$center .= ' col-xs-12';
}
}
switch($column) {
case 'center':
echo $center;
break;
case 'left':
echo $left;
break;
case 'right':
echo $right;
break;
}
}
/**
* Guess which classes to add to layout zones
*
* Layout zones are header, footer, menu and body
*
* @param string $zone Layout zone to guess classes fot
*/
static public function getLayoutClass($zone) {
$setting = get_theme_mod('ltk-foundation-setting-layout', 'container');
$classes = [$zone];
$_classMap = [
'container' => [
'wrapper' => 'container'
],
'full-width' => [
'header-inner' => 'container',
'menu-inner' => 'container',
'body-inner' => 'container',
'footer-inner' => 'container'
]
];
if (isset($_classMap[$setting][$zone])) {
$classes[] = $_classMap[$setting][$zone];
}
echo implode(' ', $classes);
}
}