| @@ -21,9 +21,8 @@ | ||
| 21 | 21 | $urls = trim( $this->options['urls'] ); |
| 22 | 22 | $tab_titles = $this->options['tab_titles']; |
| 23 | 23 | $count = intval( $this->options['count'] ); |
| 24 | 24 | |
| 25 | - $show_title = intval( $this->options['show_title'] ); | |
| 26 | 25 | $show_date = intval( $this->options['show_date'] ); |
| 27 | 26 | $show_desc = intval( $this->options['show_desc'] ); |
| 28 | 27 | $show_author = intval( $this->options['show_author'] ); |
| 29 | 28 | $show_thumb = intval( $this->options['show_thumb'] ); |
| @@ -30,21 +29,17 @@ | ||
| 30 | 29 | $open_newtab = intval( $this->options['open_newtab'] ); |
| 31 | 30 | $add_nofollow = intval( $this->options['add_nofollow'] ); |
| 32 | 31 | $strip_desc = intval( $this->options['strip_desc'] ); |
| 33 | 32 | $strip_title = intval( $this->options['strip_title'] ); |
| 34 | - $offset = intval( $this->options['offset'] ); | |
| 35 | 33 | $date_format = $this->options['date_format']; |
| 36 | 34 | $date_timezone = $this->options['date_timezone']; |
| 37 | 35 | $order_by = $this->options['order_by']; |
| 38 | 36 | $read_more = $this->options['read_more']; |
| 39 | 37 | $rich_desc = intval( $this->options['rich_desc'] ); |
| 40 | - $link_desc = intval( $this->options['link_desc'] ); | |
| 41 | 38 | $desc_type = $this->options['desc_type']; |
| 42 | 39 | $thumbnail_position = $this->options['thumbnail_position']; |
| 43 | - $thumbnail_crop_position = $this->options['thumbnail_crop_position']; | |
| 44 | 40 | $thumbnail_size = $this->options['thumbnail_size']; |
| 45 | 41 | $thumbnail_default = $this->options['thumbnail_default']; |
| 46 | - $thumbnail_type = $this->options['thumbnail_type']; | |
| 47 | 42 | $no_feed_text = $this->options['no_feed_text']; |
| 48 | 43 | |
| 49 | 44 | $color_theme = $this->options['color_style']; |
| 50 | 45 | $display_type = $this->options['display_type']; |
| @@ -49,16 +44,13 @@ | ||
| 49 | 44 | $color_theme = $this->options['color_style']; |
| 50 | 45 | $display_type = $this->options['display_type']; |
| 51 | 46 | $visible_items = intval( $this->options['visible_items'] ); |
| 52 | 47 | $ticker_speed = intval( $this->options['ticker_speed'] ) * 1000; |
| 53 | - $scroll_height = $this->options['scroll_height']; | |
| 54 | 48 | |
| 55 | 49 | if( empty( $urls ) ){ |
| 56 | 50 | return ''; |
| 57 | 51 | } |
| 58 | 52 | |
| 59 | - $count = ( $offset > 0 ) ? $count + $offset : $count; | |
| 60 | - | |
| 61 | 53 | $url_delim = strpos( $urls, ',' ) !== false ? ',' : "\n"; |
| 62 | 54 | $tab_title_delim = strpos( $tab_titles, ',' ) !== false ? ',' : "\n"; |
| 63 | 55 | |
| 64 | 56 | $urls = explode( $url_delim, $urls ); |
| @@ -70,17 +62,10 @@ | ||
| 70 | 62 | $no_feed_html = '<div>' . wp_kses_post( $no_feed_text ) . '</div>'; |
| 71 | 63 | |
| 72 | 64 | $classes = array( 'srr-wrap', 'srr-style-' . $color_theme ); |
| 73 | 65 | if( $display_type == 'vertical_ticker' ) array_push( $classes, 'srr-vticker' ); |
| 74 | - if( $display_type == 'scroll' ) array_push( $classes, 'srr-scroll' ); | |
| 75 | 66 | $class = implode( ' ', $classes ); |
| 76 | 67 | |
| 77 | - $style = ''; | |
| 78 | - if( $display_type == 'scroll' ){ | |
| 79 | - $style .= '--srr-height: ' . $scroll_height; | |
| 80 | - } | |
| 81 | - if( !empty( $style ) ) $style = 'style="' . esc_attr( $style ) . '"'; | |
| 82 | - | |
| 83 | 68 | // Fetch the feed |
| 84 | 69 | for( $i=0; $i < $url_count; $i++ ){ |
| 85 | 70 | $feed_url = trim( $urls[$i] ); |
| 86 | 71 | |
| @@ -93,9 +78,9 @@ | ||
| 93 | 78 | |
| 94 | 79 | if( is_wp_error( $feed ) ){ |
| 95 | 80 | $feed_title = __( 'Error' ); |
| 96 | 81 | }else{ |
| 97 | - $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : strip_tags( $feed->get_title() ?? '' ); | |
| 82 | + $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : strip_tags( $feed->get_title() ); | |
| 98 | 83 | } |
| 99 | 84 | |
| 100 | 85 | $feeds[ $feed_url ] = array( |
| 101 | 86 | 'id' => rand( 100, 999 ), |
| @@ -135,10 +120,10 @@ | ||
| 135 | 120 | } |
| 136 | 121 | } |
| 137 | 122 | |
| 138 | 123 | // Outer wrap start |
| 139 | - $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 ) . '" ' . $style . '>'; | |
| 140 | - $html .= '<div class="srr-inner">'; | |
| 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 ) . '">'; | |
| 125 | + $html .= '<div>'; | |
| 141 | 126 | |
| 142 | 127 | $max_items = $feed->get_item_quantity(); |
| 143 | 128 | |
| 144 | 129 | // Check feed items |
| @@ -152,14 +137,8 @@ | ||
| 152 | 137 | |
| 153 | 138 | // Loop through each feed item |
| 154 | 139 | foreach( $feed_items as $item ){ |
| 155 | 140 | |
| 156 | - // Offset items | |
| 157 | - if( $j <= $offset ){ | |
| 158 | - $j++; | |
| 159 | - continue; | |
| 160 | - } | |
| 161 | - | |
| 162 | 141 | // Link |
| 163 | 142 | $link = $item->get_link(); |
| 164 | 143 | while ( stristr( $link, 'http' ) != $link ){ $link = substr( $link, 1 ); } |
| 165 | 144 | $link = strip_tags($link); |
| @@ -164,9 +143,9 @@ | ||
| 164 | 143 | while ( stristr( $link, 'http' ) != $link ){ $link = substr( $link, 1 ); } |
| 165 | 144 | $link = strip_tags($link); |
| 166 | 145 | |
| 167 | 146 | // Title |
| 168 | - $title = strip_tags( $item->get_title() ?? '' ); | |
| 147 | + $title = strip_tags( $item->get_title() ); | |
| 169 | 148 | $title_full = $title; |
| 170 | 149 | |
| 171 | 150 | if ( empty( $title ) ){ |
| 172 | 151 | $title = __( 'No Title', 'super-rss-reader' ); |
| @@ -188,16 +167,16 @@ | ||
| 188 | 167 | } |
| 189 | 168 | |
| 190 | 169 | // Date |
| 191 | 170 | $date = ''; |
| 192 | - $date_full = strip_tags( $item->get_date() ?? '' ); | |
| 171 | + $date_full = strip_tags( $item->get_date() ); | |
| 193 | 172 | |
| 194 | 173 | if( strtolower( $date_format ) == 'relative' ){ |
| 195 | 174 | $item_date = $item->get_date( 'U' ); |
| 196 | 175 | if( $item_date ){ |
| 197 | - $date = human_time_diff( $item_date, current_time( 'U' ) ) . ' ' . __( 'ago', 'super-rss-reader' ); | |
| 176 | + $date = human_time_diff( $item_date, current_time( 'U' ) ) . ' ' . __( 'ago' ); | |
| 198 | 177 | }else{ |
| 199 | - $date = __( 'Today', 'super-rss-reader' ); | |
| 178 | + $date = __( 'Today' ); | |
| 200 | 179 | } |
| 201 | 180 | }else{ |
| 202 | 181 | $date = SRR_Utilities::date_i18n( $date_format, $item->get_date( 'U' ), $date_timezone ); |
| 203 | 182 | } |
| @@ -204,34 +183,14 @@ | ||
| 204 | 183 | |
| 205 | 184 | // Thumbnail |
| 206 | 185 | $thumb = ''; |
| 207 | 186 | if ( $show_thumb == 1 ){ |
| 208 | - $thumb_url = $this->get_thumbnail_url( $item, $thumbnail_default, $thumbnail_type ); | |
| 209 | - $thumb_url = apply_filters( 'srr_mod_thumbnail_url', $thumb_url, $item, $feed, $thumbnail_default, $thumbnail_type ); | |
| 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 ); | |
| 210 | 189 | if( !empty( $thumb_url ) ){ |
| 211 | - if( strpos( $thumbnail_size, ',' ) ){ | |
| 212 | - $thumb_size_split = explode( ',', $thumbnail_size ); | |
| 213 | - $thumb_width = $thumb_size_split[0]; | |
| 214 | - $thumb_height = $thumb_size_split[1]; | |
| 215 | - }else{ | |
| 216 | - $thumb_width = $thumb_height = $thumbnail_size; | |
| 217 | - } | |
| 218 | - $crop_positions = array( | |
| 219 | - 'center' => 'center center', | |
| 220 | - 'top' => 'center top', | |
| 221 | - 'bottom' => 'center bottom', | |
| 222 | - 'left' => 'left center', | |
| 223 | - 'right' => 'right center', | |
| 224 | - 'top_left' => 'left top', | |
| 225 | - 'top_right' => 'right top', | |
| 226 | - 'bottom_left' => 'left bottom', | |
| 227 | - 'bottom_right' => 'right bottom', | |
| 228 | - ); | |
| 229 | - $thumb_crop_position = array_key_exists( $thumbnail_crop_position, $crop_positions ) ? $thumbnail_crop_position : 'center'; | |
| 230 | 190 | $thumb_styles = array( |
| 231 | - 'width' => $thumb_width, | |
| 232 | - 'height' => $thumb_height, | |
| 233 | - '--srr-thumb-position' => $crop_positions[ $thumb_crop_position ] | |
| 191 | + 'width' => $thumbnail_size, | |
| 192 | + 'height' => $thumbnail_size | |
| 234 | 193 | ); |
| 235 | 194 | $thumb_style = ''; |
| 236 | 195 | foreach( $thumb_styles as $prop => $val ){ |
| 237 | 196 | $thumb_style .= "$prop:$val;"; |
| @@ -242,11 +201,11 @@ | ||
| 242 | 201 | |
| 243 | 202 | // Description |
| 244 | 203 | $desc = ''; |
| 245 | 204 | if( $show_desc ){ |
| 246 | - $desc_content = ( $desc_type == 'summary' ) ? ( $item->get_description() ?? '') : ( $item->get_content() ?? '' ); | |
| 205 | + $desc_content = ( $desc_type == 'summary' ) ? $item->get_description() : $item->get_content(); | |
| 247 | 206 | if( $rich_desc ){ |
| 248 | - $desc = wp_kses_post( strip_tags( $desc_content, '<p><a><img><em><strong><font><strike><s><u><b><i><br>' ) ); | |
| 207 | + $desc = wp_kses_post( strip_tags( $desc_content, '<p><a><img><em><strong><font><strike><s><u><i><br>' ) ); | |
| 249 | 208 | }else{ |
| 250 | 209 | $desc = str_replace( array( "\n", "\r" ), ' ', strip_tags( @html_entity_decode( $desc_content, ENT_QUOTES, get_option('blog_charset') ) ) ); |
| 251 | 210 | |
| 252 | 211 | if( $strip_desc != 0 ){ |
| @@ -252,12 +211,8 @@ | ||
| 252 | 211 | if( $strip_desc != 0 ){ |
| 253 | 212 | $desc = wp_trim_words( $desc, $strip_desc ); |
| 254 | 213 | if ( '[...]' == substr( $desc, -5 ) ){ |
| 255 | 214 | $desc = substr( $desc, 0, -5 ); |
| 256 | - }else if ( '…' == substr( $desc, -8 ) ){ | |
| 257 | - $desc = substr( $desc, 0, -8 ); | |
| 258 | - }else if ( '...' == substr( $desc, -3 ) ){ | |
| 259 | - $desc = substr( $desc, 0, -3 ); | |
| 260 | 215 | }elseif ( '[…]' != substr( $desc, -10 ) ){ |
| 261 | 216 | $desc .= ''; |
| 262 | 217 | } |
| 263 | 218 | } |
| @@ -263,11 +218,8 @@ | ||
| 263 | 218 | } |
| 264 | 219 | |
| 265 | 220 | $desc = trim( esc_html( $desc ) ); |
| 266 | 221 | if( !empty( $desc ) ){ |
| 267 | - if( $link_desc ){ | |
| 268 | - $desc = '<a href="' . esc_url( $link ) . '"' . $new_tab . $no_follow . ' class="srr-desc-link">' . $desc . '</a>'; | |
| 269 | - } | |
| 270 | 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>' : ''; |
| 271 | 223 | $desc = $desc . $read_more_link; |
| 272 | 224 | } |
| 273 | 225 | |
| @@ -277,9 +229,9 @@ | ||
| 277 | 229 | // Author |
| 278 | 230 | $author = ''; |
| 279 | 231 | if( $show_author ){ |
| 280 | 232 | $author = $item->get_author(); |
| 281 | - if ( is_object( $author ) && $author->get_name() ) { | |
| 233 | + if ( is_object( $author ) ) { | |
| 282 | 234 | $author = strip_tags( $author->get_name() ); |
| 283 | 235 | } |
| 284 | 236 | } |
| 285 | 237 | |
| @@ -287,11 +239,9 @@ | ||
| 287 | 239 | $t_meta = ''; |
| 288 | 240 | $t_thumb = ''; |
| 289 | 241 | $t_desc = ''; |
| 290 | 242 | |
| 291 | - if( $show_title ){ | |
| 292 | - $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>'; | |
| 293 | - } | |
| 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>'; | |
| 294 | 244 | |
| 295 | 245 | // Metadata |
| 296 | 246 | if( $show_date || $show_author ){ |
| 297 | 247 | $t_meta .= '<div class="srr-meta">'; |
| @@ -332,9 +282,9 @@ | ||
| 332 | 282 | $f_after = !isset( $f_data[ 'after' ] ) ? '' : $f_data[ 'after' ]; |
| 333 | 283 | |
| 334 | 284 | // Display the feed items |
| 335 | 285 | $html .= '<div class="srr-item ' . ( ( $j%2 == 0 ) ? 'srr-stripe' : '') . '">'; |
| 336 | - $html .= '<div class="srr-item-in srr-clearfix">'; | |
| 286 | + $html .= '<div class="srr-clearfix">'; | |
| 337 | 287 | $html .= $f_before; |
| 338 | 288 | $html .= $f_title . $f_meta . $f_thumb . $f_desc; |
| 339 | 289 | $html .= $f_after; |
| 340 | 290 | $html .= '</div>'; // End item inner clearfix |
| @@ -376,49 +326,40 @@ | ||
| 376 | 326 | shuffle( $items ); |
| 377 | 327 | return array_slice( $items, 0, $count ); |
| 378 | 328 | } |
| 379 | 329 | |
| 330 | + // For date based order - slice first and then order | |
| 331 | + $items = array_slice( $items, 0, $count ); | |
| 332 | + | |
| 380 | 333 | if( $order_by == 'date_reverse' ){ |
| 381 | 334 | $items = array_reverse( $items ); |
| 382 | 335 | } |
| 383 | 336 | |
| 384 | - // For date based order - slice first and then order | |
| 385 | - $items = array_slice( $items, 0, $count ); | |
| 386 | - | |
| 387 | 337 | return $items; |
| 388 | 338 | |
| 389 | 339 | } |
| 390 | 340 | |
| 391 | - function get_thumbnail_url( $item, $thumbnail_default, $thumbnail_type ){ | |
| 341 | + function get_thumbnail_url( $item, $thumbnail_default ){ | |
| 392 | 342 | |
| 393 | - if ( !is_object( $item ) ) { | |
| 394 | - return trim( $thumbnail_default ); | |
| 395 | - } | |
| 396 | - | |
| 397 | 343 | // Try to get from the item enclosure |
| 398 | 344 | $enclosure = $item->get_enclosure(); |
| 399 | - $enclosure_image = ''; | |
| 400 | 345 | |
| 401 | - if ( is_object( $enclosure ) ) { | |
| 402 | - if ( $enclosure->get_thumbnail() && $enclosure->get_link() ){ | |
| 403 | - $enclosure_image = ( $thumbnail_type == 'thumbnail' ) ? $enclosure->get_thumbnail() : $enclosure->get_link(); | |
| 404 | - } elseif ( $enclosure->get_thumbnail() ) { | |
| 405 | - $enclosure_image = $enclosure->get_thumbnail(); | |
| 406 | - } elseif ( $enclosure->get_link() ) { | |
| 407 | - $enclosure_image = $enclosure->get_link(); | |
| 408 | - } | |
| 346 | + if ( $enclosure->get_thumbnail() ) { | |
| 347 | + return $enclosure->get_thumbnail(); | |
| 348 | + } | |
| 409 | 349 | |
| 410 | - if( $enclosure_image && SRR_Utilities::is_valid_image_url( $item, $enclosure_image ) ){ | |
| 411 | - return trim( $enclosure_image ); | |
| 412 | - } | |
| 350 | + if ( $enclosure->get_link() ) { | |
| 351 | + return $enclosure->get_link(); | |
| 413 | 352 | } |
| 414 | 353 | |
| 415 | 354 | // Try to get from item content |
| 416 | 355 | $content = $item->get_content(); |
| 417 | - $image = SRR_Utilities::parse_image_url( $item, $content ); | |
| 418 | 356 | |
| 419 | - if( !empty( $image ) ){ | |
| 420 | - return trim( $image ); | |
| 357 | + preg_match_all('~<img.*?src=["\']+(.*?)["\']+~', $content, $urls); | |
| 358 | + $urls = $urls[1]; | |
| 359 | + | |
| 360 | + if( !empty( $urls ) ){ | |
| 361 | + return $urls[0]; | |
| 421 | 362 | } |
| 422 | 363 | |
| 423 | 364 | // Try to get the image tag finally if available |
| 424 | 365 | $image = $item->get_item_tags( '', 'image' ); |
| @@ -423,13 +364,14 @@ | ||
| 423 | 364 | // Try to get the image tag finally if available |
| 424 | 365 | $image = $item->get_item_tags( '', 'image' ); |
| 425 | 366 | |
| 426 | 367 | if( isset( $image[0]['data'] ) ){ |
| 427 | - return trim( $image[0]['data'] ); | |
| 368 | + return $image[0]['data']; | |
| 428 | 369 | } |
| 429 | 370 | |
| 430 | 371 | return trim( $thumbnail_default ); |
| 372 | + | |
| 431 | 373 | } |
| 432 | 374 | |
| 433 | 375 | } |
| 434 | 376 | |
| 435 | 377 | ?> |