????

Your IP : 216.73.216.174


Current Path : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/
Upload File :
Current File : /home2/morganrand/www/wp-content/themes/wanderfuls-2/framework/classes/global-object.php

<?php
/**
 * Creates a global object for the theme's main function, layout, design, etc.
 *
 * @package Wanderfuls WordPress Theme
 * @subpackage Framework
 * @version 3.0.0
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Main Class
 *
 * @since 3.0.0
 */
class TB_Global_Theme_Object {

	/**
	 * vc_css_ids variable
	 *
	 * Save array of post ids that need fetching to load VC css classes
	 *
	 * @since 3.0.0
	 */
	public $vc_css_ids = array();

	/**
	 *  Constructor
	 *
	 * @since 3.0.0
	 */
	public function __construct() {
		$methods = get_class_methods( $this );
		foreach ( $methods as $method ) {
			if ( '__construct' != $method ) {
				$this->$method = $this->$method();
			}
		}
	}
	
	/**
	 * Store is admin check
	 *
	 * @since 3.0.0
	 */
	private function is_admin() {
		return is_admin();
	}

	/**
	 * Store current post ID
	 *
	 * @since 3.0.0
	 */
	private function post_id() {

		// If singular get_the_ID
		if ( is_singular() ) {
			return get_the_ID();
		}

		// Get ID of WooCommerce product archive
		elseif ( TB_WOOCOMMERCE_ACTIVE && is_shop()  ) {
			$shop_id = wc_get_page_id( 'shop' );
			if ( isset( $shop_id ) ) {
				return wc_get_page_id( 'shop' );
			}
		}

		// Posts page
		elseif ( is_home() && $page_for_posts = get_option( 'page_for_posts' ) ) {
			return $page_for_posts;
		}

		// Return nothing
		else {
			return NULL;
		}

	}

	/**
	 * Returns correct theme skin
	 *
	 * @since 3.0.0
	 */
	private function skin() {
		if ( function_exists( 'tb_active_skin' ) ) {
			return tb_active_skin();
		}
	}

	/**
	 * Checks if the current post/page is using the Visual Composer
	 *
	 * @since 3.0.0
	 */
	private function has_composer() {
		if ( TB_VC_ACTIVE && $this->post_id ) {
			$post_content = get_post_field( 'post_content', $this->post_id );
			if ( $post_content && strpos( $post_content, 'vc_row' ) ) {
				return true;
			} else {
				return false;
			}
		}
	}

	/**
	 * Checks if we are in the front-end composer mode
	 *
	 * @since 3.0.0
	 */
	private function vc_is_inline() {
		if ( function_exists( 'vc_is_inline' ) ) {
			return vc_is_inline();
		}
	}

	/**
	 * Checks if retina is enabled
	 *
	 * @since 3.0.0
	 */
	private function retina() {
		if ( tb_get_mod( 'image_resizing', true ) ) {
			return tb_get_mod( 'retina' );
		}
	}

	/**
	 * Main Layout Style
	 *
	 * @since 3.0.0
	 */
	private function main_layout() {

		// Check URL
		if ( ! empty( $_GET['site_layout'] ) ) {
			return $_GET['site_layout'];
		}

		// Get layout
		$layout = tb_get_mod( 'main_layout_style' );
		$layout = $layout ? $layout : 'full-width';
		$meta   = get_post_meta( $this->post_id, 'tb_main_layout', true );
		$layout = $meta ? $meta : $layout;

		// Apply filters and return
		return apply_filters( 'tb_main_layout', $layout );

	}

	/**
	 * Checks if responsive is enabled
	 *
	 * @since 3.0.0
	 */
	private function responsive() {
		return tb_get_mod( 'responsive', true );
	}

