| @@ -11,31 +11,39 @@ | ||
| 11 | 11 | public $options = array(); |
| 12 | 12 | |
| 13 | 13 | public function __construct( $options ){ |
| 14 | 14 | |
| 15 | - $this->options = wp_parse_args( $options, SRR_Options::default_options() ); | |
| 15 | + $this->options = wp_parse_args( $options, SRR_Options::defaults() ); | |
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function html(){ |
| 20 | 20 | |
| 21 | - $urls = stripslashes( trim( $this->options['urls'] ) ); | |
| 22 | - $tab_titles = stripslashes( $this->options['tab_titles'] ); | |
| 21 | + $urls = trim( $this->options['urls'] ); | |
| 22 | + $tab_titles = $this->options['tab_titles']; | |
| 23 | 23 | $count = intval( $this->options['count'] ); |
| 24 | 24 | |
| 25 | 25 | $show_date = intval( $this->options['show_date'] ); |
| 26 | 26 | $show_desc = intval( $this->options['show_desc'] ); |
| 27 | 27 | $show_author = intval( $this->options['show_author'] ); |
| 28 | - $show_thumb = stripslashes( $this->options['show_thumb'] ); | |
| 28 | + $show_thumb = intval( $this->options['show_thumb'] ); | |
| 29 | 29 | $open_newtab = intval( $this->options['open_newtab'] ); |
| 30 | 30 | $add_nofollow = intval( $this->options['add_nofollow'] ); |
| 31 | 31 | $strip_desc = intval( $this->options['strip_desc'] ); |
| 32 | 32 | $strip_title = intval( $this->options['strip_title'] ); |
| 33 | - $read_more = htmlspecialchars( $this->options['read_more'] ); | |
| 33 | + $date_format = $this->options['date_format']; | |
| 34 | + $date_timezone = $this->options['date_timezone']; | |
| 35 | + $order_by = $this->options['order_by']; | |
| 36 | + $read_more = $this->options['read_more']; | |
| 34 | 37 | $rich_desc = intval( $this->options['rich_desc'] ); |
| 35 | - | |
| 36 | - $color_theme = stripslashes( $this->options['color_style'] ); | |
| 37 | - $display_type = stripslashes( $this->options['display_type'] ); | |
| 38 | + $desc_type = $this->options['desc_type']; | |
| 39 | + $thumbnail_position = $this->options['thumbnail_position']; | |
| 40 | + $thumbnail_size = $this->options['thumbnail_size']; | |
| 41 | + $thumbnail_default = $this->options['thumbnail_default']; | |
| 42 | + $no_feed_text = $this->options['no_feed_text']; | |
| 43 | + | |
| 44 | + $color_theme = $this->options['color_style']; | |
| 45 | + $display_type = $this->options['display_type']; | |
| 38 | 46 | $visible_items = intval( $this->options['visible_items'] ); |
| 39 | 47 | $ticker_speed = intval( $this->options['ticker_speed'] ) * 1000; |
| 40 | 48 | |
| 41 | 49 | if( empty( $urls ) ){ |
| @@ -50,18 +58,29 @@ | ||
| 50 | 58 | $url_count = count( $urls ); |
| 51 | 59 | |
| 52 | 60 | $feeds = array(); |
| 53 | 61 | $html = ''; |
| 62 | + $no_feed_html = '<div>' . wp_kses_post( $no_feed_text ) . '</div>'; | |
| 54 | 63 | |
| 64 | + $classes = array( 'srr-wrap', 'srr-style-' . $color_theme ); | |
| 65 | + if( $display_type == 'vertical_ticker' ) array_push( $classes, 'srr-vticker' ); | |
| 66 | + $class = implode( ' ', $classes ); | |
| 67 | + | |
| 55 | 68 | // Fetch the feed |
| 56 | 69 | for( $i=0; $i < $url_count; $i++ ){ |
| 57 | 70 | $feed_url = trim( $urls[$i] ); |
| 71 | + | |
| 72 | + // Skip if the RSS feed URL is same as the site URL | |
| 73 | + if ( in_array( untrailingslashit( $feed_url ), array( site_url(), home_url() ), true ) ) { | |
| 74 | + continue; | |
| 75 | + } | |
| 76 | + | |
| 58 | 77 | $feed = fetch_feed( $feed_url ); |
| 59 | 78 | |
| 60 | 79 | if( is_wp_error( $feed ) ){ |
| 61 | - $feed_title = 'Error'; | |
| 80 | + $feed_title = __( 'Error' ); | |
| 62 | 81 | }else{ |
| 63 | - $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : esc_attr( strip_tags( $feed->get_title() ) ); | |
| 82 | + $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : strip_tags( $feed->get_title() ); | |
| 64 | 83 | } |
| 65 | 84 | |
| 66 | 85 | $feeds[ $feed_url ] = array( |
| 67 | 86 | 'id' => rand( 100, 999 ), |
| @@ -71,17 +90,13 @@ | ||
| 71 | 90 | } |
| 72 | 91 | |
| 73 | 92 | // Generate tabs |
| 74 | 93 | if( $url_count > 1 ){ |
| 75 | - $html .= '<ul class="srr-tab-wrap srr-tab-style-' . $color_theme . ' srr-clearfix">'; | |
| 94 | + $html .= '<ul class="srr-tab-wrap srr-tab-style-' . esc_attr( $color_theme ) . ' srr-clearfix">'; | |
| 76 | 95 | foreach( $feeds as $url => $data ){ |
| 77 | 96 | $id = $data[ 'id' ]; |
| 78 | 97 | $feed = $data[ 'feed' ]; |
| 79 | - if( is_wp_error( $feed ) ){ | |
| 80 | - $html .= '<li data-tab="srr-tab-' . $id . '">Error</li>'; | |
| 81 | - }else{ | |
| 82 | - $html .= '<li data-tab="srr-tab-' . $id . '">' . $data[ 'title' ] . '</li>'; | |
| 83 | - } | |
| 98 | + $html .= '<li data-tab="srr-tab-' . esc_attr( $id ) . '">' . wp_kses_post( $data[ 'title' ] ) . '</li>'; | |
| 84 | 99 | } |
| 85 | 100 | $html .= '</ul>'; |
| 86 | 101 | } |
| 87 | 102 | |
| @@ -92,32 +107,35 @@ | ||
| 92 | 107 | $feed = $data[ 'feed' ]; |
| 93 | 108 | |
| 94 | 109 | // Check for feed errors |
| 95 | 110 | if ( is_wp_error( $feed ) ){ |
| 96 | - $html .= '<div class="srr-wrap srr-style-' . $color_theme .'" data-id="srr-tab-' . $id . '"><p>RSS Error: ' . $feed->get_error_message() . '</p></div>'; | |
| 111 | + $html .= '<div class="srr-wrap srr-style-' . esc_attr( $color_theme ) .'" data-id="srr-tab-' . esc_attr( $id ) . '"><p>RSS Error: ' . wp_kses_post( $feed->get_error_message() ) . '</p></div>'; | |
| 97 | 112 | continue; |
| 98 | 113 | } |
| 99 | 114 | |
| 100 | 115 | if( method_exists( $feed, 'enable_order_by_date' ) ){ |
| 101 | - $feed->enable_order_by_date( false ); | |
| 116 | + if( in_array( $order_by, array( 'date', 'date_reverse' ) ) ){ | |
| 117 | + $feed->enable_order_by_date( true ); | |
| 118 | + }else{ | |
| 119 | + $feed->enable_order_by_date( false ); | |
| 120 | + } | |
| 102 | 121 | } |
| 103 | 122 | |
| 104 | - $max_items = $feed->get_item_quantity( $count ); | |
| 105 | - $feed_items = $feed->get_items( 0, $max_items ); | |
| 106 | - | |
| 107 | - $classes = array( 'srr-wrap', 'srr-style-' . $color_theme ); | |
| 108 | - if( $display_type == 'vertical_ticker' ) array_push( $classes, 'srr-vticker' ); | |
| 109 | - $class = implode( ' ', $classes ); | |
| 110 | - | |
| 111 | 123 | // Outer wrap start |
| 112 | - $html .= '<div class="' . $class . '" data-visible="' . $visible_items . '" data-speed="' . $ticker_speed . '" data-id="srr-tab-' . $id . '">'; | |
| 124 | + $html .= '<div class="' . esc_attr( $class ) . '" data-visible="' . esc_attr( $visible_items ) . '" data-speed="' . esc_attr( $ticker_speed ) . '" data-id="srr-tab-' . esc_attr( $id ) . '">'; | |
| 113 | 125 | $html .= '<div>'; |
| 114 | 126 | |
| 127 | + $max_items = $feed->get_item_quantity(); | |
| 128 | + | |
| 115 | 129 | // Check feed items |
| 116 | 130 | if ( $max_items == 0 ){ |
| 117 | - $html .= '<div>No items.</div>'; | |
| 131 | + $html .= $no_feed_html; | |
| 118 | 132 | }else{ |
| 133 | + | |
| 134 | + $feed_items = $feed->get_items(); | |
| 135 | + $feed_items = $this->process_items( $feed_items, $count, $order_by ); | |
| 119 | 136 | $j=1; |
| 137 | + | |
| 120 | 138 | // Loop through each feed item |
| 121 | 139 | foreach( $feed_items as $item ){ |
| 122 | 140 | |
| 123 | 141 | // Link |
| @@ -122,12 +140,12 @@ | ||
| 122 | 140 | |
| 123 | 141 | // Link |
| 124 | 142 | $link = $item->get_link(); |
| 125 | 143 | while ( stristr( $link, 'http' ) != $link ){ $link = substr( $link, 1 ); } |
| 126 | - $link = esc_url( strip_tags($link) ); | |
| 144 | + $link = strip_tags($link); | |
| 127 | 145 | |
| 128 | 146 | // Title |
| 129 | - $title = esc_attr( strip_tags( $item->get_title() ) ); | |
| 147 | + $title = strip_tags( $item->get_title() ); | |
| 130 | 148 | $title_full = $title; |
| 131 | 149 | |
| 132 | 150 | if ( empty( $title ) ){ |
| 133 | 151 | $title = __( 'No Title', 'super-rss-reader' ); |
| @@ -140,20 +158,45 @@ | ||
| 140 | 158 | // Open links in new tab |
| 141 | 159 | $new_tab = $open_newtab ? ' target="_blank"' : ''; |
| 142 | 160 | |
| 143 | 161 | // Add no follow attribute |
| 144 | - $no_follow = $add_nofollow ? ' rel="nofollow"' : ''; | |
| 162 | + $no_follow = $add_nofollow ? ' rel="nofollow noopener noreferrer"' : ''; | |
| 145 | 163 | |
| 164 | + if( empty( $link ) ){ | |
| 165 | + $link = '#'; | |
| 166 | + $new_tab = ''; | |
| 167 | + } | |
| 168 | + | |
| 146 | 169 | // Date |
| 147 | - $date = $item->get_date( 'j F Y' ); | |
| 148 | - $date_full = esc_attr( $item->get_date() ); | |
| 170 | + $date = ''; | |
| 171 | + $date_full = strip_tags( $item->get_date() ); | |
| 149 | 172 | |
| 173 | + if( strtolower( $date_format ) == 'relative' ){ | |
| 174 | + $item_date = $item->get_date( 'U' ); | |
| 175 | + if( $item_date ){ | |
| 176 | + $date = human_time_diff( $item_date, current_time( 'U' ) ) . ' ' . __( 'ago' ); | |
| 177 | + }else{ | |
| 178 | + $date = __( 'Today' ); | |
| 179 | + } | |
| 180 | + }else{ | |
| 181 | + $date = SRR_Utilities::date_i18n( $date_format, $item->get_date( 'U' ), $date_timezone ); | |
| 182 | + } | |
| 183 | + | |
| 150 | 184 | // Thumbnail |
| 151 | 185 | $thumb = ''; |
| 152 | - if ( $show_thumb == 1 && $enclosure = $item->get_enclosure() ){ | |
| 153 | - $thumb_url = $enclosure->get_thumbnail(); | |
| 186 | + if ( $show_thumb == 1 ){ | |
| 187 | + $thumb_url = $this->get_thumbnail_url( $item, $thumbnail_default ); | |
| 188 | + $thumb_url = apply_filters( 'srr_mod_thumbnail_url', $thumb_url, $item, $feed, $thumbnail_default ); | |
| 154 | 189 | if( !empty( $thumb_url ) ){ |
| 155 | - $thumb = '<img src="' . $thumb_url . '" alt="' . $title_full . '" class="srr-thumb" align="left" />'; | |
| 190 | + $thumb_styles = array( | |
| 191 | + 'width' => $thumbnail_size, | |
| 192 | + 'height' => $thumbnail_size | |
| 193 | + ); | |
| 194 | + $thumb_style = ''; | |
| 195 | + foreach( $thumb_styles as $prop => $val ){ | |
| 196 | + $thumb_style .= "$prop:$val;"; | |
| 197 | + } | |
| 198 | + $thumb = '<a href="' . esc_url( $link ) . '" class="srr-thumb srr-thumb-' . esc_attr( $thumbnail_position ) . '" style="' . esc_attr( $thumb_style ) . '" ' . $new_tab . $no_follow . '><img src="' . esc_url( $thumb_url ) . '" alt="' . esc_attr( $title_full ) . '" align="left"' . ( wp_lazy_loading_enabled( 'img', 'srr-thumbnail' ) ? ' loading="lazy"' : '' ) . ' /></a>'; | |
| 156 | 199 | } |
| 157 | 200 | } |
| 158 | 201 | |
| 159 | 202 | // Description |
| @@ -158,75 +201,109 @@ | ||
| 158 | 201 | |
| 159 | 202 | // Description |
| 160 | 203 | $desc = ''; |
| 161 | 204 | if( $show_desc ){ |
| 205 | + $desc_content = ( $desc_type == 'summary' ) ? $item->get_description() : $item->get_content(); | |
| 162 | 206 | if( $rich_desc ){ |
| 163 | - $desc = strip_tags( $item->get_description(), '<p><a><img><em><strong><font><strike><s><u><i>' ); | |
| 207 | + $desc = wp_kses_post( strip_tags( $desc_content, '<p><a><img><em><strong><font><strike><s><u><i><br>' ) ); | |
| 164 | 208 | }else{ |
| 209 | + $desc = str_replace( array( "\n", "\r" ), ' ', strip_tags( @html_entity_decode( $desc_content, ENT_QUOTES, get_option('blog_charset') ) ) ); | |
| 165 | 210 | |
| 166 | - $desc = str_replace( array( "\n", "\r" ), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) ); | |
| 167 | - $read_more_link = ''; | |
| 168 | - | |
| 169 | 211 | if( $strip_desc != 0 ){ |
| 170 | 212 | $desc = wp_trim_words( $desc, $strip_desc ); |
| 171 | - $read_more_link = !empty( $read_more ) ? ' <a href="' . $link . '" title="Read more"' . $new_tab . $no_follow . '>' . $read_more . '</a>' : ''; | |
| 172 | - | |
| 173 | 213 | if ( '[...]' == substr( $desc, -5 ) ){ |
| 174 | 214 | $desc = substr( $desc, 0, -5 ); |
| 175 | 215 | }elseif ( '[…]' != substr( $desc, -10 ) ){ |
| 176 | 216 | $desc .= ''; |
| 177 | 217 | } |
| 218 | + } | |
| 178 | 219 | |
| 179 | - $desc = esc_html( $desc ); | |
| 220 | + $desc = trim( esc_html( $desc ) ); | |
| 221 | + if( !empty( $desc ) ){ | |
| 222 | + $read_more_link = !empty( $read_more ) ? ' <a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'Read more', 'super-rss-reader' ) . '"' . $new_tab . $no_follow . ' class="srr-read-more">' . esc_html( $read_more ) . '</a>' : ''; | |
| 223 | + $desc = $desc . $read_more_link; | |
| 180 | 224 | } |
| 181 | 225 | |
| 182 | - $desc = $desc . $read_more_link; | |
| 183 | - | |
| 184 | 226 | } |
| 185 | 227 | } |
| 186 | 228 | |
| 187 | 229 | // Author |
| 188 | - $author = $item->get_author(); | |
| 189 | - if ( is_object( $author ) ) { | |
| 190 | - $author = $author->get_name(); | |
| 191 | - $author = esc_html( strip_tags( $author ) ); | |
| 230 | + $author = ''; | |
| 231 | + if( $show_author ){ | |
| 232 | + $author = $item->get_author(); | |
| 233 | + if ( is_object( $author ) ) { | |
| 234 | + $author = strip_tags( $author->get_name() ); | |
| 235 | + } | |
| 192 | 236 | } |
| 193 | 237 | |
| 194 | - // Display the feed items | |
| 195 | - $html .= '<div class="srr-item ' . ( ( $j%2 == 0 ) ? 'even' : 'odd') . ' srr-clearfix">'; | |
| 196 | - $html .= '<div class="srr-title"><a href="' . $link . '"' . $new_tab . $no_follow . ' title="' . $title_full . '">' . $title . '</a></div>'; | |
| 238 | + $t_title = ''; | |
| 239 | + $t_meta = ''; | |
| 240 | + $t_thumb = ''; | |
| 241 | + $t_desc = ''; | |
| 197 | 242 | |
| 198 | - $html .= '<div class="srr-meta">'; | |
| 199 | - if( $show_date && !empty( $date ) ){ | |
| 200 | - $html .= '<time class="srr-date" title="' . $date_full . '">' . $date . '</time>'; | |
| 201 | - } | |
| 243 | + $t_title .= '<div class="srr-title"><a href="' . esc_url( $link ) . '"' . $new_tab . $no_follow . ' title="' . esc_attr( $title_full ) . '">' . esc_html( $title ) . '</a></div>'; | |
| 202 | 244 | |
| 203 | - if( $show_author && !empty( $author ) ){ | |
| 204 | - $html .= ' - <cite class="srr-author">' . $author . '</cite>'; | |
| 245 | + // Metadata | |
| 246 | + if( $show_date || $show_author ){ | |
| 247 | + $t_meta .= '<div class="srr-meta">'; | |
| 248 | + if( $show_date && !empty( $date ) ){ | |
| 249 | + $t_meta .= '<time class="srr-date" title="' . esc_attr( $date_full ) . ' UTC">' . esc_html( $date ) . '</time>'; | |
| 250 | + } | |
| 251 | + | |
| 252 | + if( $show_author && !empty( $author ) ){ | |
| 253 | + $t_meta .= ' - <cite class="srr-author">' . esc_html( $author ) . '</cite>'; | |
| 254 | + } | |
| 255 | + $t_meta .= '</div>'; // End meta | |
| 205 | 256 | } |
| 206 | - $html .= '</div>'; | |
| 207 | 257 | |
| 208 | 258 | if ( $show_thumb ){ |
| 209 | - $html .= $thumb; | |
| 259 | + $t_thumb .= $thumb; | |
| 210 | 260 | } |
| 211 | 261 | |
| 212 | - if( $show_desc ){ | |
| 213 | - $html .= '<div class="srr-summary srr-clearfix">'; | |
| 214 | - $html .= $rich_desc ? $desc : ( '<p>' . $desc . '</p>' ); | |
| 215 | - $html .= '</div>'; | |
| 262 | + if( $show_desc && !empty( $desc ) ){ | |
| 263 | + $t_desc .= '<div class="srr-summary srr-clearfix">'; | |
| 264 | + $t_desc .= $rich_desc ? $desc : ( '<p>' . $desc . '</p>' ); | |
| 265 | + $t_desc .= '</div>'; // End summary | |
| 216 | 266 | } |
| 217 | 267 | |
| 218 | - $html .= '</div>'; | |
| 219 | - // End display | |
| 268 | + $f_data = apply_filters( 'srr_mod_item_html', array( | |
| 269 | + 'title' => $t_title, | |
| 270 | + 'meta' => $t_meta, | |
| 271 | + 'thumbnail' => $t_thumb, | |
| 272 | + 'description' => $t_desc, | |
| 273 | + 'before' => '', | |
| 274 | + 'after' => '' | |
| 275 | + ), $url, $item ); | |
| 220 | 276 | |
| 277 | + $f_title = !isset( $f_data[ 'title' ] ) ? '' : $f_data[ 'title' ]; | |
| 278 | + $f_meta = !isset( $f_data[ 'meta' ] ) ? '' : $f_data[ 'meta' ]; | |
| 279 | + $f_thumb = !isset( $f_data[ 'thumbnail' ] ) ? '' : $f_data[ 'thumbnail' ]; | |
| 280 | + $f_desc = !isset( $f_data[ 'description' ] ) ? '' : $f_data[ 'description' ]; | |
| 281 | + $f_before = !isset( $f_data[ 'before' ] ) ? '' : $f_data[ 'before' ]; | |
| 282 | + $f_after = !isset( $f_data[ 'after' ] ) ? '' : $f_data[ 'after' ]; | |
| 283 | + | |
| 284 | + // Display the feed items | |
| 285 | + $html .= '<div class="srr-item ' . ( ( $j%2 == 0 ) ? 'srr-stripe' : '') . '">'; | |
| 286 | + $html .= '<div class="srr-clearfix">'; | |
| 287 | + $html .= $f_before; | |
| 288 | + $html .= $f_title . $f_meta . $f_thumb . $f_desc; | |
| 289 | + $html .= $f_after; | |
| 290 | + $html .= '</div>'; // End item inner clearfix | |
| 291 | + $html .= '</div>'; // End feed item | |
| 292 | + | |
| 221 | 293 | $j++; |
| 222 | 294 | } |
| 295 | + | |
| 296 | + if( $j == 1 ){ | |
| 297 | + $html .= $no_feed_html; | |
| 298 | + } | |
| 299 | + | |
| 223 | 300 | } |
| 224 | 301 | |
| 225 | 302 | // Outer wrap end |
| 226 | 303 | $html .= '</div></div>' ; |
| 227 | 304 | |
| 228 | - if ( !is_wp_error( $feed ) ) | |
| 305 | + if( !is_wp_error( $feed ) ) | |
| 229 | 306 | $feed->__destruct(); |
| 230 | 307 | |
| 231 | 308 | unset( $feed ); |
| 232 | 309 | |
| @@ -231,9 +308,68 @@ | ||
| 231 | 308 | unset( $feed ); |
| 232 | 309 | |
| 233 | 310 | } |
| 234 | 311 | |
| 312 | + $html = '<div class="srr-main">' . $html . '</div>'; | |
| 313 | + | |
| 235 | 314 | return $html; |
| 315 | + | |
| 316 | + } | |
| 317 | + | |
| 318 | + function process_items( $items, $count, $order_by ){ | |
| 319 | + | |
| 320 | + if( count( $items ) == 0 ){ | |
| 321 | + return $items; | |
| 322 | + } | |
| 323 | + | |
| 324 | + // For shuffle order - Shuffle first and then slice as per count | |
| 325 | + if( $order_by == 'random' ){ | |
| 326 | + shuffle( $items ); | |
| 327 | + return array_slice( $items, 0, $count ); | |
| 328 | + } | |
| 329 | + | |
| 330 | + // For date based order - slice first and then order | |
| 331 | + $items = array_slice( $items, 0, $count ); | |
| 332 | + | |
| 333 | + if( $order_by == 'date_reverse' ){ | |
| 334 | + $items = array_reverse( $items ); | |
| 335 | + } | |
| 336 | + | |
| 337 | + return $items; | |
| 338 | + | |
| 339 | + } | |
| 340 | + | |
| 341 | + function get_thumbnail_url( $item, $thumbnail_default ){ | |
| 342 | + | |
| 343 | + // Try to get from the item enclosure | |
| 344 | + $enclosure = $item->get_enclosure(); | |
| 345 | + | |
| 346 | + if ( $enclosure->get_thumbnail() ) { | |
| 347 | + return $enclosure->get_thumbnail(); | |
| 348 | + } | |
| 349 | + | |
| 350 | + if ( $enclosure->get_link() ) { | |
| 351 | + return $enclosure->get_link(); | |
| 352 | + } | |
| 353 | + | |
| 354 | + // Try to get from item content | |
| 355 | + $content = $item->get_content(); | |
| 356 | + | |
| 357 | + preg_match_all('~<img.*?src=["\']+(.*?)["\']+~', $content, $urls); | |
| 358 | + $urls = $urls[1]; | |
| 359 | + | |
| 360 | + if( !empty( $urls ) ){ | |
| 361 | + return $urls[0]; | |
| 362 | + } | |
| 363 | + | |
| 364 | + // Try to get the image tag finally if available | |
| 365 | + $image = $item->get_item_tags( '', 'image' ); | |
| 366 | + | |
| 367 | + if( isset( $image[0]['data'] ) ){ | |
| 368 | + return $image[0]['data']; | |
| 369 | + } | |
| 370 | + | |
| 371 | + return trim( $thumbnail_default ); | |
| 236 | 372 | |
| 237 | 373 | } |
| 238 | 374 | |
| 239 | 375 | } |