Visit widget page for more information.
Version: 1.05
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['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';
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','pause_time','rounded_corners');
$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 .= '