-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunmus_zirkusliebe.php
58 lines (46 loc) · 1.2 KB
/
unmus_zirkusliebe.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
<?php
/**
* All about Podcast
*
* @package unmus
* @since 0.1
*/
// Security: Stops code execution if WordPress is not loaded
if (!defined('ABSPATH')) { exit; }
/**
* Modify Podcast Excerpt Length
*
* Required for Taxonomy/Date Archives & Search.
* Excerpt Lenght will be reduced to WordPress Standard.
*
* @since 0.2
*
* @param string Excerpt
* @return string Excerpt
*/
function unmus_zirkusliebe_modify_excerpt_length($input) {
if('podcast' == get_post_type()) {
$word_count = str_word_count( strip_tags( $input ) );
if ($word_count > 65 ) {
$text = $input;
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
return '<p>'.$text.'</p>';
}
else {
return $input;
}
}
else {
return $input;
}
}
add_filter('the_excerpt', 'unmus_zirkusliebe_modify_excerpt_length');
?>