public
Last active

Thesis Skin Starter Template - Advanced

  • Download Gist
custom.css
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*---:[ body ]:---*/
body { background: #000; }
 
/*---:[ menu ]:---*/
.menu { list-style: none; }
.menu li { float: left; }
.menu li a { text-decoration: none; display: block; }
 
/*---:[ post image fix from @kristarella ]:---*/
.post_image { max-width: 100%; height: auto; }
 
/*---:[ widget lists ]:---*/
.sidebar_list { list-style: none; }
 
/*---:[ clearfixes ]---*/
#content_box:after, .menu:after { visibility: hidden; display: block; content: ""; clear: both; height: 0; }
custom_functions.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
<?php
// Initial sanity check
if (! defined('ABSPATH'))
die('Please do not directly access this file');
 
// classes are a VERY important part of 2.0, so you need to be familiar with them.
 
class thesis_skin_example extends thesis_custom_loop {
public function __construct() {
// run the parent constructor so we can access the thesis custom loop api
parent::__construct();
// run the main init
add_action('init', array($this, 'init'));
}
public function init() {
// actions and filters that will run on init. you could put other things here if you need.
$this->actions();
$this->filters();
$this->switch_skin();
}
public function actions() {
// add and remove actions here
// modify the nav menu to exclude the div wrapper that WP defaults to
remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_before_header', array($this, 'nav'));
}
public function filters() {
// add and remove filters here
/*
* Filter out the standard thesis style.css.
* Run this with a priority of 11 if you want to make sure the gravity forms css gets added.
*/
add_filter('thesis_css', array($this, 'css'), 11, 4);
}
public function css($contents, $thesis_css, $style, $multisite) {
// filter the Thesis generated css. in this example we're removing all the nav styles related to color
$generated_css = $this->filter_css($thesis_css->css);
/*
* You can access the thesis_css object, which contains a variety of settings.
* As an example, I'll show you how to access nav text color.
* Remember that you can always do this in custom.css if you don't care about users having control over the colors
*/
$my_css = "\n/*---:[ my nav menu styles ]:---*/\n" // it's always a good idea to add in comments as to what you're adding
. ".menu li a { color: #{$thesis_css->nav['link']['color']} }\n"
. ".menu li a:hover { color: #{$thesis_css->nav['link']['hover']} }\n\n";
// put in everything except the main thesis style.css. also add an initial css reset
$css = $thesis_css->fonts_to_import . $this->css_reset . $generated_css . $my_css;
// return it
return $css;
}
public function filter_css($css) {
if (! empty($css)) {
// remove the nav colors
if (preg_match('|/\*---:\[ nav colors \]:---\*/|i', $css))
$css = preg_replace('|/\*---:\[ nav colors \]:---\*/(\n.+){7}|i', '', $css);
// you could add more filtering here
}
return $css;
}
public function nav() {
// we're doing this so we can remove the default container div output by WordPress
global $thesis_site;
if (function_exists('wp_nav_menu') && $thesis_site->nav['type'] == 'wp') { #wp
$args = array(
'theme_location' => 'primary',
'container' => '',
'fallback_cb' => 'thesis_nav_default'
);
wp_nav_menu($args); #wp
echo "\n";
}
else
thesis_nav_default();
}
public function switch_skin() {
// Since after_switch_theme won't run, let's make sure that we generate the CSS
if (is_admin() && ! get_option(__CLASS__ . '_generate')) {
thesis_generate_css();
update_option(__CLASS__ . '_generate', 1);
wp_cache_flush();
}
else return null;
}
public function home() {
// this is really just what thesis normally does, except we are excluding posts in "uncategorized"
$post_count = 1;
$teaser_count = 1;
$args = array(
'category__not_in' => array(1) // pass an array of cat ids you DON'T want
);
$home_query = new WP_Query($args); // stick that in the WP_Query class
while ($home_query->have_posts()) { // I do my while loops in brackets cuz I'm a rebel like that
$home_query->the_post();
if (apply_filters('thesis_is_teaser', thesis_is_teaser($post_count))) {
if (($teaser_count % 2) == 1) {
$top = ($post_count == 1) ? ' top' : '';
$open_box = '<div class="teasers_box$top">';
$close_box = '';
$right = false;
}
else {
$open_box = '';
$close_box = "</div>";
$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++;
}
else {
$classes = 'post_box';
 
if ($post_count == 1)
$classes .= ' top';
 
thesis_post_box($classes, $post_count);
}
 
$post_count++;
}
if ((($teaser_count - 1) % 2) == 1)
echo "</div>";
}
}
 
new thesis_skin_example;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.