Visit widget page for more information. Version: 1.04 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; /***************** 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['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'; add_option('wp7feeds_options', $newoptions); } // add the admin page function wp_7feeds_add_pages() { add_options_page('7feeds ticker', '7feeds ticker', 8, __FILE__, 'wp_7feeds_options'); } // 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; 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; } $aTmp = unserialize($options['feed_url']); if (empty($aTmp)) { $options['feed_url'] = ''; } //Check box fields $aF = array('open_new_window','strip_tags','widget_header','news_content','pub_time'); $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; } $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) { $aData = array(); $aData[] = array("feed_title_format"=>"left/arial/14/0xfe9900/b/ni/nu","body_bgcolor"=>"0xffe0b2","footer_bgcolor"=>"0xffe0b2","feed_highlight"=>"0xffefd8","border_color"=>"0xfe9900","footer_feedo_format"=>"left/_sans/11/0xfe9900/nb/ni/nu","feed_back_color"=>"0xfffbf2","feeds_num_color"=>"0xfe9900","buttons_onpress_color"=>"0xfe9900"); $aData[] = array("feed_title_format"=>"left/arial/14/0x6599ff/b/ni/nu","body_bgcolor"=>"0xd1e0ff","footer_bgcolor"=>"0xd1e0ff","feed_highlight"=>"0xe7f0ff","border_color"=>"0x6599ff","footer_feedo_format"=>"left/_sans/11/0x6599ff/nb/ni/nu","feed_back_color"=>"0xf7faff","feeds_num_color"=>"0x6599ff","buttons_onpress_color"=>"0x6599ff"); $aData[] = array("feed_title_format"=>"left/arial/14/0xcccb32/b/ni/nu","body_bgcolor"=>"0xf1f0c2","footer_bgcolor"=>"0xf1f0c2","feed_highlight"=>"0xf7f7df","border_color"=>"0xcccb32","footer_feedo_format"=>"left/_sans/11/0xcccb32/nb/ni/nu","feed_back_color"=>"0xfcfbf6","feeds_num_color"=>"0xcccb32","buttons_onpress_color"=>"0xcccb32"); $aData[] = array("feed_title_format"=>"left/arial/14/0xfe66cb/b/ni/nu","body_bgcolor"=>"0xffd0f0","footer_bgcolor"=>"0xffd0f0","feed_highlight"=>"0xffe8f7","border_color"=>"0xfe66cb","footer_feedo_format"=>"left/_sans/11/0xfe66cb/nb/ni/nu","feed_back_color"=>"0xfff7fc","feeds_num_color"=>"0xfe66cb","buttons_onpress_color"=>"0xfe66cb"); $aData[] = array("feed_title_format"=>"left/arial/14/0x676767/b/ni/nu","body_bgcolor"=>"0xd1d1d1","footer_bgcolor"=>"0xd1d1d1","feed_highlight"=>"0xe7e7e7","border_color"=>"0x676767","footer_feedo_format"=>"left/_sans/11/0x676767/nb/ni/nu","feed_back_color"=>"0xf7f7f7","feeds_num_color"=>"0x676767","buttons_onpress_color"=>"0x676767"); $aData[] = array("feed_title_format"=>"left/arial/14/0x339933/b/ni/nu","body_bgcolor"=>"0xc1e0c1","footer_bgcolor"=>"0xc1e0c1","feed_highlight"=>"0xe0efe0","border_color"=>"0x339933","footer_feedo_format"=>"left/_sans/11/0x339933/nb/ni/nu","feed_back_color"=>"0xf5faf4","feeds_num_color"=>"0x339933","buttons_onpress_color"=>"0x339933"); $aData[] = array("feed_title_format"=>"left/arial/14/0xcd3333/b/ni/nu","body_bgcolor"=>"0xf1c1c1","footer_bgcolor"=>"0xf1c1c1","feed_highlight"=>"0xf8dfdf","border_color"=>"0xcd3333","footer_feedo_format"=>"left/_sans/11/0xcd3333/nb/ni/nu","feed_back_color"=>"0xfdf4f5","feeds_num_color"=>"0xcd3333","buttons_onpress_color"=>"0xcd3333"); $aData[] = array("feed_title_format"=>"left/arial/14/0x9966ff/b/ni/nu","body_bgcolor"=>"0xe1d1ff","footer_bgcolor"=>"0xe1d1ff","feed_highlight"=>"0xefe7ff","border_color"=>"0x9966ff","footer_feedo_format"=>"left/_sans/11/0x9966ff/nb/ni/nu","feed_back_color"=>"0xfaf7ff","feeds_num_color"=>"0x9966ff","buttons_onpress_color"=>"0x9966ff"); $aData[] = array("feed_title_format"=>"left/arial/14/0x66cc68/b/ni/nu","body_bgcolor"=>"0xd1f0d1","footer_bgcolor"=>"0xd1f0d1","feed_highlight"=>"0xe8f7e7","border_color"=>"0x66cc68","footer_feedo_format"=>"left/_sans/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[] = '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['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"])); } // any changes? save! if ( $options != $newoptions ) { $options = $newoptions; update_option('wp7feeds_options', $options); } // options form /*echo '';*/ echo _7feed_get_javaScript(); echo '
'; echo "

Default display options

"; echo ''; // width echo ''; echo ''; // height echo ''; echo ''; // text length echo ''; echo ''; // Scroll Speed echo ''; echo ''; // Number of entries echo ''; echo ''; // Pause time echo ''; echo ''; // Open in new window echo ''; echo ''; // Feed url echo ''; //echo ''; echo ''; // News order echo ''; echo ''; // Select theme echo ''; echo ''; //widget header echo ''; echo ''; //news content echo ''; echo ''; //pub time echo ''; echo ''; // Custom widget title echo ''; echo ''; // Open in new window echo ''; echo ''; // Promote echo ''; echo ''; // end table echo '
Width of the widget Width in pixels
Height of the widget Height in pixels
News item length, chars
Scrolling speed
Number of entries
Pause time
Open links in new windows
Feed\'s URL
'; echo _7feed_multi_fields('feed_url', $options['feed_url'], 'size="60"', 'feed_url_id', false); echo '
News order
Select theme'.wp_7feeds_get_theme_select('theme',$options['theme']).'
Widget header Check to show widget header from RSS feed title
News content Check to show news content (unchecked - headlines only)
Pub time Check to show Pub time of News Item
Custom widget title
Strip tags Check to strip tags
Help to promote 7feeds
'; 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; } //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['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"])); 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') { $options[$key] = ''; } } } $x_size = attribute_escape($options['x_size']); $y_size = attribute_escape($options['y_size']); $summary_length = attribute_escape($options['summary_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']); echo _7feed_get_javaScript(); ?>

id.'feed_url');?>