Viewing File: /home/maglabs/2vsa/wp-content/themes/cargohub/inc/frontend/layout.php
<?php
/**
* Hooks for frontend display
*
* @package Cargohub
*/
/**
* Adds custom classes to the array of body classes.
*
* @since 1.0
* @param array $classes Classes for the body element.
* @return array
*/
function cargohub_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Add a class of layout style
$classes[] = cargohub_get_option( 'layout_style' );
// Add a class of layout
$classes[] = cargohub_get_layout();
// Adds a class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
if ( in_array( cargohub_get_option( 'header_layout' ), array( 'v1' ) ) ) {
$classes[] = 'header-transparent';
}
if ( is_post_type_archive( 'project' ) || is_tax( 'project_category' ) ) {
if ( 'ajax' == cargohub_get_option( 'project_nav_type' ) ) {
$classes[] = 'project-nav-ajax';
}
if ( false != cargohub_get_option( 'project_view' ) ) {
$classes[] = 'project-grid-fullwidth';
}
}
if ( cargohub_get_option( 'header_sticky' ) ) {
$classes[] = 'header-sticky';
}
if ( cargohub_get_option( 'topbar_mobile' ) ) {
$classes[] = 'hide-topbar-mobile';
}
if ( ! cargohub_get_option( '404_bg' ) ) {
$classes[] = 'error404-no-bg';
}
$classes[] = 'blog-' . cargohub_get_option( 'blog_layout' );
$classes[] = 'header-' . cargohub_get_option( 'header_layout' );
return $classes;
}
add_filter( 'body_class', 'cargohub_body_classes' );
if ( ! function_exists( 'cargohub_get_layout' ) ) :
/**
* Get layout base on current page
*
* @return string
*/
function cargohub_get_layout() {
$layout = cargohub_get_option( 'layout_default' );
if ( is_singular() && get_post_meta( get_the_ID(), 'custom_layout', true ) ) {
$layout = get_post_meta( get_the_ID(), 'layout', true );
} elseif ( is_page() ) {
$layout = cargohub_get_option( 'layout_page' );
} elseif ( is_404() ) {
$layout = 'no-sidebar';
} elseif ( is_post_type_archive( 'project' ) || is_tax( 'project_category' ) || is_singular( 'project' ) ) {
$layout = cargohub_get_option( 'layout_project' );
} elseif ( is_post_type_archive( 'service' ) || is_tax( 'service_category' ) ) {
$layout = cargohub_get_option( 'layout_service' );
} elseif ( is_singular( 'service' ) ) {
$layout = 'no-sidebar';
}
return $layout;
}
endif;
if ( ! function_exists( 'cargohub_get_content_columns' ) ) :
/**
* Get CSS classes for content columns
*
* @param string $layout
*
* @return array
*/
function cargohub_get_content_columns( $layout = null ) {
$layout = $layout ? $layout : cargohub_get_layout();
if ( 'no-sidebar' == $layout ) {
return array( 'col-md-12', 'col-sm-12', 'col-xs-12' );
}
if ( cargohub_is_blog() ) {
return array( 'col-md-8', 'col-sm-12', 'col-xs-12' );
} else {
return array( 'col-md-9', 'col-sm-12', 'col-xs-12' );
}
}
endif;
if ( ! function_exists( 'cargohub_content_columns' ) ) :
/**
* Display CSS classes for content columns
*
* @param string $layout
*/
function cargohub_content_columns( $layout = null ) {
echo implode( ' ', cargohub_get_content_columns( $layout ) );
}
endif;
Back to Directory
File Manager