	/**
	 * Returns correct post layout
	 *
	 * @since 3.0.0
	 */
	private function post_layout() {

		// Check URL
		if ( ! empty( $_GET['post_layout'] ) ) {
			return $_GET['post_layout'];
		}

		// Define variables
		$class  = 'right-sidebar';
		$meta   = get_post_meta( $this->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 = get_theme_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 and return
		return apply_filters( 'tb_post_layout_class', $class );

	} // End post_layout

	/**
	 * Checks if header is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_header() {

		// Return true by default
		$return = true;

		// Check if disabled via meta option
		if ( 'on' == get_post_meta( $this->post_id, 'tb_disable_header', true ) ) {
			$return = false;
		}

		// Apply filters and return
		return apply_filters( 'tb_display_header', $return );

	}

	/**
	 * Checks if header overlay is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_overlay_header() {

		// Return false if header is disabled
		if ( ! $this->has_header ) {
			return false;
		}

		// Return false by default
		$return = false;

		// Return true if enabled via the post meta
		if ( $this->post_id && 'on' == get_post_meta( $this->post_id, 'tb_overlay_header', true ) ) {
			$return = true;
		}

		// Apply filters and return
		return apply_filters( 'tb_has_overlay_header', $return );

	}

	/**
	 * Header overlay style
	 *
	 * @since 3.0.0
	 */
	private function header_overlay_style() {
		return get_post_meta( $this->post_id, 'tb_overlay_header_style', true );
	}
	
	/**
	 * Returns header style
	 *
	 * @since 3.0.0
	 */
	private function header_style() {

		// Check URL
		if ( ! empty( $_GET['header_style'] ) ) {
			return $_GET['header_style'];
		}

		// Get header style from customizer setting
		$style = tb_get_mod( 'header_style', 'one' );

		// Check for custom header style defined in meta options
		if ( $meta = get_post_meta( $this->post_id, 'tb_header_style', true ) ) {
			$style = $meta;
		}

		// Return header style one if Header Overlay enabled
		if ( isset( $this->has_overlay_header ) && $this->has_overlay_header ) {
			$style = 'one';
		}

		// Sanitize style to make sure it isn't empty
		$style = $style ? $style : 'one';

		// Apply filters and return
		return apply_filters( 'tb_header_style', $style );

	}

	/**
	 * Returns header logo
	 *
	 * @since 3.0.0
	 */
	private function header_logo() {

		// Get logo img from admin panel
		$logo = tb_get_mod( 'custom_logo' );

		// WPML translation
		$logo = tb_translate_theme_mod( 'custom_logo', $logo );

		// Apply filter for child theming
		$logo = apply_filters( 'tb_header_logo_img_url', $logo );

		// Sanitize URL
		$logo = esc_url( $logo );

		// Return logo
		return $logo;

	}

	/**
	 * Returns retina header logo
	 *
	 * @since 3.0.0
	 */
	private function retina_header_logo() {
		return tb_translate_theme_mod( 'retina_logo', tb_get_mod( 'retina_logo' ) );
	}

	/**
	 * Returns header logo
	 *
	 * @since 3.0.0
	 */
	private function fixed_header_logo() {
		return apply_filters( 'tb_fixed_header_logo', tb_get_mod( 'fixed_header_logo' ) );
	}

	/**
	 * Check if has fixed header
	 *
	 * @since 3.0.0
	 */
	private function has_fixed_header() {
		if ( $this->vc_is_inline ) {
			$return = false;
		} elseif ( tb_get_mod( 'fixed_header', true ) ) {
			$return = true;
		} else {
			$return = false;
		}
		if ( 'six' == $this->header_style ) {
			$return = false; // disabled for header six
		}
		return apply_filters( 'tb_has_fixed_header', $return );
	}

	/**
	 * Check if shrink fixed header is enabled
	 *
	 * @since 3.0.0
	 */
	private function shrink_fixed_header() {
		return tb_get_mod( 'shink_fixed_header', true );
	}

	/**
	 * Header Aside Content check so we can load custom CSS from the customizer
	 *
	 * @since 3.0.0
	 */
	private function header_aside_content() {

		// Not needed here
		if ( ! tb_header_supports_aside( $this->header_style ) ) {
			return;
		}

		// Get header aside content
		$content = tb_get_mod( 'header_aside' );

		// WPML translations
		$content = tb_translate_theme_mod( 'header_aside', $content );

		// Check if content is a page ID and get page content
		if ( is_numeric( $content ) ) {
			$post_id = $content;
			$post = get_post( $post_id );
			if ( $post && ! is_wp_error( $post ) ) {
				$content = $post->post_content;
				$this->vc_css_ids[$post_id] = $post_id;
			}
		}

		// Apply filters
		$content = apply_filters( 'tb_header_aside_content', $content );

		// Return content
		return $content;

	}

	/**
	 * Returns lightbox skin
	 *
	 * @since 3.0.0
	 */
	private function lightbox_skin() {
		if ( function_exists( 'tb_ilightbox_skin' ) ) {
			return tb_ilightbox_skin();
		}
	}

	/**
	 * Returns mobile menu style
	 *
	 * @since 3.0.0
	 */
	private function mobile_menu_style() {

		// Get style defined in Customizer
		$style = tb_get_mod( 'mobile_menu_style', 'sidr' );

		// Sanitize
		$style = $style ? $style : 'sidr';

		// Disable if responsive is disabled
		$style = $this->responsive ? $style : 'disabled';

		// Apply filters and return
		return apply_filters( 'tb_mobile_menu_style', $style );

	}

	/**
	 * Returns mobile menu toggle style
	 *
	 * @since 3.0.0
	 */
	private function mobile_menu_toggle_style() {

		// Not needed if mobile menu style is disabled
		if ( 'disabled' == $this->mobile_menu_style ) {
			return null;
		}

		// Get style
		$style = tb_get_mod( 'mobile_menu_toggle_style' );

		// Sanitize
		$style = $style ? $style : 'icon_buttons';

		// Apply filters and return style
		return apply_filters( 'tb_mobile_menu_toggle_style', $style );

	}

	/**
	 * Check if the mobile menu is enabled or not
	 *
	 * @since 2.1.04
	 */
	function has_mobile_menu() {
		if ( 'disabled' != $this->mobile_menu_style ) {
			return true;
		}
	}

	/**
	 * Returns sidebar menu source
	 *
	 * @since 3.0.0
	 */
	private function sidr_menu_source() {

		// Only needed for sidr menu style
		if ( 'sidr' != $this->mobile_menu_style ) {
			return;
		}

		// Define array of items
		$items = array();

		// Add close button
		$items['sidrclose'] = '#sidr-close';

		// Add mobile menu alternative if defined
		if ( has_nav_menu( 'mobile_menu_alt' ) ) {
			$items['nav'] = '#mobile-menu-alternative';
		}

		// If mobile menu alternative is not defined add main navigation
		else {
			$items['nav'] = '#site-navigation';
		}

		// Add search form
		$items['search'] = '#mobile-menu-search';

		// Apply filters for child theming
		$items = apply_filters( 'tb_mobile_menu_source', $items );

		// Turn items into comma seperated list
		$items = implode( ', ', $items );

		// Return items
		return $items;

	}

	/**
	 * Check if search is enabled in the menu
	 *
	 * @since 3.0.0
	 */
	private function has_menu_search() {

		// Return false by default
		$return = false;

		// Get header style
		$header_style = $this->header_style;

		// Always return true for the header style 2, we can hide via CSS
		if ( 'two' == $header_style ) {
			$return = true;
		}

		// Return true if enabled via the Customizer
		elseif ( tb_get_mod( 'main_search', true ) ) {
			$return = true;
		}

		// Apply filters and return
		return apply_filters( 'tb_has_menu_search', $return );

	}

	/**
	 * Returns menu search style
	 *
	 * @since 3.0.0
	 */
	private function menu_search_style() {

		// Return if search disabled form the menu
		if ( ! $this->has_menu_search ) {
			return;
		}

		// Get search style from Customizer
		$style = tb_get_mod( 'menu_search_style', 'drop_down' );

		// Overlay header should use pop-up
		if ( 'disabled' != $style && ( $this->has_overlay_header || 'six' == $this->header_style ) ) {
			$style = 'overlay';
		}

		// Apply filters for advanced edits
		$style = apply_filters( 'tb_menu_search_style', $style );

		// Sanitize output so it's not empty
		$style = $style ? $style : 'drop_down';

		// Return style
		return $style;

	}

	/**
	 * Returns header search style
	 *
	 * @since 3.0.0
	 */
	private function menu_cart_style() {

		// Return if disabled or not used here
		if ( ! TB_WOOCOMMERCE_ACTIVE || ! tb_get_mod( 'woo_menu_icon', true ) ) {
			return;
		}

		// Get search style from Customizer
		$style = tb_get_mod( 'woo_menu_icon_style', 'drop_down' );

		// Overlay header should use pop-up
		if ( $this->has_overlay_header || 'six' == $this->header_style ) {
			$style = 'overlay';
		}

		// Return click style for these pages
		if ( is_cart() || is_checkout() ) {
			$style = 'custom-link';
		}

		// Apply filters for advanced edits
		$style = apply_filters( 'tb_menu_cart_style', $style );

		// Sanitize output so it's not empty
		if ( 'drop-down' == $style || ! $style ) {
			$style = 'drop_down';
		}

		// Return style
		return $style;

	}

	/**
	 * Returns correct post slider shortcode
	 *
	 * @since 1.6.0
	 */
	function post_slider_shortcode() {

		// Check for slider defined in custom fields
		if ( $slider = get_post_meta( $this->post_id, 'tb_post_slider_shortcode', true ) ) {
			$slider = $slider;
		} elseif( get_post_meta( $this->post_id, 'tb_page_slider_shortcode', true ) ) {
			$slider = get_post_meta( $this->post_id, 'tb_page_slider_shortcode', true );
		}

		// Apply filters and return
		return apply_filters( 'tb_post_slider_shortcode', $slider );

	}

	/**
	 * Returns post slider position
	 *
	 * @since 3.0.0
	 */
	private function post_slider_position() {

		// Default position is below the title
		$position = 'below_title';

		// Check meta field for position
		if ( $meta = get_post_meta( $this->post_id, 'tb_post_slider_shortcode_position', true ) ) {
			$position = $meta;
		}

		// Apply filters and return
		return apply_filters( 'tb_post_slider_position', $position );

	}

	/**
	 * Checks if the page has a slider
	 *
	 * @since 3.0.0
	 */
	private function has_post_slider() {

		// Check for shortcode
		if ( $this->post_slider_shortcode ) {
			$return = true;
		} else {
			$return = false;
		}

		// Apply filters and return
		return apply_filters( 'tb_has_post_slider', $return );

	}

	/**
	 * Checks if the topbar is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_top_bar() {

		// Return true by default
		$return = true;

		// Return false if disabled via Customizer
		if ( ! tb_get_mod( 'top_bar', true ) ) {
			$return = false;
		}

		// Return false if disabled via post meta
		if ( 'on' == get_post_meta( $this->post_id, 'tb_disable_top_bar', true ) ) {
			$return = false;
		}

		// Return false if disabled via post meta
		if ( 'enable' == get_post_meta( $this->post_id, 'tb_disable_top_bar', true ) ) {
			$return = true;
		}

		// Apply filers and return
		return apply_filters( 'tb_is_top_bar_enabled', $return );

	}

	/**
	 * Returns topbar content
	 *
	 * @since 3.0.0
	 */
	private function top_bar_content() {

		if ( ! $this->has_top_bar() ) {
			return null;
		}

		// Get topbar content from Customizer
		$content = tb_get_mod( 'top_bar_content', '[font_awesome icon="phone" margin_right="5px" color="#000"] 1-800-987-654 [font_awesome icon="envelope" margin_right="5px" margin_left="20px" color="#000"] admin@total.com [font_awesome icon="user" margin_right="5px" margin_left="20px" color="#000"] [wp_login_url text="User Login" logout_text="Logout"]' );

		// Translate the content
		$content = tb_translate_theme_mod( 'top_bar_content', $content );

		// Check if content is a page ID and get page content
		if ( is_numeric( $content ) ) {
			$post_id = $content;
			$post = get_post( $post_id );
			if ( $post && ! is_wp_error( $post ) ) {
				$content = $post->post_content;
				$this->vc_css_ids[$post_id] = $post_id;
			}
		}

		// Apply filters
		$content = apply_filters( 'tb_top_bar_content', $content );

		// Return content
		return $content;

	}

	/**
	 * Returns topbar content
	 *
	 * @since 3.0.0
	 */
	private function top_bar_social_alt() {

		// Get mod
		$content = tb_get_mod( 'top_bar_social_alt' );

		// Translate alternative content
		$content = tb_translate_theme_mod( 'top_bar_social_alt', $content );

		// Check if social_alt is a page ID and get page content
		if ( is_numeric( $content ) ) {
			$post_id = $content;
			$post = get_post( $post_id );
			if ( $post && ! is_wp_error( $post ) ) {
				$content = $post->post_content;
				$this->vc_css_ids[$post_id] = $post_id;
			}
		}

		// Return content
		return $content;

	}	

	/**
	 * Returns correct toggle_bar_content_id
	 *
	 * @since 3.0.0
	 */
	private function toggle_bar_content_id() {
		return apply_filters( 'tb_toggle_bar_content_id', tb_get_mod( 'toggle_bar_page' ) );
	}

	/**
	 * Checks if the topbar is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_togglebar() {

		// Return if toggle bar page is not defined
		if ( ! $this->toggle_bar_content_id() ) {
			return false;
		}

		// Return true by default
		$return = true;

		// Disabled for front-end composer
		if ( $this->vc_is_inline ) {
			$return = false;
		}

		// Return false if disabled via the Customizer
		if ( ! tb_get_mod( 'toggle_bar', true ) ) {
			$return = false;
		}

		// Return true if enabled via the page settings
		if ( 'enable' == get_post_meta( $this->post_id, 'tb_disable_toggle_bar', true ) ) {
			$return = true;
		}

		// Return false if disabled via the page settings
		if ( 'on' == get_post_meta( $this->post_id, 'tb_disable_toggle_bar', true ) ) {
			$return = false;
		}

		// Apply filters and return
		return apply_filters( 'tb_toggle_bar_active', $return );

	} // End has_togglebar

	/**
	 * Returns page header style
	 *
	 * @since 3.0.0
	 */
	private function page_header_style() {

		// Get default page header style defined in Customizer
		$style = tb_get_mod( 'page_header_style' );

		// Get for header style defined in page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_post_title_style', true ) ) {
			$style = $meta;
		}

		// Sanitize data
		$style = ( 'default' == $style ) ? '' : $style;
		
		// Apply filters and return
		return apply_filters( 'tb_page_header_style', $style );

	}

