-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-quote.php
executable file
·81 lines (64 loc) · 2.06 KB
/
content-quote.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
<?php
/**
* The template for displaying the quote post format on archives.
*
* @package Patch Lite
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<div class="grid__item">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-meta"><?php patch_lite_card_meta(); ?></div><!-- .entry-meta -->
<?php
//let's see if we have a featured image
$post_thumbnail_style = '';
if ( has_post_thumbnail() ) {
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'patch-single-image' );
if ( isset( $post_thumbnail[0] ) ) {
$post_thumbnail_style = 'style="background-image: url(' . esc_url( $post_thumbnail[0] ) . ');"';
}
} ?>
<div class="entry-content" <?php echo $post_thumbnail_style; ?> >
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<span class="sticky-post"></span>
<?php endif; ?>
<?php
/* translators: %s: Name of current post */
$content = get_the_content(
sprintf(
wp_kses(
__( 'Continue reading %s', 'patch-lite' ),
array(
'span' => array(
'class' => array(),
),
)
),
the_title( '<span class="screen-reader-text">', '</span>', false )
)
);
//now we need to test for the length of the quote so we can decide on a class
$quote_length = mb_strlen( strip_tags( $content ) );
$quote_class = 'entry-quote--long';
if ( $quote_length < 50 ) {
$quote_class = 'entry-quote--short';
} ?>
<div class="content-quote <?php echo esc_attr( $quote_class ); ?>">
<div class="flexbox">
<div class="flexbox__item">
<?php
//test if there is a </blockquote> tag in here
if ( false !== strpos( $content,'</blockquote>' ) ) {
echo $content;
} else {
//we will wrap the whole content in blockquote since this is definitely intended as a quote
echo '<blockquote>' . $content . '</blockquote>';
} ?>
</div>
</div>
</div>
</div><!-- .entry-content -->
</article><!-- #post-## -->
</div><!-- .grid__item -->