<?php

$featureSidebarContent = ufandshands_sidebar_detector('featurebox_footer', false);
$opt_featurebox_widgets_visibility = of_get_option("opt_featurebox_widgets_visibility");
if ($opt_featurebox_widgets_visibility) {
    ?>
<div id="featurebox-footer">
	<div class="container">
		<?php 
    if ($featureSidebarContent) {
        ?>
							
					<?php 
        echo $featureSidebarContent;
        ?>
	        <?php 
    }
    ?>
	</div><!-- .container -->
</div><!-- #featurebox-footer -->
<?php 
}
<?php

$secondaryWidgetContent = ufandshands_sidebar_detector('home_left', false);
$secondaryWidgetContent .= ufandshands_sidebar_detector('home_middle', false);
$secondaryWidgetContent .= ufandshands_sidebar_detector('home_right', false);
if (!empty($secondaryWidgetContent)) {
    ufandshands_secondary_widget_area();
}
<?php

$sidebarContent = ufandshands_sidebar_detector('site_footer', false);
$opt_footer_widgets_visibility = of_get_option("opt_footer_widgets_visibility");
?>
<footer role="contentinfo">
	<?php 
if ($opt_footer_widgets_visibility === 'all_pages' || $opt_footer_widgets_visibility === 'homepage_only' && is_front_page() || $opt_footer_widgets_visibility === 'subpages_only' && !is_front_page()) {
    ?>
		<?php 
    if ($sidebarContent) {
        ?>
			<div class="container append-bottom">
			
				<div id="footer_top" class="footer_count_<?php 
        ufandshands_sidebar_detector('site_footer', false, true);
        ?>
">
							
					<?php 
        echo $sidebarContent;
        ?>
	        <div class="clear"></div>
				</div>
			</div>
		<?php 
    }
    ?>
	<?php 
}
?>
$currenttemplate = get_post_meta($post->ID, '_wp_page_template', true);
//members only template check
?>
				
		<?php 
if ($currenttemplate != "membersonly.php" || $currenttemplate == "membersonly.php" && ufandshands_members_only()) {
    //members only logic
    ?>
		
			<?php 
    get_sidebar();
    //call in the sidebar and navigation
    ?>
      
      <?php 
    $page_right_sidebar = ufandshands_sidebar_detector('page_right', false);
    $article_width = '';
    if (!empty($ufandshands_sidebar_nav) && $page_right_sidebar) {
        $article_width = '12';
    } elseif (!empty($ufandshands_sidebar_nav) && !$page_right_sidebar) {
        $article_width = '17';
    } elseif (empty($ufandshands_sidebar_nav) && $page_right_sidebar) {
        $article_width = '17 box';
    } else {
        $article_width = '23 box';
    }
    ?>
      
			<article id="main-content" class="span-<?php 
    echo $article_width;
    ?>
<?php

global $ufandshands_sidebar_nav;
global $ufandshands_sidebar_widgets;
$ufandshands_sidebar_nav = ufandshands_sidebar_navigation($post);
$ufandshands_sidebar_widgets = ufandshands_sidebar_detector('page_sidebar', false);
?>

<?php 
if (!empty($ufandshands_sidebar_nav) || !empty($ufandshands_sidebar_widgets)) {
    ?>

  <nav id="sidebar-nav" class="span-6" role="navigation">
	<div class="shadow"></div>
  <?php 
    if (!empty($ufandshands_sidebar_nav)) {
        ?>
    <ul class="site-nav" <?php 
        if ($ufandshands_sidebar_widgets) {
            echo "style='margin-bottom:25px;'";
        }
        ?>
>
      <?php 
        echo $ufandshands_sidebar_nav;
        ?>
    </ul>
  <?php 
    }
    ?>