	/**
	 * Checks if the page header is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_page_header() {
		
		// Define vars
		$return = true;
		$style  = $this->page_header_style;

		// Return if page header is disabled via custom field
		if ( $this->post_id ) {

			// Return if page header is disabled and there isn't a page header background defined
			if ( 'on' == get_post_meta( $this->post_id, 'tb_disable_title', true )
				&& 'background-image' != $style ) {
				$return	= false;
			}

		}

		// Check if page header style is set to hidden
		if ( 'hidden' == $style ) {
			$return = false;
		}

		// Apply filters and return
		return apply_filters( 'tb_display_page_header', $return );

	}

	/**
	 * Checks if the page header has a title
	 *
	 * @since 3.0.0
	 */
	private function has_page_header_title() {

		// Disable title if the page header is disabled via meta (ignore filter)
		if ( 'on' == get_post_meta( $this->post_id, 'tb_disable_title', true ) ) {
			return false;
		}

		// Apply filters and return
		return apply_filters( 'tb_has_page_header_title', true );

	}

	/**
	 * Returns page subheading
	 *
	 * @since 3.0.0
	 */
	private function get_page_subheading() {

		// Subheading is NULL by default
		$subheading = NULL;

		// Posts & Pages
		if ( $meta = get_post_meta( $this->post_id, 'tb_post_subheading', true ) ) {
			$subheading = $meta;
		}

		// Search
		elseif ( is_search() ) {
			$subheading = __( 'You searched for:', 'tb' ) .' &quot;'. esc_html( get_search_query( false ) ) .'&quot;';
		}

		// Categories
		elseif ( is_category() ) {
			if ( 'under_title' == tb_get_mod( 'category_description_position', 'under_title' ) ) {
				$subheading = term_description();
			}
		}

		// Author
		elseif ( is_author() ) {
			$subheading = __( 'This author has written', 'tb' ) .' '. get_the_author_posts() .' '. __( 'articles', 'tb' );
		}

		// All other Taxonomies
		elseif ( is_tax() && ! tb_has_term_description_above_loop() ) {
			$subheading = term_description();
		}

		// Apply filters and return
		return apply_filters( 'tb_post_subheading', $subheading );

	}

