-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
84 lines (68 loc) · 2.51 KB
/
functions.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
<?php
function futura_get_post_excerpt($post, $limit = '', $strip_tags = TRUE, $show_read_more = FALSE)
{
global $preview;
$more_link_text = null;
$strip_teaser = false;
if ( null === $more_link_text ) {
$more_link_text = sprintf(
'<span aria-label="%1$s">%2$s</span>',
sprintf(
/* translators: %s: Name of current post */
__( 'Continue reading %s' ),
the_title_attribute( array( 'echo' => false ) )
),
__( '(more…)' )
);
}
$output = '';
$has_teaser = false;
// If post password required and it doesn't match the cookie.
if ( post_password_required( $post ) )
return get_the_password_form( $post );
$content = $post->post_content;
if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
$content = explode( $matches[0], $content, 2 );
if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) )
$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
$has_teaser = true;
} else {
$content = array( $content );
}
if ( false !== strpos( $post->post_content, '<!--noteaser-->' ) )
$strip_teaser = true;
$teaser = $content[0];
if ($strip_tags) {
$teaser = strip_tags($teaser);
}
if ($limit != '') {
$teaser = explode(' ', $teaser, $limit);
if (count($teaser)>=$limit) {
array_pop($teaser);
$teaser = implode(" ",$teaser).'...';
} else {
$teaser = implode(" ",$teaser);
}
if (trim($teaser) == '...') {
$teaser = '';
}
}
$output .= $teaser;
if ( count( $content ) > 1 ) {
if ( !empty($more_link_text) && $show_read_more ) {
/**
* Filters the Read More link text.
*
* @since 2.8.0
*
* @param string $more_link_element Read More link element.
* @param string $more_link_text Read More text.
*/
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink($post) . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
}
$output = force_balance_tags( $output );
}
if ( $preview ) // Preview fix for JavaScript bug with foreign languages.
$output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
return $output;
}