<?php $strDate = rssmi_get_default_date_format(); $readable = '<div class="rssmi_wrap">'; foreach ($myarray as $items) { $useMediaImage = $items["useMediaImage"]; if ($pag !== 1) { $total = $total + 1; if ($maxperPage > 0 && $total >= $maxperPage) { break; } } $idnum = $idnum + 1; // Today and Earlier Script if ($sortDir == 0 && $todaybefore == 1) { $from = date("d-m-Y", strtotime('now')); $to = date("d-m-Y", $items["mystrdate"]); $nodays = (strtotime($to) - strtotime($from)) / (60 * 60 * 24); if ($nodays == 0) { if ($todayStamp == 0) { $readable .= '<span style="' . $testyle . '">Today</span>'; $todayStamp = 1; } } elseif ($nodays != 0) { if ($todayStamp == 1 || $total == 0) { $readable .= '<span style="' . $testyle . '">Earlier</span>'; $todayStamp = 2; } } } $openWindow = rssmi_lightbox_filter($items["mylink"], $targetWindow);
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { add_action('wp_footer', 'rssmi_footer_scripts'); /* Load the excerpt functions file. */ global $maximgwidth; $maximgwidth = 100; $rssmi_global_options = get_option('rssmi_global_options'); $suppress_warnings = isset($rssmi_global_options['suppress_warnings']) ? $rssmi_global_options['suppress_warnings'] : 0; $strDate = rssmi_get_default_date_format(); require_once WP_RSS_MULTI_INC . 'excerpt_functions.php'; extract($args); $siteurl = get_site_url(); $widget_images_url = $siteurl . '/wp-content/plugins/wp-rss-multi-importer/images'; $title = apply_filters('widget_title', $instance['title']); $count = $instance['numoption']; (array) ($catArray = isset($instance['category']) ? $instance['category'] : null); if (empty($catArray)) { $catArray = array("0"); } if (!isset($instance['category']) || IS_NULL($instance['category'])) { $instance['category'] = array("0"); } $catList = implode(', ', $instance['category']); $sortDir = $instance['checkbox']; $showdate = $instance['showdate']; $showicon = $instance['showicon']; $linktitle = $instance['linktitle']; $showdesc = $instance['showdesc']; $maxposts = $instance['maxposts']; $targetwindow = $instance['targetwindow']; $simplelist = $instance['simplelist']; $showimage = $instance['showimage']; $showsource = $instance['showsource']; $descNum = $instance['descnum']; $strDate = rssmi_get_default_date_format(); global $RSSdefaultImage; $RSSdefaultImage = $instance['rssdefaultimage']; // 0- process normally, 1=use default for category, 2=replace when no image available //$RSSdefaultImage=1; global $isMobileDevice; if (isset($isMobileDevice) && $isMobileDevice == 1) { //open mobile device windows in new tab $targetwindow = 2; } if (!empty($linktitle)) { $title = '<a href="' . $linktitle . '">' . $title . '</a>'; } if ($showicon == 1) { $title = '<img src="' . $widget_images_url . '/rss.png" width="14" height="14" style="border:0;margin-right:5px;">' . $title; } $addmotion = $instance['addmotion']; $background = $instance['background']; if ($addmotion == 1) { add_action('wp_footer', 'widget_footer_scripts'); } if (!function_exists("wprssmi_hourly_feed")) { function wprssmi_hourly_feed() { return 3600; } } add_filter('wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed'); if ($targetwindow == 0) { add_action('wp_footer', 'colorbox_scripts'); // load colorbox only if not indicated as conflict } if (empty($sortDir)) { $sortDir = 0; } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $readable = ''; $options = get_option('rss_import_items', 'option not found'); if (!empty($options)) { // $targetwindow=(isset($options['targetWindow']) ? $options['targetWindow'] : null); } else { // $targetwindow=2; } global $wpdb; $myarray = array(); if ($catList == 0) { $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_url'"; } else { $feedQuery = "SELECT * FROM {$wpdb->posts} as a inner join {$wpdb->postmeta} as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_cat' AND meta_value in ({$catList}) "; } $feed_array = $wpdb->get_results($feedQuery); if (empty($feed_array)) { // return _e("There is a problem - it appears you are using categories and no feeds have been put into those categories.", 'wp-rss-multi-importer'); return; } foreach ($feed_array as $feed) { $feedlimit = 0; $rssmi_cat = get_post_meta($feed->ID, 'rssmi_cat', true); $rssmi_source = get_the_title($feed->ID); $catSourceArray = array("myGroup" => $rssmi_source, "mycatid" => $rssmi_cat); $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM {$wpdb->postmeta} as a inner join {$wpdb->postmeta} as b on a.post_id=b.post_id WHERE a.meta_value ={$feed->ID} and b.meta_key='rssmi_item_date' order by b.meta_value "; if ($sortDir == 0) { $rssmi_sql .= "desc"; } elseif ($sortDir == 1) { $rssmi_sql .= "asc"; } $desc_array = $wpdb->get_results($rssmi_sql); foreach ($desc_array as $arrayItem) { $feedlimit = $feedlimit + 1; if ($feedlimit > $maxposts) { continue; } $post_ID = $arrayItem->post_id; $desc = get_post_meta($post_ID, 'rssmi_item_description', true); $arrayItem = array_merge((array) $desc[0], $catSourceArray); // add the source and category ID if (include_post($rssmi_cat, $arrayItem['mydesc'], $arrayItem['mytitle']) == 0) { continue; } // FILTER array_push($myarray, $arrayItem); //combine into final array } } if (!isset($myarray) || empty($myarray)) { if ($suppress_warnings == 0 && current_user_can('edit_post')) { return _e("There is a problem with the feeds you entered. Go to our <a href='http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/'>support page</a> to see how to solve this.", 'wp-rss-multi-importer'); } return; } global $isMobileDevice; if (isset($isMobileDevice) && $isMobileDevice == 1) { //open mobile device windows in new tab $targetwindow = 2; } //$myarrary sorted by mystrdate foreach ($myarray as $key => $row) { $dates[$key] = $row["mystrdate"]; } //SORT, DEPENDING ON SETTINGS if ($sortDir == 1) { array_multisort($dates, SORT_ASC, $myarray); } else { array_multisort($dates, SORT_DESC, $myarray); } // HOW THE LINK OPENS global $isMobileDevice; if (isset($isMobileDevice) && $isMobileDevice == 1) { //open mobile device windows in new tab $targetwindow = 2; } if ($targetwindow == 0) { $openWindow = 'class="colorbox"'; } elseif ($targetwindow == 1) { $openWindow = 'target=_self'; } else { $openWindow = 'target=_blank'; } $total = -1; if ($simplelist == 1) { echo '<ul class="wprssmi_widget_list">'; foreach ($myarray as $items) { // VIDEO CHECK if ($targetwindow == 0) { $getVideoArray = rssmi_video($items["mylink"]); $openWindow = $getVideoArray[1]; $items["mylink"] = $getVideoArray[0]; } $openWindow = rssmi_lightbox_filter($items["mylink"], $targetwindow); //Lightbox filter $total = $total + 1; if ($count > 0 && $total >= $count) { break; } echo '<li class="title"><a ' . $openWindow . ' href="' . $items["mylink"] . '" ' . ($noFollow == 1 ? 'rel=nofollow' : '') . '>' . $items["mytitle"] . '</a>'; if (!empty($items["mystrdate"]) && $showdate == 1) { echo '<span class="date">' . date_i18n($strDate, $items["mystrdate"]) . '</span>'; } echo '</li>'; } // don't mess with this php code echo '</ul>'; } else { echo ' <div class="news-wrapper" id="newsticker" style="10px;background-color:' . $background . ';">'; echo ' <div class="news-contents">'; foreach ($myarray as $items) { // VIDEO CHECK if ($targetWindow == 0) { $getVideoArray = rssmi_video($items["mylink"], $targetwindow); $openWindow = $getVideoArray[1]; $items["mylink"] = $getVideoArray[0]; } $openWindow = rssmi_lightbox_filter($items["mylink"], $targetwindow); //Lightbox filter $total = $total + 1; if ($count > 0 && $total >= $count) { break; } echo '<div style="top: 101px;margin-left:5px;" class="news">'; if ($showimage == 1 && $addmotion != 1) { echo showexcerpt($items["mydesc"], 0, $openWindow, 0, $items["mylink"], 1, "left", 0, $items["myimage"], $items["mycatid"]); } echo '<div class="rssmi_title_class"><a ' . $openWindow . ' href="' . $items["mylink"] . '" class="news_title">' . $items["mytitle"] . '</a></div>'; if ($showdesc == 1 && $addmotion != 1) { $desc = esc_attr(strip_tags(@html_entity_decode($items["mydesc"], ENT_QUOTES, get_option('blog_charset')))); $desc = str_replace('[...]', '', $desc); $words = explode(" ", trim($desc)); $desc = implode(" ", array_splice($words, 0, $descNum)); $desc .= ' <a ' . $openWindow . ' href="' . $items["mylink"] . '">[…]</a>'; echo $desc . '<br/>'; } if (!empty($items["mystrdate"]) && $showdate == 1) { echo date_i18n($strDate, $items["mystrdate"]) . '<br />'; } if (!empty($items["myGroup"]) && $showsource == 1) { echo '<span class="rssmi_group_style" style="font-style:italic;">' . $items["myGroup"] . '</span>'; } // echo '</p>'; echo '</div>'; } echo '</div></div>'; } echo $after_widget; }