	/**
	 * Checks if the page header has subheading
	 *
	 * @since 3.0.0
	 */
	private function has_page_header_subheading() {
		if ( $this->get_page_subheading ) {
			return true;
		}
	}

	/**
	 * Checks if breadcrumbs are enabled
	 *
	 * @since 3.0.0
	 */
	private function has_breadcrumbs() {

		// Return true by default
		$return = true;

		// Check if disabled by theme options
		if ( ! tb_get_mod( 'breadcrumbs', true ) ) {
			$return = false;
		}

		// Check page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_disable_breadcrumbs', true ) ) {
			if ( 'on' == $meta ) {
				$return = false;
			} elseif ( 'enable' == $meta ) {
				$return = true;
			}
		}

		// Apply filters and return
		return apply_filters( 'tb_has_breadcrumbs', $return );

	} // End has_breadcrumbs

	/**
	 * Checks if the footer is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_footer() {

		// Return true by default
		$return = true;

		// Disabled on landing page
		if ( is_page_template( 'templates/landing-page.php' ) ) {
			$return = false;
		}

		// Check page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_disable_footer', true ) ) {
			if ( 'on' == $meta ) {
				$return = false;
			} elseif ( 'enable' == $meta ) {
				$return = true;
			}
		}

		// Apply filters and return
		return apply_filters( 'tb_display_footer', $return );

	}

	/**
	 * Checks if footer widgets are enabled
	 *
	 * @since 3.0.0
	 */
	private function has_footer_widgets() {

		// Check if enabled via the customizer
		$return = tb_get_mod( 'footer_widgets', true );

		// Check page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_disable_footer_widgets', true ) ) {
			if ( 'on' == $meta ) {
				$return = false;
			} elseif ( 'enable' == $meta ) {
				$return = true;
			}
		}

		// Apply filters and return
		return apply_filters( 'tb_display_footer_widgets', $return );

	}

	/**
	 * Checks if footer widgets are enabled
	 *
	 * @since 3.0.0
	 */
	private function has_footer_reveal() {

		// Disable on boxed style - ALWAYS
		if ( 'boxed' == $this->main_layout || 'six' == $this->header_style ) {
			return false;
		}

		// Disabled by default
		$return = false;

		// Theme option check
		if ( tb_get_mod( 'footer_reveal', false ) ) {
			$return = true;
		}

		// Check page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_footer_reveal', true ) ) {
			if ( 'on' == $meta ) {
				$return = true;
			} elseif ( 'off' == $meta ) {
				$return = false;
			}
		}

		// Disable on 404
		if ( is_404() ) {
			$return = false;
		}

		// Apply filters and return
		return apply_filters( 'tb_has_footer_reveal', $return );

	} // End has_footer_reveal

	/**
	 * Checks if footer callout is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_footer_callout() {
		
		// Return true by default
		$return = true;

		// Return false if disabled via Customizer
		if ( ! tb_get_mod( 'callout', true ) ) {
			$return = false;
		}

		// Return true if custom callout text exists
		if ( get_post_meta( $this->post_id, 'tb_callout_text', true ) ) {
			$return = true;
		}

		// Check page settings
		if ( $meta = get_post_meta( $this->post_id, 'tb_disable_footer_callout', true ) ) {
			if ( 'on' == $meta ) {
				$return = false;
			} elseif ( 'enable' == $meta ) {
				$return = true;
			}
		}

		// Apply filter and return
		return apply_filters( 'tb_callout_enabled', $return );

	}

	/**
	 * Footer callout content
	 *
	 * @since 3.0.0
	 */
	private function footer_callout_content() {

		// Footer callout is disabled return nothing
		if ( ! $this->has_footer_callout() ) {
			return null;
		}
		
		// Get post ID
		$post_id = $this->post_id;

		// Get Content
		if ( $post_id && $meta = get_post_meta( $post_id, 'tb_callout_text', true ) ) {

			// Return content defined in meta
			$content = $meta;

		} else {

			// Get content from theme mod
			$content = tb_get_mod( 'callout_text', 'I am the footer call-to-action block, here you can add some relevant/important information about your company or product. I can be disabled in the theme options.' );

			// Check if content is a page ID and get page content
			if ( is_numeric( $content ) ) {
				$post_id = $content;
				$post = get_post( $post_id );
				if ( $post && ! is_wp_error( $post ) ) {
					$content = $post->post_content;
					$this->vc_css_ids[$post_id] = $post_id;
				}
			}

		}

		// Return content
		return apply_filters( 'tb_get_footer_callout_content', $content );

	}

	/**
	 * Checks if social share is enabled
	 *
	 * @since 3.0.0
	 */
	private function has_social_share() {

		// Return false by default
		$return = false;

		// Check page settings to overrides theme mods and filters
		if ( $meta = get_post_meta( $this->post_id, 'tb_disable_social', true ) ) {

			// Check if disabled by meta options
			if ( 'on' == $meta ) {
				return false;
			}

			// Return true if enabled via meta option
			if ( 'enable' == $meta ) {
				return true;
			}
			
		}

		// Page check
		if ( is_page() ) {
			if ( tb_get_mod( 'social_share_pages' ) ) {
				$return = true;
			}
		}

		// Check if enabled on single blog posts
		elseif ( is_singular( 'post' ) ) {
			return true; // It uses the builder so we should return true
		}

		// Apply filters and return
		return apply_filters( 'tb_has_social_share', $return );

	}

	/**
	 * No longer used but keeping to prevent errors
	 *
	 * @since 3.0.0
	 */
	private function is_mobile() {
		return false;
	}

}

/**
 * Helper function: Returns global object or property from global object
 * IMPORTANT: Must be loaded on init to prevent issues with the Visual Composer
 *
 * @since 2.1.0
 */
function tb_global_obj( $key = null ) {
	global $tb_theme;
	if ( $key ) {
		if ( isset( $tb_theme->$key ) ) {
			return $tb_theme->$key;
		}
		// Object doesn't exist, lets try and re-create it for the front-end VC builder only
		else {
			if ( function_exists( 'vc_is_inline' ) && vc_is_inline() ) {
				$obj = new TB_Global_Theme_Object;
				if ( isset( $obj->$key ) ) {
					return $obj->$key;
				}
			}
		}
	} else {
		return $tb_theme;
	}
}