/
rss.php
57 lines (49 loc) · 1.43 KB
/
rss.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
<?php
/**
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 20.1.0
*
* renamed: template-parts/loop/entry-summary/figure/figure-rss.php
*/
use Framework\Helper;
$args = wp_parse_args(
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
$args,
// phpcs:enable
array(
'_entries_id' => null,
'_item' => false,
)
);
if ( ! $args['_item'] || ! is_a( $args['_item'], 'SimplePie_Item' ) ) {
return;
}
$thumbnail = false;
// note
$simplepie_thumbnail = $args['_item']->get_item_tags( SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail' );
$thumbnail_src = ! empty( $simplepie_thumbnail[0]['data'] ) ? $simplepie_thumbnail[0]['data'] : false;
if ( $thumbnail_src ) {
$thumbnail = sprintf( '<img src="%1$s" alt="">', esc_url( $thumbnail_src ) );
}
// はてなブログ
if ( ! $thumbnail ) {
$thumbnail_src = $args['_item']->get_enclosure()->get_link();
if ( $thumbnail_src ) {
$thumbnail = sprintf( '<img src="%1$s" alt="">', esc_url( $thumbnail_src ) );
}
}
// first img
if ( ! $thumbnail ) {
$description = $args['_item']->get_description();
if ( preg_match( '|^(?:<a [^>]+?>)?(<img [^>]+?>)|ims', $description, $match ) ) {
$thumbnail = $match[1];
$thumbnail = preg_replace( '|style="[^"]*?"|', '', $thumbnail );
$thumbnail = preg_replace( '|class="[^"]*?"|', '', $thumbnail );
}
}
?>
<div class="c-entry-summary__figure">
<?php echo wp_kses_post( $thumbnail ); ?>
</div>