Created
January 6, 2012 04:13
-
-
Save JPry/1568927 to your computer and use it in GitHub Desktop.
Files used to add town specific category archives and styling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// First, get the current query object so we can work with it | |
$current_query = get_queried_object(); | |
// Run only if the parent category is "Towns" and the sidebars are active for that town | |
if ( get_cat_ID( 'Towns' ) == $current_query->category_parent ) { | |
add_filter( 'does_city_style', 'does_site_town_name' ); | |
if ( is_active_sidebar( $current_query->slug . '-featured-top' ) || is_active_sidebar( $current_query->slug . '-bottom-left' ) || is_active_sidebar( $current_query->slug . '-bottom-right' ) ) { | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'does_category_featured_top' ); | |
add_action( 'genesis_loop', 'does_category_featured_bottom' ); | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function does_category_featured_top() { | |
$current_query = get_queried_object(); | |
?> | |
<div id="featured-top"> | |
<?php if ( ! dynamic_sidebar( $current_query->cat_name . ' Featured Top' ) ) : ?> | |
<div class="widget"> | |
<h4><?php echo $current_query->cat_name . ' Featured Top'; ?></h4> | |
<div class="wrap"> | |
<p>This is a widgeted area which is called <?php echo $current_query->cat_name; ?> Featured Top.</p> | |
</div><!-- end .wrap --> | |
</div><!-- end .widget --> | |
<?php endif; ?> | |
</div><!-- end #featured-top --> | |
<?php | |
} | |
function does_category_featured_bottom() { | |
$current_query = get_queried_object(); | |
?> | |
<div id="featured-bottom"> | |
<div class="featured-bottom-left"> | |
<?php if ( ! dynamic_sidebar( $current_query->cat_name . ' Bottom Left' ) ) : ?> | |
<!-- Empty widget area --> | |
<?php endif; ?> | |
</div><!-- end .featured-bottom-left --> | |
<div class="featured-bottom-right"> | |
<?php if ( ! dynamic_sidebar( $current_query->cat_name . ' Bottom Right' ) ) : ?> | |
<!-- Empty widget area --> | |
<?php endif; ?> | |
</div><!-- end .featured-bottom-right --> | |
</div><!-- end #featured-bottom --> | |
<?php | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
genesis(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function does_site_town_name( $town ) { | |
$current_query = get_queried_object(); | |
$town = $current_query->slug; | |
return $town; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_city_style_color( $city ) { | |
switch ( $city ): | |
case 'coatesville': | |
return '#B61023'; | |
case 'downingtown': | |
return '#0690a5'; | |
case 'exton': | |
return '#92BD68'; | |
case 'west_chester': | |
case 'west-chester': | |
return '#447EBA'; | |
case 'pet': | |
return '#c36417'; | |
/** Downingtown-related styles */ | |
case 'east-brandywine': | |
return '#00A599'; | |
case 'east-caln': | |
return '#005159'; | |
case 'west-bradford': | |
return '#002D36'; | |
/** Exton-related styles */ | |
case 'west-whiteland': | |
return '#73AF55'; | |
case 'west-pikeland': | |
return '#275E37'; | |
case 'upper-uwchlan': | |
return '#34B233'; | |
case 'uwchlan': | |
return '#009B48'; | |
/** Coatesville-related styles */ | |
case 'caln': | |
return '#F18B7D'; | |
case 'east-fallowfield': | |
return '#F54359'; | |
case 'sadsbury': | |
return '#500409'; | |
case 'valley': | |
return '#D80A19'; | |
case 'west-brandywine': | |
return '#F62C3A'; | |
default: | |
return '#000'; | |
endswitch; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_does_town_categories( $args = array() ) { | |
// Stop immediately if the "Towns" category doesn't exist, and return empty array | |
if ( 0 == get_cat_ID( 'Towns' ) ) | |
return array(); | |
$defaults = array( | |
'parent' => get_cat_ID( 'Towns' ), | |
'order' => 'ASC', | |
'hide_empty' => 0, | |
); | |
$args = wp_parse_args( $args, $defaults ); | |
return get_categories( $args ); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$town_categories = get_does_town_categories(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_head', 'does_site_city_theme' ); | |
function does_site_city_theme() { | |
if ( ! is_admin() ) { | |
$city = apply_filters( 'does_city_style', strtolower( genesis_get_does_site_option( 'city_style' ) ) ); | |
$city_color = get_city_style_color( $city ); | |
echo ' | |
<style type="text/css"> | |
a, | |
a:visited, | |
a:hover, | |
#content h2, | |
#content h2 a, | |
#content h2 a:visited, | |
#content #featured-top h2 a:hover, | |
#content #featured-bottom h2 a:hover, | |
#content h2 a:hover, | |
#sidebar a:hover, | |
#sidebar-alt a:hover, | |
#sidebar h2, | |
#sidebar h2 a, | |
#sidebar-alt h2, | |
#sidebar-alt h2 a, | |
#sidebar h2 a:hover, | |
#sidebar-alt h2 a:hover, | |
#cat{ | |
color: ' . $city_color . '; | |
} | |
.ui-tabs .more-link-:hover { | |
background: ' . $city_color . '; | |
} | |
a.read-more-link:hover { | |
background: ' . $city_color . ' url(' . CHILD_URL . '/city_styles/' . $city . '/readmore-hover.png) left top repeat-x; | |
border: 1px solid ' . $city_color . '; | |
} | |
.navigation li a:hover, .navigation li.active a { | |
background: ' . $city_color . '; | |
border: 1px solid ' . $city_color . '; | |
} | |
.navigation li.disabled { | |
border: 1px solid ' . $city_color . '; | |
} | |
#submit:hover, .searchsubmit:hover, .enews #subbutton:hover, .gform_footer .button:hover { | |
background: ' . $city_color . ' !important; | |
border: 1px solid ' . $city_color . '; | |
} | |
#nav li a:hover, | |
#nav li li a:hover, | |
#nav li li a:active, | |
#nav .seasonal-page { | |
background: url(' . CHILD_URL . '/city_styles/' . $city . '/nav-hover.png) left top repeat-x; | |
} | |
</style> | |
'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment