|
1 <?php |
|
2 |
|
3 // create bullet-proof excerpt for meta name="description" |
|
4 |
|
5 function thematic_trim_excerpt($text) { |
|
6 if ( '' == $text ) { |
|
7 $text = get_the_content(''); |
|
8 |
|
9 $text = strip_shortcodes( $text ); |
|
10 |
|
11 $text = str_replace(']]>', ']]>', $text); |
|
12 $text = strip_tags($text); |
|
13 $text = str_replace('"', '\'', $text); |
|
14 $excerpt_length = apply_filters('excerpt_length', 55); |
|
15 $words = explode(' ', $text, $excerpt_length + 1); |
|
16 if (count($words) > $excerpt_length) { |
|
17 array_pop($words); |
|
18 array_push($words, '[...]'); |
|
19 $text = implode(' ', $words); |
|
20 } |
|
21 } |
|
22 return $text; |
|
23 } |
|
24 |
|
25 function thematic_the_excerpt($deprecated = '') { |
|
26 global $post; |
|
27 $output = ''; |
|
28 $output = strip_tags($post->post_excerpt); |
|
29 $output = str_replace('"', '\'', $output); |
|
30 if ( post_password_required($post) ) { |
|
31 $output = __('There is no excerpt because this is a protected post.'); |
|
32 return $output; |
|
33 } |
|
34 |
|
35 return $output; |
|
36 |
|
37 } |
|
38 |
|
39 function thematic_excerpt_rss() { |
|
40 global $post; |
|
41 $output = ''; |
|
42 $output = strip_tags($post->post_excerpt); |
|
43 if ( post_password_required($post) ) { |
|
44 $output = __('There is no excerpt because this is a protected post.'); |
|
45 return $output; |
|
46 } |
|
47 |
|
48 return apply_filters('thematic_excerpt_rss', $output); |
|
49 |
|
50 } |
|
51 |
|
52 add_filter('thematic_excerpt_rss', 'thematic_trim_excerpt'); |
|
53 |
|
54 // create nice multi_tag_title |
|
55 // Credits: Martin Kopischke for providing this code |
|
56 |
|
57 function thematic_tag_query() { |
|
58 $nice_tag_query = get_query_var('tag'); // tags in current query |
|
59 $nice_tag_query = str_replace(' ', '+', $nice_tag_query); // get_query_var returns ' ' for AND, replace by + |
|
60 $tag_slugs = preg_split('%[,+]%', $nice_tag_query, -1, PREG_SPLIT_NO_EMPTY); // create array of tag slugs |
|
61 $tag_ops = preg_split('%[^,+]*%', $nice_tag_query, -1, PREG_SPLIT_NO_EMPTY); // create array of operators |
|
62 |
|
63 $tag_ops_counter = 0; |
|
64 $nice_tag_query = ''; |
|
65 |
|
66 foreach ($tag_slugs as $tag_slug) { |
|
67 $tag = get_term_by('slug', $tag_slug ,'post_tag'); |
|
68 // prettify tag operator, if any |
|
69 if ($tag_ops[$tag_ops_counter] == ',') { |
|
70 $tag_ops[$tag_ops_counter] = ', '; |
|
71 } elseif ($tag_ops[$tag_ops_counter] == '+') { |
|
72 $tag_ops[$tag_ops_counter] = ' + '; |
|
73 } |
|
74 // concatenate display name and prettified operators |
|
75 $nice_tag_query = $nice_tag_query.$tag->name.$tag_ops[$tag_ops_counter]; |
|
76 $tag_ops_counter += 1; |
|
77 } |
|
78 return $nice_tag_query; |
|
79 } |
|
80 |
|
81 ?> |