Visit widget page for more information. Version: 1.10.3 Author: IOIX Ukraine Author URI: http://ioix.com.ua Copyright 2009, IOIX Ukraine This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /***************** DEFINE *****************/ //Get path if(function_exists('plugins_url')){ // 2.6 or better $movie = plugins_url('7feeds-news-ticker/rssinformer.swf'); $path = plugins_url('7feeds-news-ticker/'); } else { // pre 2.6 $movie = get_bloginfo('wpurl') . "/wp-content/plugins/7feeds-news-ticker/rssinformer.swf"; $path = get_bloginfo('wpurl')."/wp-content/plugins/7feeds-news-ticker/"; } define('_7FEEDS_PATH', $path); define('_7FEEDS_MOVIE_PATH', $movie); $GLOBALS['7FEEDS_ACTIVE'] = true; $gaFONTS = array('Default','Arial','Courier','Simsun','Tahoma','Times new roman','Verdana'); /***************** DEFINE *****************/ _7feed_check_extensions(); function _7feed_check_extensions($main=true) { $GLOBALS['_7feeds_error_message'] = ''; $show = false; if (!extension_loaded('curl') || !extension_loaded('mbstring')) { if ($main) { $GLOBALS['_7feeds_error_message'] = '7feeds warning: Server misconfiguration detected. Proceed to configuration page | Dismiss'; $show = true; }else { $aErr[] = 'cURL (false':'#00FF00">true').')'; $aErr[] = 'MBString (false':'#00FF00">true').')'; if (!empty($aErr)) { $GLOBALS['_7feeds_error_message'] = 'For correct functioning "7feeds" plugin requires following PHP Extensions:'; foreach ($aErr as $key=>$val) { $GLOBALS['_7feeds_error_message'] .= '
'.($key+1).') '.$val; } $GLOBALS['_7feeds_error_message'] .= '
If you don\'t understand what it means, please contact your server administrator or hosting provider support staff and show then this error message!'; } return $GLOBALS['_7feeds_error_message']; } } if ($show) { $GLOBALS['7FEEDS_ACTIVE'] = false; function _7feed_warning() { echo "

". __($GLOBALS['_7feeds_error_message']). "

"; } add_action('admin_notices', '_7feed_warning'); return; } } //initially set the options function wp_7feeds_install () { $newoptions = get_option('wp7feeds_options'); $newoptions['x_size'] = '180'; $newoptions['y_size'] = '320'; $newoptions['summary_length'] = '300'; $newoptions['title_length'] = '100'; $newoptions['scroll_speed'] = '50'; $newoptions['num_of_entries'] = '5'; $newoptions['pause_time'] = '3000'; $newoptions['open_new_window'] = '1'; $newoptions['feed_url'] = 'http://news.bbc.co.uk/'; $newoptions['strip_tags'] = '0'; $newoptions['theme'] = '0'; $newoptions['widget_header'] = '1'; $newoptions['news_content'] = '1'; $newoptions['pub_time'] = '1'; $newoptions['widget_title'] = ''; $newoptions['widget_promote'] = '1'; $newoptions['rounded_corners'] = '1'; $newoptions['date_format'] = ''; $newoptions['news_filter'] = ''; $newoptions['news_filter_type'] = 0; $newoptions['news_filter_condition'] = 0; $newoptions['widget_font'] = 0; add_option('wp7feeds_options', $newoptions); } // add the admin page function wp_7feeds_add_pages() { $page=add_options_page('7feeds ticker', '7feeds ticker', 8, __FILE__, 'wp_7feeds_options'); add_action('admin_head', 'wp_7feeds_admin_head'); add_action('admin_print_scripts-' . $page, 'wp_7feeds_admin_scripts'); } // replace tag in content with tag cloud (non-shortcode version for WP 2.3.x) function wp_7feeds_init($content){ if( strpos($content, '[WP-7feeds]') === false ){ return $content; } else { $code = wp_7feeds_createflashcode(false); $content = str_replace( '[WP-7feeds]', $code, $content ); return $content; } } // template function function wp_7feeds_insert( $atts=NULL ){ echo wp_7feeds_createflashcode( false, $atts ); } // shortcode function function wp_7feeds_shortcode( $atts=NULL ){ return wp_7feeds_createflashcode( false, $atts ); } // piece together the flash code function wp_7feeds_createflashcode( $widget=false, $atts=NULL, $widget_options = array(), $widgetId = '' ){ static $aWidgetIds; global $gaFONTS; if ($GLOBALS['7FEEDS_ACTIVE'] === false) { return ''; } if (!isset($aWidgetIds)) { $aWidgetIds = array(); } //Gen id while (true) { srand(time()); $num = rand(1,1000000); if (!in_array($num, $aWidgetIds)) { break; } } $aWidgetIds[] = $num; //Get options if ($widget && !empty($widget_options)) { $options = $widget_options; }elseif (!$widget && !empty($atts)) { $options = $atts; } if (!is_array($options['feed_url']) && unserialize($options['feed_url']) !== false) { $aTmp = unserialize($options['feed_url']); if (empty($aTmp)) { $options['feed_url'] = ''; } }elseif (is_array($options['feed_url'])) { $options['feed_url'] = serialize($options['feed_url']); }else { $options['feed_url'] = serialize(array($options['feed_url'])); } //Check box fields $aF = array('open_new_window','strip_tags','widget_header','news_content','pub_time','pause_time','rounded_corners'); if (isset($options['widget_promote'])) { unset($options['widget_promote']); } if (!$widget) { foreach ($aF as $key=>$val) { if (!isset($options[$val])) { unset($aF[$key]); } } sort($aF); } $atOptions = get_option('wp7feeds_options'); foreach ($atOptions as $key=>$val) { if (empty($options[$key])) { if (!in_array($key,$aF)) { $options[$key] = ''; }else { $options[$key] = (int)$options[$key]; } } if (!isset($options[$key]) || $options[$key] === '') { $options[$key] = $val; } } $aTmp = unserialize($options['feed_url']); if (!empty($widgetId) && is_array($aTmp) && !empty($aTmp)) { $options['feed_url'] = $widgetId; }elseif (is_array($aTmp) && !empty($aTmp)) { $options['feed_url'] = $aTmp[0]; } $font = strtolower($gaFONTS[(int)$options['widget_font']]); $flashCode = ''; $flashCode .= '
'; $flashCode .= ''; $flashCode .= ''; if (isset($options['widget_promote']) && $options['widget_promote']) { $flashCode .= '
Powered by 7feeds
'; } return $flashCode; } //Get theme color function wp_7feeds_get_theme_color($index, $key, $hex=0, $font = 'arial') { $aData = array(); //Default $aData[] = array("feed_title_format"=>"left/".$font."/14/0xfe9900/b/ni/nu","body_bgcolor"=>"0xffe0b2","footer_bgcolor"=>"0xffe0b2","feed_highlight"=>"0xffefd8","border_color"=>"0xfe9900","footer_feedo_format"=>"left/".$font."/11/0xfe9900/nb/ni/nu","feed_back_color"=>"0xfffbf2","feeds_num_color"=>"0xfe9900","buttons_onpress_color"=>"0xfe9900"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0xfe9900/b/ni/nu","body_bgcolor"=>"0xffe0b2","footer_bgcolor"=>"0xffe0b2","feed_highlight"=>"0xffefd8","border_color"=>"0xfe9900","footer_feedo_format"=>"left/".$font."/11/0xfe9900/nb/ni/nu","feed_back_color"=>"0xfffbf2","feeds_num_color"=>"0xfe9900","buttons_onpress_color"=>"0xfe9900"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0x6599ff/b/ni/nu","body_bgcolor"=>"0xd1e0ff","footer_bgcolor"=>"0xd1e0ff","feed_highlight"=>"0xe7f0ff","border_color"=>"0x6599ff","footer_feedo_format"=>"left/".$font."/11/0x6599ff/nb/ni/nu","feed_back_color"=>"0xf7faff","feeds_num_color"=>"0x6599ff","buttons_onpress_color"=>"0x6599ff"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0xcccb32/b/ni/nu","body_bgcolor"=>"0xf1f0c2","footer_bgcolor"=>"0xf1f0c2","feed_highlight"=>"0xf7f7df","border_color"=>"0xcccb32","footer_feedo_format"=>"left/".$font."/11/0xcccb32/nb/ni/nu","feed_back_color"=>"0xfcfbf6","feeds_num_color"=>"0xcccb32","buttons_onpress_color"=>"0xcccb32"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0xfe66cb/b/ni/nu","body_bgcolor"=>"0xffd0f0","footer_bgcolor"=>"0xffd0f0","feed_highlight"=>"0xffe8f7","border_color"=>"0xfe66cb","footer_feedo_format"=>"left/".$font."/11/0xfe66cb/nb/ni/nu","feed_back_color"=>"0xfff7fc","feeds_num_color"=>"0xfe66cb","buttons_onpress_color"=>"0xfe66cb"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0x676767/b/ni/nu","body_bgcolor"=>"0xd1d1d1","footer_bgcolor"=>"0xd1d1d1","feed_highlight"=>"0xe7e7e7","border_color"=>"0x676767","footer_feedo_format"=>"left/".$font."/11/0x676767/nb/ni/nu","feed_back_color"=>"0xf7f7f7","feeds_num_color"=>"0x676767","buttons_onpress_color"=>"0x676767"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0x339933/b/ni/nu","body_bgcolor"=>"0xc1e0c1","footer_bgcolor"=>"0xc1e0c1","feed_highlight"=>"0xe0efe0","border_color"=>"0x339933","footer_feedo_format"=>"left/".$font."/11/0x339933/nb/ni/nu","feed_back_color"=>"0xf5faf4","feeds_num_color"=>"0x339933","buttons_onpress_color"=>"0x339933"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0xcd3333/b/ni/nu","body_bgcolor"=>"0xf1c1c1","footer_bgcolor"=>"0xf1c1c1","feed_highlight"=>"0xf8dfdf","border_color"=>"0xcd3333","footer_feedo_format"=>"left/".$font."/11/0xcd3333/nb/ni/nu","feed_back_color"=>"0xfdf4f5","feeds_num_color"=>"0xcd3333","buttons_onpress_color"=>"0xcd3333"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0x9966ff/b/ni/nu","body_bgcolor"=>"0xe1d1ff","footer_bgcolor"=>"0xe1d1ff","feed_highlight"=>"0xefe7ff","border_color"=>"0x9966ff","footer_feedo_format"=>"left/".$font."/11/0x9966ff/nb/ni/nu","feed_back_color"=>"0xfaf7ff","feeds_num_color"=>"0x9966ff","buttons_onpress_color"=>"0x9966ff"); $aData[] = array("feed_title_format"=>"left/".$font."/14/0x66cc68/b/ni/nu","body_bgcolor"=>"0xd1f0d1","footer_bgcolor"=>"0xd1f0d1","feed_highlight"=>"0xe8f7e7","border_color"=>"0x66cc68","footer_feedo_format"=>"left/".$font."/11/0x66cc68/nb/ni/nu","feed_back_color"=>"0xf7fcf6","feeds_num_color"=>"0x66cc68","buttons_onpress_color"=>"0x66cc68"); $ret = isset($aData[$index][$key])?$aData[$index][$key]:$aData[0][$key]; if ($hex) { $ret = str_replace('0x','#',$ret); } return $ret; } //Get theme select function wp_7feeds_get_theme_select($name, $val) { $aData = array(); $aData[] = 'Default'; $aData[] = 'Active Orange'; $aData[] = 'Sky Blue'; $aData[] = 'Hot Mustard'; $aData[] = 'Teen Pink'; $aData[] = 'Just Grey'; $aData[] = 'Deep Green'; $aData[] = 'Sweet Cherry'; $aData[] = 'Modern Violet'; $aData[] = 'Spring Fresh'; $options = ''; for ($i=0;$i'.$aData[$i].''; } return ''; } // options page function wp_7feeds_options() { if ($GLOBALS['7FEEDS_ACTIVE'] === false) { echo '

'._7feed_check_extensions(false).'

'; exit; } $options = $newoptions = get_option('wp7feeds_options'); // if submitted, process results if ( $_POST["wp7feeds_submit"] ) { $newoptions['x_size'] = strip_tags(stripslashes($_POST["x_size"])); $newoptions['y_size'] = strip_tags(stripslashes($_POST["y_size"])); $newoptions['summary_length'] = strip_tags(stripslashes($_POST["summary_length"])); $newoptions['title_length'] = strip_tags(stripslashes($_POST["title_length"])); $newoptions['scroll_speed'] = strip_tags(stripslashes($_POST["scroll_speed"])); $newoptions['num_of_entries'] = strip_tags(stripslashes($_POST["num_of_entries"])); $newoptions['pause_time'] = strip_tags(stripslashes($_POST["pause_time"])); $newoptions['open_new_window'] = strip_tags(stripslashes($_POST["open_new_window"])); if (is_array($_POST["feed_url"])) { $aTmp = array(); foreach ($_POST["feed_url"] as $val) { if (empty($val)) continue; $aTmp[] = strip_tags(stripslashes($val)); } $newoptions['feed_url'] = serialize($aTmp); }else { $newoptions['feed_url'] = strip_tags(stripslashes($_POST["feed_url"])); } $newoptions['news_order'] = strip_tags(stripslashes($_POST["news_order"])); $newoptions['strip_tags'] = strip_tags(stripslashes($_POST["strip_tags"])); $newoptions['theme'] = strip_tags(stripslashes($_POST["theme"])); $newoptions['widget_header'] = strip_tags(stripslashes($_POST["widget_header"])); $newoptions['news_content'] = strip_tags(stripslashes($_POST["news_content"])); $newoptions['pub_time'] = strip_tags(stripslashes($_POST["pub_time"])); $newoptions['widget_title'] = strip_tags(stripslashes($_POST["widget_title"])); $newoptions['widget_promote'] = strip_tags(stripslashes($_POST["widget_promote"])); $newoptions['rounded_corners'] = $_POST["rounded_corners"]; $newoptions['date_format'] = strip_tags(stripslashes($_POST["date_format"])); $newoptions['news_filter'] = strip_tags(stripslashes($_POST["news_filter"])); $newoptions['news_filter_type'] = (int)$_POST["news_filter_type"]; $newoptions['news_filter_condition'] = (int)$_POST["news_filter_condition"]; $newoptions['widget_font'] = (int)$_POST["widget_font"]; } // any changes? save! if ( $options != $newoptions ) { $options = $newoptions; update_option('wp7feeds_options', $options); } // options form echo _7feed_get_javaScript(); if (isset($_POST['wp7feeds_submit'])) { echo '

7feeds: Settings updated!

'; } echo '
'; echo "

Default display options

"; ?> You can use wp shortcodes [wp-7feeds]. Click here to show shortcode parameters >>
'; //Widget settings echo '
'; // Select theme echo ''; echo ''; // width echo ''; echo ''; // height echo ''; echo ''; // Corners echo ''; echo ''; //Widget font echo ''; echo ''; // Help to promote echo ''; echo ''; echo '
Select theme'.wp_7feeds_get_theme_select('theme',$options['theme']).'
Width of the widget Width in pixels
Height of the widget Height in pixels
Rounded corners
Widget font'.wp_7feeds_font_select('widget_font', $newoptions['widget_font']).'
Help to promote 7feeds
'; //Items settings echo '
'; // News order echo ''; echo ''; // Number of entries echo ''; echo ''; // title length echo ''; echo ''; // text length echo ''; echo ''; // Scroll Speed echo ''; echo ''; // Pause time echo ''; echo ''; //Widget header echo ''; echo ''; // Custom widget title echo ''; echo ''; //News content echo ''; echo ''; //pub time echo ''; echo ''; // Custom date format if (empty($options['date_format'])) { $options['date_format'] = 'l, d F, Y H:i'; } echo ''; echo ''; // Strip tags echo ''; echo ''; // Open in new window echo ''; echo ''; echo '
News order
Number of entries
News title length, chars
News content length, chars
Scrolling speed
Pause time Set 0 to disable pausing
Widget header Check to show widget header from RSS feed title
Custom widget title
News content Check to show news content (unchecked - headlines only)
Pub time Check to show Pub time of News Item
Custom date format
Example:
Y/m/d H:i:s ('.date('Y/m/d H:i:s').')
l, d F, Y H:i ('.date('l, d F, Y H:i').')
For more information of valid format of the outputted date/time check PHP documentation.
Strip tags Check to strip tags
Open links in new windows
'; //Content echo '
'; // Feed url echo ''; //echo ''; echo ''; // News filter echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Feed\'s URL
'; echo _7feed_multi_fields('feed_url', $options['feed_url'], 'size="60"', 'feed_url_id', false); echo '
Filter type
Filter condition
News filter
For enter several words, separate they with coma
'; // end table echo ''; echo ''; echo '

'; echo "
"; echo '
'; } function _7feed_get_javaScript() { $cnt = ''; $cnt .= ''; return $cnt; } function _7feed_multi_fields($name, $value, $action, $id, $br=true) { $aTmp = array(); if (!empty($value)) { $aTmp = unserialize($value); } if (empty($aTmp) && !is_array($aTmp)){ $aTmp[] = $value; }elseif (empty($aTmp)) { $aTmp[] = ''; } $cnt = ''; $i=0; $c = count($aTmp); for ($i=0; $i<$c; $i++) { if ($i == 0) { $el_id = $id; //$action .= ' id="'.$id.'"'; }else { $el_id = $id.'_'.$i; //$action .= ' id="'.$id.'_'.'"'; } if ($br) { $cnt .= '
'; } $br = true; $cnt .= ''.($i > 0?' X':''); } //Add link $cnt .= '
Add more feeds'; return $cnt; } function wp_7feeds_font_select($name, $sel) { global $gaFONTS; $str = ''; } //uninstall all options function wp_7feeds_uninstall () { //delete_option('wp7feeds_options'); //delete_option('widget_7feeds-widget'); } // widget /*** CLASS ***/ ### Class: WP-7feeds ticket class WP_Widget_7feeds extends WP_Widget { // Constructor function WP_Widget_7feeds() { $widget_ops = array('description' => __('Customized RSS news ticker/scroller for sidebar', 'wp-7feeds')); $this->WP_Widget('7feeds-widget', __('7feeds', 'wp-7feeds'), $widget_ops); } // Display Widget function widget($args, $options) { extract($args); echo $before_widget; if( !empty($options['title']) ):echo $before_title . $options['title'] . $after_title; endif; if( !stristr( $_SERVER['PHP_SELF'], 'widgets.php' ) ){ echo wp_7feeds_createflashcode(true, NULL, $options, $this->number); } echo $after_widget; } // When Widget Control Form Is Posted function update($new_instance, $newoptions) { if (!isset($_POST['wp7feeds_widget_submit'])) { return false; } $newoptions['x_size'] = strip_tags(stripslashes($_POST["wp7feeds_widget_x_size"])); $newoptions['y_size'] = strip_tags(stripslashes($_POST["wp7feeds_widget_y_size"])); $newoptions['summary_length'] = strip_tags(stripslashes($_POST["wp7feeds_widget_summary_length"])); $newoptions['title_length'] = strip_tags(stripslashes($_POST["wp7feeds_widget_title_length"])); $newoptions['scroll_speed'] = strip_tags(stripslashes($_POST["wp7feeds_widget_scroll_speed"])); $newoptions['num_of_entries'] = strip_tags(stripslashes($_POST["wp7feeds_widget_num_of_entries"])); $newoptions['pause_time'] = strip_tags(stripslashes($_POST["wp7feeds_widget_pause_time"])); $newoptions['open_new_window'] = strip_tags(stripslashes($_POST["wp7feeds_widget_open_new_window"])); //$newoptions['feed_url'] = strip_tags(stripslashes($_POST["wp7feeds_widget_feed_url"])); if (is_array($_POST["wp7feeds_widget_feed_url"])) { $aTmp = array(); foreach ($_POST["wp7feeds_widget_feed_url"] as $val) { if (empty($val)) continue; $aTmp[] = strip_tags(stripslashes($val)); } $newoptions['feed_url'] = serialize($aTmp); }else { $newoptions['feed_url'] = strip_tags(stripslashes($_POST["wp7feeds_widget_feed_url"])); } $newoptions['news_order'] = strip_tags(stripslashes($_POST["wp7feeds_widget_news_order"])); $newoptions['strip_tags'] = strip_tags(stripslashes($_POST["wp7feeds_widget_strip_tags"])); $newoptions['theme'] = strip_tags(stripslashes($_POST["wp7feeds_theme"])); $newoptions['widget_header'] = strip_tags(stripslashes($_POST["wp7feeds_widget_header"])); $newoptions['news_content'] = strip_tags(stripslashes($_POST["wp7feeds_news_content"])); $newoptions['pub_time'] = strip_tags(stripslashes($_POST["wp7feeds_pub_time"])); $newoptions['widget_title'] = strip_tags(stripslashes($_POST["wp7feeds_widget_title"])); $newoptions['rounded_corners'] = strip_tags(stripslashes($_POST["wp7feeds_rounded_corners"])); $newoptions['title'] = strip_tags(stripslashes($_POST["wp7feeds_title"])); $newoptions['news_filter'] = strip_tags(stripslashes($_POST["wp7feeds_news_filter"])); $newoptions['news_filter_type'] = (int)$_POST["wp7feeds_news_filter_type"]; $newoptions['news_filter_condition'] = (int)$_POST["wp7feeds_news_filter_condition"]; $newoptions['widget_font'] = (int)$_POST["wp7feeds_widget_font"]; return $newoptions; } // DIsplay Widget Control Form function form($options) { if (empty($options)) { $options = get_option('wp7feeds_options'); foreach ($options as $key=>$val) { if ($val != '1' && $val != '0' && !is_numeric($val)) { $options[$key] = ''; } } } $x_size = attribute_escape($options['x_size']); $y_size = attribute_escape($options['y_size']); $summary_length = attribute_escape($options['summary_length']); $title_length = attribute_escape($options['title_length']); $scroll_speed = attribute_escape($options['scroll_speed']); $num_of_entries = attribute_escape($options['num_of_entries']); $pause_time = attribute_escape($options['pause_time']); $open_new_window = attribute_escape($options['open_new_window']); //$feed_url = attribute_escape($options['feed_url']); $feed_url = $options['feed_url']; $news_order = attribute_escape($options['news_order']); $strip_tags = attribute_escape($options['strip_tags']); $theme = attribute_escape($options['theme']); $widget_header = attribute_escape($options['widget_header']); $news_content = attribute_escape($options['news_content']); $pub_time = attribute_escape($options['pub_time']); $widget_title = attribute_escape($options['widget_title']); $rounded_corners = attribute_escape($options['rounded_corners']); $title = attribute_escape($options['title']); $news_filter = $options['news_filter']; $news_filter_type = $options['news_filter_type']; $news_filter_condition = $options['news_filter_condition']; $widget_font = $options['widget_font']; echo _7feed_get_javaScript(); ?>

id.'feed_url');?>

"; } function wp_7feeds_admin_scripts() { wp_enqueue_script('7feeds_ticker'); } /*** CLASS ***/ // add the actions add_action('admin_menu', 'wp_7feeds_add_pages'); register_activation_hook( __FILE__, 'wp_7feeds_install' ); register_deactivation_hook( __FILE__, 'wp_7feeds_uninstall' ); if( function_exists('add_shortcode') ){ add_shortcode('wp-7feeds', 'wp_7feeds_shortcode'); add_shortcode('WP-7feeds', 'wp_7feeds_shortcode'); } else { add_filter('the_content','wp_7feeds_init'); } ?>