<?php



/* ! remove thesis features */
remove_action('thesis_hook_archive_info', 'thesis_default_archive_info');
remove_action('thesis_hook_after_post', 'thesis_comments_link');


/* ! navigation */
remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_after_content_box', 'thesis_nav_menu', '1');


/* ! multimedia box */
function custom_multimedia_box() {
		if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Multimedia Box') ) : endif;
}
add_action('thesis_hook_multimedia_box', 'custom_multimedia_box');


/* ! geographical navigation */
function custom_navigation() { 
	global $post;

	$custom_search_title = get_post_meta($post->ID, 'search_title', true);
	$custom_search_url = get_post_meta($post->ID, 'search_url', true);
	?>

	<ul id="geo_navigation">
		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Geographical Navigation') ) : endif; ?>
		<?php if ($custom_search_title && $custom_search_url != '') { ?>
			<li class="geo_search"><a rel="nofollow" href="<?php echo $custom_search_url; ?>"><?php echo $custom_search_title; ?></a></li>
		<?php } else { 
			/* change the URL within href="" in the line bellow to the URL you'd like your default Search All Homes link to point to */ ?>
			<li class="geo_search"><a href="http://www.terrymcdonaldrealestate.com/charlotte-homes/">Search All Charlotte Area Homes</a></li>
		<?php } ?>
	</ul>
<?php }
add_action('thesis_hook_after_multimedia_box', 'custom_navigation');


/* ! footer */
remove_action('thesis_hook_footer', 'thesis_attribution');

function custom_footer() { ?>
	<div class="footer_widgets_top">
		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Top') ) : endif; ?>
	</div>
	<div class="footer_widgets_bottom">
		<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Bottom') ) : endif; ?>
	</div>
 
<div id="header_rotator">
<?php
	global $post;
	$custom_gallery = get_post_meta($post->ID, 'header_gallery', true);

	if ($custom_gallery != '') { if (function_exists("nggSlideshowWidget")) { nggSlideshowWidget($custom_gallery,983,150); } }
	/* change the first number in the line bellow to the ID of the gallery you'd like to display in the header by default */
	else { if (function_exists("nggSlideshowWidget")) { nggSlideshowWidget(1,983,150); } }
?>
</div>

<?php }
add_action('thesis_hook_footer', 'custom_footer');


/* ! filters */
function custom_body_classes($content) {
	# Add "custom_front" class for front page.
	if (is_front_page()) {
		$content[] = 'custom_front';
		return $content;
	}

	# Add "custom_home" class for home page.
	elseif (is_home()) {
		$content[] = 'custom_home';
		return $content;
	}

	# Add "custom_page" class for page.
	elseif (is_page()) {
		$content[] = 'custom_page';
		return $content;
	}

	# Add "custom_post" class for single posts page.
	elseif (is_single()) {
		$content[] = 'custom_post';
		return $content;
	}

	# Return the defaults for everything else.
	else
		return $content;
}
add_filter('thesis_body_classes', 'custom_body_classes');

function custom_content_filter($content) {
	$content = str_replace('<a href="http://tmcdonald.wilkinsonandassociates.com', '<a rel="nofollow" href="http://tmcdonald.wilkinsonandassociates.com', $content);
	return $content;
}
add_filter('the_content', 'custom_content_filter');
add_filter('widget_text', 'custom_content_filter');


/* ! custom templates */
remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');

