Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 347 lines (265 sloc) 10.497 kb
03275de Grant Hutchinson Added Starkers 2.8.5 theme files
authored
1 <?php
2 /**
3 * @package WordPress
7b590ff Grant Hutchinson Updated @subpackage tags, again
authored
4 * @subpackage Tersus
03275de Grant Hutchinson Added Starkers 2.8.5 theme files
authored
5 */
6
3004525 Grant Hutchinson THEME_NAME is now defined the same way as other constants
authored
7 // Define Theme Constants
8
9 $theme_data = get_theme_data(TEMPLATEPATH.'/style.css');
10
11 define('THEME_URI', $theme_data['URI']);
12 define('THEME_NAME', $theme_data['Name']);
13 define('THEME_AUTHOR', $theme_data['Author']);
14 define('THEME_VERSION', trim($theme_data['Version']));
15 define('THEME_DESCRIPTION', trim($theme_data['Description']));
16
17
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
18 // Tersus Theme Options
19
2e1ee0e @cdharrison Fixed Issue 21.
cdharrison authored
20 $themename = "Tersus";
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
21 $shortname = "tersus";
22 $options = array (
23 array( "name" => "Flavor",
f9d60e6 Grant Hutchinson Tweaked theme options labels and descriptions
authored
24 "desc" => "Select which theme style you’d like to use.",
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
25 "id" => $shortname."_style_sheet",
26 "type" => "select",
27 "options" => array( "Default", "Advanced", "Super Ginormous" ),
28 "std" => "default"),
cb39e40 Grant Hutchinson New theme options for page and category lists
authored
29 array( "name" => "Sidebar",
30 "desc" => "Show subpages in page list",
31 "id" => $shortname."_page_depth",
32 "type" => "checkbox",
33 "std" => "true"),
34 array( "name" => "",
35 "desc" => "Show the number of posts beside each category",
36 "id" => $shortname."_category_count",
37 "type" => "checkbox",
38 "std" => "true"),
31c80bd Grant Hutchinson New theme option for archive lists
authored
39 array( "name" => "",
40 "desc" => "Show the number of posts beside each archive",
41 "id" => $shortname."_archive_count",
42 "type" => "checkbox",
43 "std" => "true"),
dfcff5d Grant Hutchinson Theme option page formatting and nomenclature
authored
44 array( "name" => "Announcement",
f9d60e6 Grant Hutchinson Tweaked theme options labels and descriptions
authored
45 "desc" => "Display the following text on every page",
e061214 Grant Hutchinson Added theme option to activate global announcement text
authored
46 "id" => $shortname."_announcement_display",
47 "type" => "checkbox",
f9d60e6 Grant Hutchinson Tweaked theme options labels and descriptions
authored
48 "std" => ""),
49 array( "name" => "",
50 "desc" => "HTML may be used to format the announcement text.",
e061214 Grant Hutchinson Added theme option to activate global announcement text
authored
51 "id" => $shortname."_announcement",
e9d3dc3 Grant Hutchinson Added rudimentary theme option for global admin notice
authored
52 "type" => "textarea",
e061214 Grant Hutchinson Added theme option to activate global announcement text
authored
53 "std" => "<p>This text will appear in the announcement area.</p>"),
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
54 );
e9d3dc3 Grant Hutchinson Added rudimentary theme option for global admin notice
authored
55
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
56
135e209 Grant Hutchinson Code formatting persnicketiness
authored
57 // Tersus Theme Options Admin
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
58
59 function tersus_add_admin() {
60 global $themename, $shortname, $options;
61 if ( $_GET['page'] == basename(__FILE__) ) {
62 if ( 'save' == $_REQUEST['action'] ) {
63 foreach ($options as $value) {
64 update_option( $value['id'], $_REQUEST[ $value['id'] ] );
65 }
66 foreach ($options as $value) {
67 if( isset( $_REQUEST[ $value['id'] ] ) ) {
68 update_option( $value['id'], $_REQUEST[ $value['id'] ] );
69 } else {
70 delete_option( $value['id'] );
71 }
72 }
73 header("Location: themes.php?page=functions.php&saved=true");
74 die;
75 } else if( 'reset' == $_REQUEST['action'] ) {
76 foreach ($options as $value) {
77 delete_option( $value['id'] );
78 }
79 header("Location: themes.php?page=functions.php&reset=true");
80 die;
81 }
82 }
83 add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'tersus_admin');
84 }
85
86 function tersus_admin() {
87 global $themename, $shortname, $options;
7cd9afa Grant Hutchinson Minor edits to theme option messages
authored
88 if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' options have been saved.</strong></p></div>';
89 if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' options have been reset to their default settings.</strong></p></div>';
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
90
91 ?>
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
92
93 <div class="wrap">
94 <div id="icon-themes" class="icon32"><br /></div>
95 <h2><?php echo $themename; ?> Options</h2>
96 <form method="post">
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
97 <table class="form-table">
98
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
99 <?php
100 foreach ($options as $value) {
101 switch ( $value['type'] ) {
102 case 'text':
103 ?>
104
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
105 <tr>
106 <th><strong><?php echo $value['name']; ?></strong></th>
dfcff5d Grant Hutchinson Theme option page formatting and nomenclature
authored
107 <td><input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if (get_settings($value['id']) != "") { echo get_settings($value['id']); } else { echo $value['std']; } ?>" /> <?php echo $value['desc']; ?></td>
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
108 </tr>
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
109
110 <?php
111 break;
112 case 'textarea':
113 ?>
114
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
115 <tr>
116 <th><strong><?php echo $value['name']; ?></strong></th>
dfcff5d Grant Hutchinson Theme option page formatting and nomenclature
authored
117 <td><textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="80" rows="5"><?php if (get_settings($value['id']) != "") { echo stripslashes(get_settings( $value['id'] )); } else { echo $value['std']; } ?></textarea>
118 <p><?php echo $value['desc']; ?></p></td>
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
119 </tr>
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
120
121 <?php
122 break;
123 case 'select':
124 ?>
125
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
126 <tr>
127 <th><strong><?php echo $value['name']; ?></strong></th>
dfcff5d Grant Hutchinson Theme option page formatting and nomenclature
authored
128 <td><select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"><?php foreach ($value['options'] as $option) { ?><option<?php if (get_settings($value['id']) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?></select> <?php echo $value['desc']; ?></td>
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
129 </tr>
130
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
131 <?php
132 break;
133 case "checkbox":
134 ?>
135
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
136 <tr>
137 <th><strong><?php echo $value['name']; ?></strong></th>
cb39e40 Grant Hutchinson New theme options for page and category lists
authored
138 <td><input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="1" <?php checked(true, get_option( $value['id'] )); ?> /> <?php echo $value['desc']; ?></td>
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
139 </tr>
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
140
141 <?php break;
142 }
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
143 }
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
144 ?>
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
145
146 </table>
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
147 <p class="submit">
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
148 <input name="save" type="submit" value="Save Changes" />
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
149 <input type="hidden" name="action" value="save" />
150 </p>
151 </form>
152
153 <form method="post">
154 <p class="submit">
1481ef7 Grant Hutchinson Reformatted theme options to match WordPress settings
authored
155 <input name="reset" type="submit" value="Reset Options" />
97fa80e Grant Hutchinson Tidied up the theme option functions
authored
156 <input type="hidden" name="action" value="reset" />
157 </p>
158 </form>
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
159
160 <?php
161 }
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
162
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
163 add_action('admin_menu', 'tersus_add_admin');
164
165 // Automatic Feed Links
166
167 automatic_feed_links();
168
ff51734 Grant Hutchinson Persnickity edits to comment verbiage
authored
169 // Remove non-validating parent post link from header
0647c94 Grant Hutchinson Removed nonvalidating parent post link from header
authored
170
171 remove_action('wp_head', 'parent_post_rel_link');
172
ff51734 Grant Hutchinson Persnickity edits to comment verbiage
authored
173 // Sidebar support. Let's have two, shall we?
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
174
175 if ( function_exists('register_sidebar') ) {
176 register_sidebar(array('name'=>'Sidebar1',
177 'before_widget' => '<li id="%1$s" class="widget %2$s">',
178 'after_widget' => '</li>',
179 'before_title' => '<h2 class="widgettitle">',
180 'after_title' => '</h2>',
181 ));
182 register_sidebar(array('name'=>'Sidebar2',
183 'before_widget' => '<li id="%1$s" class="widget %2$s">',
184 'after_widget' => '</li>',
185 'before_title' => '<h2 class="widgettitle">',
186 'after_title' => '</h2>',
187 ));
188 }
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
189
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
190 // Adds support for Post Formats -- http://codex.wordpress.org/Post_Formats
191
192 add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
193
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
194 // Replace default post class verbosity
195
196 function simple_post_class() {
197 $post = get_post($post_id);
198 $c = array();
199
200 // hentry for hAtom compliance
201 $c[] = 'hentry';
202
203 // Determine Post Format
204 $post_format = get_post_format( $post->ID );
205 if ( $post_format && !is_wp_error($post_format) ) $c[] = $post->post_type . '-' . sanitize_html_class( $post_format );
206
207 // Is it Sticky?
208 if ( is_sticky($post->ID) && is_home() && !is_paged() ) $c[] = 'sticky';
209
210 return $c;
211 }
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
212
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
213 add_filter( 'post_class', 'simple_post_class' );
214
ff51734 Grant Hutchinson Persnickity edits to comment verbiage
authored
215 // Remove non-validating rel attributes from category links
b4c5db3 Grant Hutchinson Removed nonvalidating rel attributes from category links
authored
216
217 function relfix($c) {
4cf8c36 Grant Hutchinson Fixed escaped slashes appearing in category links and announcement text
authored
218 return preg_replace('/category tag/','tag',$c);
b4c5db3 Grant Hutchinson Removed nonvalidating rel attributes from category links
authored
219 }
220
221 add_filter('the_category','relfix');
222
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
223 // Add a proper thousands delimiter to category post counts
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
224
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
225 function delim($c) {
226 return preg_replace('/(\d)(\d{3})\b/','\1,\2',$c); // Hat tip to @myfonts for the regex tweaks
227 }
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
228
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
229 add_filter('wp_list_categories','delim');
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
230
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
231
4106d4e Grant Hutchinson Consolidated class decrufting functions
authored
232 // Remove crufty class and ID attributes from list elements
6e99fba Grant Hutchinson Added a proper thousands delimiter function for category post counts
authored
233
4106d4e Grant Hutchinson Consolidated class decrufting functions
authored
234 function decruft($c) {
235 $c_ = preg_replace('/ class=[\"\'].+?[\"\']/','',$c);
236 return preg_replace('/ id=[\"\'].+?[\"\']/','',$c_);
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
237 }
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
238
4106d4e Grant Hutchinson Consolidated class decrufting functions
authored
239 add_filter('wp_list_bookmarks','decruft');
240 add_filter('wp_list_categories','decruft');
241 add_filter('wp_list_pages','decruft');
242 add_filter('edit_comment_link','decruft');
243 add_filter('comment_reply_link','decruft');
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
244
94dfbde Grant Hutchinson Added filter for comment_class function
authored
245
b27a4c4 Grant Hutchinson Renamed function for consistency
authored
246 // Remove crufty class attributes from avatars
c2b4a3b Grant Hutchinson Added function to remove classes from comment edit and reply links
authored
247
b27a4c4 Grant Hutchinson Renamed function for consistency
authored
248 function decruft_avatars($str) {
249 return preg_replace('/ class=[\"\'].+?[\"\']/',' class="photo"',$str);
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
250 }
d9016c2 Grant Hutchinson Comment lists now use a custom callback function
authored
251
b27a4c4 Grant Hutchinson Renamed function for consistency
authored
252 add_filter ('get_avatar','decruft_avatars');
43b3ae0 Grant Hutchinson Added function to remove extraneous avatar classes
authored
253
d9016c2 Grant Hutchinson Comment lists now use a custom callback function
authored
254
255 // Replacement comment callback function
256 // Removes default class and ID verbosity
257
258 function tersus_comment($comment, $args, $depth) {
259 $GLOBALS['comment'] = $comment; ?>
260 <li id="comment-<?php comment_ID() ?>">
261 <p>Posted by <span class="vcard author"><?php echo get_avatar( $comment->comment_author_email, 48 ); ?> <?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?></span> on <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>" rel="bookmark" title="<?php comment_time('c') ?>"><?php comment_time('l, F jS, Y') ?></a>.</p>
262
263 <?php if ($comment->comment_approved == '0') : ?>
264 <p><em><?php _e('Your comment is awaiting moderation.') ?></em></p>
265 <?php endif; ?>
266
267 <?php comment_text() ?>
268
269 <p><?php edit_comment_link(__('Edit'),'',' | ') ?><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></p>
270 <?php
271 }
272
a32ef3b Grant Hutchinson Updated incline comment reply link anchors
authored
273
274 // Update comment reply link anchors
275
276 function comment_reply_anchor($str) {
277 return preg_replace('/respond/', 'comment', $str);
278 }
279
280 add_filter ('comment_reply_link','comment_reply_anchor');
d9016c2 Grant Hutchinson Comment lists now use a custom callback function
authored
281
282
69a6344 @cdharrison Added functions to enable support of the_page_thumbnail within the RSS f...
cdharrison authored
283 // Add support for the_post_thumbnail
96f841c Grant Hutchinson Added function to remove classes from page list items
authored
284
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
285 if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
286 add_theme_support( 'post-thumbnails' );
287 set_post_thumbnail_size( 600, 9999, true ); // Normal post thumbnails
288 add_image_size( 'archive-thumbnail', 50, 50 ); // Permalink thumbnail size
289 }
9fe4602 Grant Hutchinson Fixed “Headers already sent” error
authored
290
291 // Add support for the_post_thumbnail in RSS feeds
292
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
293 function insertThumbnailRSS($content) {
294 global $post;
295 if ( has_post_thumbnail( $post->ID ) ){
296 $content = '<p class="image">' . get_the_post_thumbnail( $post->ID, 'medium' ) . '</p>' . $content;
297 }
298 return $content;
299 }
3b967cb Grant Hutchinson Added theme information constants
authored
300
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
301 add_filter('the_excerpt_rss', 'insertThumbnailRSS');
302 add_filter('the_content_feed', 'insertThumbnailRSS');
3b967cb Grant Hutchinson Added theme information constants
authored
303
2cb5e7a Grant Hutchinson Added contextual archive navigation delimiters
authored
304 // Removes the link delimiter when viewing first or last post
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
305
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
306 function delim_post_link() {
307 $prev = get_previous_post();
308 $next = get_next_post();
309 if ( $prev && $next ) {
310 echo " | ";
311 }
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
312 }
313
2cb5e7a Grant Hutchinson Added contextual archive navigation delimiters
authored
314 // Removes the link delimiter when viewing first or last archive page
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
315
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
316 function delim_posts_link() {
317 $prev = get_previous_posts_link();
318 $next = get_next_posts_link();
319 if ( $prev && $next ) {
320 echo " | ";
321 }
2cb5e7a Grant Hutchinson Added contextual archive navigation delimiters
authored
322 }
323
324 // Removes the link delimiter when viewing first or last comment
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
325
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
326 function delim_comment_link() {
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
327
6bd2e21 @cdharrison Theme Options, Post Formats, Simple_Post_Class Updates
cdharrison authored
328 $prev = get_previous_comments_link();
329 $next = get_next_comments_link();
330 if ( $prev && $next ) {
331 echo " | ";
332 }
e240851 Grant Hutchinson Added contextual post navigation delimiters
authored
333 }
2cb5e7a Grant Hutchinson Added contextual archive navigation delimiters
authored
334
d5a7ab6 Grant Hutchinson Added filter to excerpt_more function
authored
335 // Custom excerpt links
336
337 function new_excerpt_more($more) {
8879526 Grant Hutchinson Custom excerpt links
authored
338 global $post;
339 $t = get_post($post->ID);
340 $title = $t->post_title;
341 return ' … <a href="' . get_permalink($post->ID) . '" title="Read the rest of “' . $title . '”">Read the rest of this item</a>';
d5a7ab6 Grant Hutchinson Added filter to excerpt_more function
authored
342 }
343
344 add_filter('excerpt_more', 'new_excerpt_more');
345
39f9af7 Grant Hutchinson Added simple_post_class function to replace post_class verbosity
authored
346 ?>
Something went wrong with that request. Please try again.