????
| Current Path : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/ |
| Current File : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/post-layout.php |
<?php
/**
* Returns the correct main layout class for the current post/page/archive/etc
*
* @package Wanderfuls WordPress Theme
* @subpackage Framework
*/
/**
* Returns defined post layout for curent post
*
* @since 2.0.0
*/
function tb_get_post_layout() {
// Get global object
$obj = tb_global_obj();
// Return post layout if defined
if ( ! empty( $obj->post_layout ) ) {
return $obj->post_layout;
}
// Backup check incase $tb_theme isn't defined for some reason
else {
return tb_post_layout();
}
}
/**
* Sets the correct layout for posts
*
* @since Wanderfuls 1.0.0
*/
function tb_post_layout( $post_id = '' ) {
// Get ID if not defined
$post_id = $post_id ? $post_id : tb_get_the_id();
// Define variables
$class = 'right-sidebar';
$meta = get_post_meta( $post_id, 'tb_post_layout', true );
// Check meta first to override and return (prevents filters from overriding meta)
if ( $meta ) {
return $meta;
}
// Singular Page
if ( is_page() ) {
// Blog template
if ( is_page_template( 'templates/blog.php' ) ) {
$class = tb_get_mod( 'blog_archives_layout', 'right-sidebar' );
}
// Landing Page
if ( is_page_template( 'templates/landing-page.php' ) ) {
$class = 'full-width';
}
// Attachment
elseif ( is_attachment() ) {
$class = 'full-width';
}
// All other pages
else {
$class = tb_get_mod( 'page_single_layout', 'right-sidebar' );
}
}
// Singular Post
elseif ( is_singular( 'post' ) ) {
$class = tb_get_mod( 'blog_single_layout', 'right-sidebar' );
}
// Attachment
elseif ( is_singular( 'attachment' ) ) {
$class = 'full-width';
}
// Home
elseif ( is_home() ) {
$class = tb_get_mod( 'blog_archives_layout', 'right-sidebar' );
}
// Search
elseif ( is_search() ) {
$class = tb_get_mod( 'search_layout', 'right-sidebar' );
}
// Standard Categories
elseif ( is_category() ) {
$class = tb_get_mod( 'blog_archives_layout', 'right-sidebar' );
$term = get_query_var( 'cat' );
$term_data = get_option( "category_$term" );
if ( $term_data ) {
if( ! empty( $term_data['tb_term_layout'] ) ) {
$class = $term_data['tb_term_layout'];
}
}
}
// Archives
elseif ( tb_is_blog_query() ) {
$class = tb_get_mod( 'blog_archives_layout', 'right-sidebar' );
}
// 404 page
elseif ( is_404() ) {
$class = 'full-width';
}
// All else
else {
$class = 'right-sidebar';
}
// Class should never be empty
if ( empty( $class ) ) {
$class = 'right-sidebar';
}
// Apply filters for child theme editing
$class = apply_filters( 'tb_post_layout_class', $class );
// Return correct classname
return $class;
}