function custom_templates() { 

	global $post;
	global $thesis;

	$custom_template = get_post_meta($post->ID, 'template', true);

	$custom_widgetized_area = get_post_meta($post->ID, 'widgetized_area', true);
	$custom_category = get_post_meta($post->ID, 'category', true);
	$custom_sidebar_1 = get_post_meta($post->ID, 'sidebar1', true);
	$custom_sidebar_2 = get_post_meta($post->ID, 'sidebar2', true);

if ( $custom_template == 'front_page' ) { ?>

<div id="content">
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<div id="post-<?php the_ID(); ?>" class="post_box top">
		<div class="format_text">
			<ul class="front_widgets_top">
				<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Front Before Content') ) : endif; ?>
			</ul>
			<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
			<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
			<ul class="front_widgets_bottom">
				<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Front After Content') ) : endif; ?>
			</ul>
		</div>
	</div>
	<?php endwhile; endif; ?> 
</div>

<div id="sidebars">
	<?php if (thesis_show_multimedia_box())
		thesis_multimedia_box(); ?>

	<div id="sidebar_1" class="sidebar front_sidebar_1">
		<ul class="sidebar_list">
			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Front Sidebar 1') ) : endif; ?>
		</ul>	
		<ul class="sidebar_list">
			<?php thesis_sidebar_1(); ?>
		</ul>
	</div>
	<div id="sidebar_2" class="sidebar front_sidebar_2">
		<ul class="sidebar_list">
			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Front Sidebar 2') ) : endif; ?>
		</ul>
		<ul class="sidebar_list">
			<?php thesis_sidebar_2(); ?>
		</ul>
	</div>
</div>

<?php } else { ?>

<div id="content" class="geo_content">
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<div id="post-<?php the_ID(); ?>" class="post_box top">
		<div class="headline_area">
			<h1><?php the_title(); ?></h1>
		</div>
		<div class="format_text">
			<?php if ($custom_widgetized_area != '') { ?>
			<ul class="geo_widgets_top">
				<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($custom_widgetized_area) ) : endif; ?>
			</ul>
			<?php } ?>		
			<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
			<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
		</div>
	</div>
	<?php wp_reset_query(); endwhile; endif; ?>

		<?php
		$custom_teasers = new WP_Query('showposts=4&cat='. $custom_category);

		$post_count = 1;
		$teaser_count = 1;

		while ($custom_teasers->have_posts()) {
			$custom_teasers->the_post();
	
				if (($teaser_count % 2) == 1) {
					$open_box = '			<div class="teasers_box">' . "\n\n";
					$close_box = '';
					$right = false;
				}
				else {
					$open_box = '';
					$close_box = '			</div>' . "\n\n";
					$right = true;
				}
	
				if ($open_box != '') {
					echo $open_box;
					thesis_hook_before_teasers_box($post_count);
				}
	
				thesis_teaser($classes, $post_count, $right);
	
				if ($close_box != '') {
					echo $close_box;
					thesis_hook_after_teasers_box($post_count);
				}
	
				$teaser_count++;
	
			$post_count++;
		}
	
		if ((($teaser_count - 1) % 2) == 1)
			echo '			</div>' . "\n\n";
		wp_reset_query(); ?>

</div>

<div id="sidebars">
	<?php if (thesis_show_multimedia_box())
		thesis_multimedia_box(); ?>

	<div id="sidebar_1" class="sidebar front_sidebar_1">
	<?php if ($custom_sidebar_1 != '') { ?>
		<ul class="sidebar_list">
			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($custom_sidebar_1) ) : endif; ?>
		</ul>
	<?php } ?>
		<ul class="sidebar_list">
			<?php thesis_sidebar_1(); ?>
		</ul>
	</div>
	<div id="sidebar_2" class="sidebar front_sidebar_2">
	<?php if ($custom_sidebar_2 != '') { ?>
		<ul class="sidebar_list">
			<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar($custom_sidebar_2) ) : endif; ?>
		</ul>
	<?php } ?>
		<ul class="sidebar_list">
			<?php thesis_sidebar_2(); ?>
		</ul>
	</div>
</div>

<?php } }
add_action('thesis_hook_custom_template', 'custom_templates');


/* ! widgetized areas */
if ( function_exists('register_sidebar') ) {

register_sidebar(array(
        'name' => 'Multimedia Box',
        'before_widget' => '<div class="widget %2$s" id="%1$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Geographical Navigation',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Front Before Content',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Front After Content',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Front Sidebar 1',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Front Sidebar 2',
        'before_widget' => '<li class="widget %2$s" id="%1$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3>',
        'after_title' => '</h3>'
    )
);

register_sidebar(array(
        'name' => 'Footer Top',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<span class="hide">',
        'after_title' => '</span>'
    )
);

register_sidebar(array(
        'name' => 'Footer Bottom',
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '<span class="hide">',
        'after_title' => '</span>'
    )
);

/* change the number bellow to the number of custom widgetized areas you need */
register_sidebars(10, array('name'=>'G%d'));

}

/* ! widgets */
File:			custom.css
Description:	Custom styles for Thesis

BASIC USAGE:

If you have enabled the custom stylesheet in the Thesis options panel, the <body> tag 
will be appended with the "custom" class, like so: <body class="custom">. You can use 
the "custom" class to override *any* CSS declarations contained in the style.css file.

For example, if you wish to change the default link color to green, you would add the 
following declarations to this file:

	.custom a, .custom a:visited { color: #090; }	<--- This makes links green
	.custom a:hover { color: #00f; }	<--- This makes links blue when you mouse over them

WHY THIS WORKS:

By using the "custom" class, you are creating more specific CSS declarations for HTML
elements. CSS styling is applied through rules of specificity, and because declarations
prepended with .custom are more specific, they get applied when the page is rendered!

More information about styling your Thesis installation using this file can be found
in the User's Guide:
	http://diythemes.com/thesis/rtfm/customizing-thesis-with-customcss/
*/