1
|
1 |
<?php |
|
2 |
|
|
3 |
// Creates the DOCTYPE section |
|
4 |
function thematic_create_doctype() { |
|
5 |
$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; |
|
6 |
$content .= '<html xmlns="http://www.w3.org/1999/xhtml"'; |
|
7 |
echo apply_filters('thematic_create_doctype', $content); |
|
8 |
} // end thematic_create_doctype |
|
9 |
|
|
10 |
|
|
11 |
// Creates the HEAD Profile |
|
12 |
function thematic_head_profile() { |
|
13 |
$content = '<head profile="http://gmpg.org/xfn/11">' . "\n"; |
|
14 |
echo apply_filters('thematic_head_profile', $content); |
|
15 |
} // end thematic_head_profile |
|
16 |
|
|
17 |
|
|
18 |
// Get the page number adapted from http://efficienttips.com/wordpress-seo-title-description-tag/ |
|
19 |
function pageGetPageNo() { |
|
20 |
if (get_query_var('paged')) { |
|
21 |
print ' | Page ' . get_query_var('paged'); |
|
22 |
} |
|
23 |
} // end pageGetPageNo |
|
24 |
|
|
25 |
|
|
26 |
// Located in header.php |
|
27 |
// Creates the content of the Title tag |
|
28 |
// Credits: Tarski Theme |
|
29 |
function thematic_doctitle() { |
|
30 |
$site_name = get_bloginfo('name'); |
|
31 |
$separator = '|'; |
|
32 |
|
|
33 |
if ( is_single() ) { |
|
34 |
$content = single_post_title('', FALSE); |
|
35 |
} |
|
36 |
elseif ( is_home() || is_front_page() ) { |
|
37 |
$content = get_bloginfo('description'); |
|
38 |
} |
|
39 |
elseif ( is_page() ) { |
|
40 |
$content = single_post_title('', FALSE); |
|
41 |
} |
|
42 |
elseif ( is_search() ) { |
|
43 |
$content = __('Search Results for:', 'thematic'); |
|
44 |
$content .= ' ' . wp_specialchars(stripslashes(get_search_query()), true); |
|
45 |
} |
|
46 |
elseif ( is_category() ) { |
|
47 |
$content = __('Category Archives:', 'thematic'); |
|
48 |
$content .= ' ' . single_cat_title("", false);; |
|
49 |
} |
|
50 |
elseif ( is_tag() ) { |
|
51 |
$content = __('Tag Archives:', 'thematic'); |
|
52 |
$content .= ' ' . thematic_tag_query(); |
|
53 |
} |
|
54 |
elseif ( is_404() ) { |
|
55 |
$content = __('Not Found', 'thematic'); |
|
56 |
} |
|
57 |
else { |
|
58 |
$content = get_bloginfo('description'); |
|
59 |
} |
|
60 |
|
|
61 |
if (get_query_var('paged')) { |
|
62 |
$content .= ' ' .$separator. ' '; |
|
63 |
$content .= 'Page'; |
|
64 |
$content .= ' '; |
|
65 |
$content .= get_query_var('paged'); |
|
66 |
} |
|
67 |
|
|
68 |
if($content) { |
|
69 |
if ( is_home() || is_front_page() ) { |
|
70 |
$elements = array( |
|
71 |
'site_name' => $site_name, |
|
72 |
'separator' => $separator, |
|
73 |
'content' => $content |
|
74 |
); |
|
75 |
} |
|
76 |
else { |
|
77 |
$elements = array( |
|
78 |
'content' => $content |
|
79 |
); |
|
80 |
} |
|
81 |
} else { |
|
82 |
$elements = array( |
|
83 |
'site_name' => $site_name |
|
84 |
); |
|
85 |
} |
|
86 |
|
|
87 |
// Filters should return an array |
|
88 |
$elements = apply_filters('thematic_doctitle', $elements); |
|
89 |
|
|
90 |
// But if they don't, it won't try to implode |
|
91 |
if(is_array($elements)) { |
|
92 |
$doctitle = implode(' ', $elements); |
|
93 |
} |
|
94 |
else { |
|
95 |
$doctitle = $elements; |
|
96 |
} |
|
97 |
|
|
98 |
$doctitle = "\t" . "<title>" . $doctitle . "</title>" . "\n\n"; |
|
99 |
|
|
100 |
echo $doctitle; |
|
101 |
} // end thematic_doctitle |
|
102 |
|
|
103 |
|
|
104 |
// Creates the content-type section |
|
105 |
function thematic_create_contenttype() { |
|
106 |
$content = "\t"; |
|
107 |
$content .= "<meta http-equiv=\"Content-Type\" content=\""; |
|
108 |
$content .= get_bloginfo('html_type'); |
|
109 |
$content .= "; charset="; |
|
110 |
$content .= get_bloginfo('charset'); |
|
111 |
$content .= "\" />"; |
|
112 |
$content .= "\n\n"; |
|
113 |
echo apply_filters('thematic_create_contenttype', $content); |
|
114 |
} // end thematic_create_contenttype |
|
115 |
|
|
116 |
// The master switch for SEO functions |
|
117 |
function thematic_seo() { |
|
118 |
$content = TRUE; |
|
119 |
return apply_filters('thematic_seo', $content); |
|
120 |
} |
|
121 |
|
|
122 |
// Creates the canonical URL |
|
123 |
function thematic_canonical_url() { |
|
124 |
if (thematic_seo()) { |
|
125 |
if ( is_singular() ) { |
|
126 |
$canonical_url = "\t"; |
|
127 |
$canonical_url .= '<link rel="canonical" href="' . get_permalink() . '" />'; |
|
128 |
$canonical_url .= "\n\n"; |
|
129 |
echo apply_filters('thematic_canonical_url', $canonical_url); |
|
130 |
} |
|
131 |
} |
|
132 |
} // end thematic_canonical_url |
|
133 |
|
|
134 |
|
|
135 |
// switch use of thematic_the_excerpt() - default: ON |
|
136 |
function thematic_use_excerpt() { |
|
137 |
$display = TRUE; |
|
138 |
$display = apply_filters('thematic_use_excerpt', $display); |
|
139 |
return $display; |
|
140 |
} // end thematic_use_excerpt |
|
141 |
|
|
142 |
|
|
143 |
// switch use of thematic_the_excerpt() - default: OFF |
|
144 |
function thematic_use_autoexcerpt() { |
|
145 |
$display = FALSE; |
|
146 |
$display = apply_filters('thematic_use_autoexcerpt', $display); |
|
147 |
return $display; |
|
148 |
} // end thematic_use_autoexcerpt |
|
149 |
|
|
150 |
|
|
151 |
// Creates the meta-tag description |
|
152 |
function thematic_create_description() { |
|
153 |
if (thematic_seo()) { |
|
154 |
if (is_single() || is_page() ) { |
|
155 |
if ( have_posts() ) { |
|
156 |
while ( have_posts() ) { |
|
157 |
the_post(); |
|
158 |
if (thematic_the_excerpt() == "") { |
|
159 |
if (thematic_use_autoexcerpt()) { |
|
160 |
$content ="\t"; |
|
161 |
$content .= "<meta name=\"description\" content=\""; |
|
162 |
$content .= thematic_excerpt_rss(); |
|
163 |
$content .= "\" />"; |
|
164 |
$content .= "\n\n"; |
|
165 |
} |
|
166 |
} else { |
|
167 |
if (thematic_use_excerpt()) { |
|
168 |
$content ="\t"; |
|
169 |
$content .= "<meta name=\"description\" content=\""; |
|
170 |
$content .= thematic_the_excerpt(); |
|
171 |
$content .= "\" />"; |
|
172 |
$content .= "\n\n"; |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
} elseif ( is_home() || is_front_page() ) { |
|
178 |
$content ="\t"; |
|
179 |
$content .= "<meta name=\"description\" content=\""; |
|
180 |
$content .= get_bloginfo('description'); |
|
181 |
$content .= "\" />"; |
|
182 |
$content .= "\n\n"; |
|
183 |
} |
|
184 |
echo apply_filters ('thematic_create_description', $content); |
|
185 |
} |
|
186 |
} // end thematic_create_description |
|
187 |
|
|
188 |
|
|
189 |
// meta-tag description is switchable using a filter |
|
190 |
function thematic_show_description() { |
|
191 |
$display = TRUE; |
|
192 |
$display = apply_filters('thematic_show_description', $display); |
|
193 |
if ($display) { |
|
194 |
thematic_create_description(); |
|
195 |
} |
|
196 |
} // end thematic_show_description |
|
197 |
|
|
198 |
|
|
199 |
// create meta-tag robots |
|
200 |
function thematic_create_robots() { |
|
201 |
global $paged; |
|
202 |
if (thematic_seo()) { |
|
203 |
$content = "\t"; |
|
204 |
if((is_home() && ($paged < 2 )) || is_front_page() || is_single() || is_page() || is_attachment()) { |
|
205 |
$content .= "<meta name=\"robots\" content=\"index,follow\" />"; |
|
206 |
} elseif (is_search()) { |
|
207 |
$content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />"; |
|
208 |
} else { |
|
209 |
$content .= "<meta name=\"robots\" content=\"noindex,follow\" />"; |
|
210 |
} |
|
211 |
$content .= "\n\n"; |
|
212 |
if (get_option('blog_public')) { |
|
213 |
echo apply_filters('thematic_create_robots', $content); |
|
214 |
} |
|
215 |
} |
|
216 |
} // end thematic_create_robots |
|
217 |
|
|
218 |
|
|
219 |
// meta-tag robots is switchable using a filter |
|
220 |
function thematic_show_robots() { |
|
221 |
$display = TRUE; |
|
222 |
$display = apply_filters('thematic_show_robots', $display); |
|
223 |
if ($display) { |
|
224 |
thematic_create_robots(); |
|
225 |
} |
|
226 |
} // end thematic_show_robots |
|
227 |
|
|
228 |
|
|
229 |
// Located in header.php |
|
230 |
// creates link to style.css |
|
231 |
function thematic_create_stylesheet() { |
|
232 |
$content = "\t"; |
|
233 |
$content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\""; |
|
234 |
$content .= get_bloginfo('stylesheet_url'); |
|
235 |
$content .= "\" />"; |
|
236 |
$content .= "\n\n"; |
|
237 |
echo apply_filters('thematic_create_stylesheet', $content); |
|
238 |
} |
|
239 |
|
|
240 |
|
|
241 |
// rss usage is switchable using a filter |
|
242 |
function thematic_show_rss() { |
|
243 |
$display = TRUE; |
|
244 |
$display = apply_filters('thematic_show_rss', $display); |
|
245 |
if ($display) { |
|
246 |
$content = "\t"; |
|
247 |
$content .= "<link rel=\"alternate\" type=\"application/rss+xml\" href=\""; |
|
248 |
$content .= get_bloginfo('rss2_url'); |
|
249 |
$content .= "\" title=\""; |
|
250 |
$content .= wp_specialchars(get_bloginfo('name'), 1); |
|
251 |
$content .= " " . __('Posts RSS feed', 'thematic'); |
|
252 |
$content .= "\" />"; |
|
253 |
$content .= "\n"; |
|
254 |
echo apply_filters('thematic_rss', $content); |
|
255 |
} |
|
256 |
} // end thematic_show_rss |
|
257 |
|
|
258 |
|
|
259 |
// comments rss usage is switchable using a filter |
|
260 |
function thematic_show_commentsrss() { |
|
261 |
$display = TRUE; |
|
262 |
$display = apply_filters('thematic_show_commentsrss', $display); |
|
263 |
if ($display) { |
|
264 |
$content = "\t"; |
|
265 |
$content .= "<link rel=\"alternate\" type=\"application/rss+xml\" href=\""; |
|
266 |
$content .= get_bloginfo('comments_rss2_url'); |
|
267 |
$content .= "\" title=\""; |
|
268 |
$content .= wp_specialchars(get_bloginfo('name'), 1); |
|
269 |
$content .= " " . __('Comments RSS feed', 'thematic'); |
|
270 |
$content .= "\" />"; |
|
271 |
$content .= "\n\n"; |
|
272 |
echo apply_filters('thematic_commentsrss', $content); |
|
273 |
} |
|
274 |
} // end thematic_show_commentsrss |
|
275 |
|
|
276 |
|
|
277 |
// pingback usage is switchable using a filter |
|
278 |
function thematic_show_pingback() { |
|
279 |
$display = TRUE; |
|
280 |
$display = apply_filters('thematic_show_pingback', $display); |
|
281 |
if ($display) { |
|
282 |
$content = "\t"; |
|
283 |
$content .= "<link rel=\"pingback\" href=\""; |
|
284 |
$content .= get_bloginfo('pingback_url'); |
|
285 |
$content .= "\" />"; |
|
286 |
$content .= "\n\n"; |
|
287 |
echo apply_filters('thematic_pingback_url',$content); |
|
288 |
} |
|
289 |
} // end thematic_show_pingback |
|
290 |
|
|
291 |
|
|
292 |
// comment reply usage is switchable using a filter |
|
293 |
function thematic_show_commentreply() { |
|
294 |
$display = TRUE; |
|
295 |
$display = apply_filters('thematic_show_commentreply', $display); |
|
296 |
if ($display) |
|
297 |
if ( is_singular() ) |
|
298 |
wp_enqueue_script( 'comment-reply' ); // support for comment threading |
|
299 |
} // end thematic_show_commentreply |
|
300 |
|
|
301 |
|
|
302 |
// Load scripts for the jquery Superfish plugin http://users.tpg.com.au/j_birch/plugins/superfish/#examples |
|
303 |
function thematic_head_scripts() { |
|
304 |
$scriptdir_start = "\t"; |
|
305 |
$scriptdir_start .= '<script type="text/javascript" src="'; |
|
306 |
$scriptdir_start .= get_bloginfo('template_directory'); |
|
307 |
$scriptdir_start .= '/library/scripts/'; |
|
308 |
|
|
309 |
$scriptdir_end = '"></script>'; |
|
310 |
|
|
311 |
$scripts = "\n"; |
|
312 |
$scripts .= $scriptdir_start . 'hoverIntent.js' . $scriptdir_end . "\n"; |
|
313 |
$scripts .= $scriptdir_start . 'superfish.js' . $scriptdir_end . "\n"; |
|
314 |
$scripts .= $scriptdir_start . 'supersubs.js' . $scriptdir_end . "\n"; |
|
315 |
$dropdown_options = $scriptdir_start . 'thematic-dropdowns.js' . $scriptdir_end . "\n"; |
|
316 |
|
|
317 |
$scripts = $scripts . apply_filters('thematic_dropdown_options', $dropdown_options); |
|
318 |
|
|
319 |
$scripts .= "\n"; |
|
320 |
$scripts .= "\t"; |
|
321 |
$scripts .= '<script type="text/javascript">' . "\n"; |
|
322 |
$scripts .= "\t\t"; |
|
323 |
$scripts .= 'jQuery.noConflict();' . "\n"; |
|
324 |
$scripts .= "\t"; |
|
325 |
$scripts .= '</script>' . "\n"; |
|
326 |
|
|
327 |
// Print filtered scripts |
|
328 |
print apply_filters('thematic_head_scripts', $scripts); |
|
329 |
|
|
330 |
} |
|
331 |
add_action('wp_head','thematic_head_scripts'); |
|
332 |
|
|
333 |
|
|
334 |
// Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu |
|
335 |
function thematic_add_menuclass($ulclass) { |
|
336 |
return preg_replace('/<ul>/', '<ul class="sf-menu">', $ulclass, 1); |
|
337 |
} // end thematic_add_menuclass |
|
338 |
add_filter('wp_page_menu','thematic_add_menuclass'); |
|
339 |
|
|
340 |
|
|
341 |
// Just after the opening body tag, before anything else. |
|
342 |
function thematic_before() { |
|
343 |
do_action('thematic_before'); |
|
344 |
} // end thematic_before |
|
345 |
|
|
346 |
|
|
347 |
// Just before the header div |
|
348 |
function thematic_aboveheader() { |
|
349 |
do_action('thematic_aboveheader'); |
|
350 |
} // end thematic_aboveheader |
|
351 |
|
|
352 |
|
|
353 |
// Used to hook in the HTML and PHP that creates the content of div id="header"> |
|
354 |
function thematic_header() { |
|
355 |
do_action('thematic_header'); |
|
356 |
} // end thematic_header |
|
357 |
|
|
358 |
|
|
359 |
// Functions that hook into thematic_header() |
|
360 |
|
|
361 |
// Open #branding |
|
362 |
// In the header div |
|
363 |
function thematic_brandingopen() { ?> |
|
364 |
<div id="branding"> |
|
365 |
<?php } |
|
366 |
add_action('thematic_header','thematic_brandingopen',1); |
|
367 |
|
|
368 |
|
|
369 |
// Create the blog title |
|
370 |
// In the header div |
|
371 |
function thematic_blogtitle() { ?> |
|
372 |
<div id="blog-title"><span><a href="<?php bloginfo('url') ?>/" title="<?php bloginfo('name') ?>" rel="home"><?php bloginfo('name') ?></a></span></div> |
|
373 |
<?php } |
|
374 |
add_action('thematic_header','thematic_blogtitle',3); |
|
375 |
|
|
376 |
|
|
377 |
// Create the blog description |
|
378 |
// In the header div |
|
379 |
function thematic_blogdescription() { |
|
380 |
if (is_home() || is_front_page()) { ?> |
|
381 |
<h1 id="blog-description"><?php bloginfo('description') ?></h1> |
|
382 |
<?php } else { ?> |
|
383 |
<div id="blog-description"><?php bloginfo('description') ?></div> |
|
384 |
<?php } |
|
385 |
} |
|
386 |
add_action('thematic_header','thematic_blogdescription',5); |
|
387 |
|
|
388 |
|
|
389 |
// Close #branding |
|
390 |
// In the header div |
|
391 |
function thematic_brandingclose() { ?> |
|
392 |
</div><!-- #branding --> |
|
393 |
<?php } |
|
394 |
add_action('thematic_header','thematic_brandingclose',7); |
|
395 |
|
|
396 |
|
|
397 |
// Create #access |
|
398 |
// In the header div |
|
399 |
function thematic_access() { ?> |
|
400 |
<div id="access"> |
|
401 |
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div> |
|
402 |
<?php wp_page_menu('sort_column=menu_order') ?> |
|
403 |
</div><!-- #access --> |
|
404 |
<?php } |
|
405 |
add_action('thematic_header','thematic_access',9); |
|
406 |
|
|
407 |
|
|
408 |
// End of functions that hook into thematic_header() |
|
409 |
|
|
410 |
|
|
411 |
// Just after the header div |
|
412 |
function thematic_belowheader() { |
|
413 |
do_action('thematic_belowheader'); |
|
414 |
} // end thematic_belowheader |
|
415 |
|
|
416 |
|
|
417 |
?> |