PHP Marquee Scrolling Help

Heys Guys!

Looking for help on some PHP code that was written for a WordPress Plugin. The Plugin seems to be unsupported as attempts to contact the original coder (Gopi) have gone unsuccessful.

The link for the Plugin is as follows: https://wordpress.org/plugins/marquee-xml-rss-feed-scroll/ for those who work with WordPress.

The plugin works in part though will only show 1 of the 5 RSS feeds listed. I looked at the PHP code though I am a beginner and can’t quite figure out what would be the issue.

Wondering if those in the know might be able to help me reconfigure the code to make it work. Thanks!!

Code:

<?php /* Plugin Name: Marquee xml rss feed scroll Description: Marquee xml rss feed scroll is a simple wordpress plugin to create the marquee in the website with rss feed. Author: Gopi Ramasamy Version: 6.2 Plugin URI: http://www.gopiplus.com/work/2011/08/10/marquee-xml-rss-feed-scroll-wordpress-scroll/ Author URI: http://www.gopiplus.com/work/2011/08/10/marquee-xml-rss-feed-scroll-wordpress-scroll/ Donate link: http://www.gopiplus.com/work/2011/08/10/marquee-xml-rss-feed-scroll-wordpress-scroll/ License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ function rssshow() { global $wpdb; $mxrf_marquee = ""; $mxrf_scrollamount = get_option('mxrf_scrollamount'); $mxrf_scrolldelay = get_option('mxrf_scrolldelay'); $mxrf_direction = get_option('mxrf_direction'); $mxrf_style = get_option('mxrf_style'); $mxrf_rss1 = get_option('mxrf_rss1'); $mxrf_spliter = get_option('mxrf_spliter'); $mxrf_target = get_option('mxrf_target'); if(!is_numeric($mxrf_scrollamount)){ $mxrf_scrollamount = 2; } if(!is_numeric($mxrf_scrolldelay)){ $mxrf_scrolldelay = 5; } if($mxrf_rss1 <> "") { $url = $mxrf_rss1; } else { $url = "http://www.gopiplus.com/work/feed/"; } $maxitems = 0; $spliter = ""; $mxrf = ""; include_once( ABSPATH . WPINC . '/feed.php' ); $rss = fetch_feed( $url ); if ( ! is_wp_error( $rss ) ) { $cnt = 0; $maxitems = $rss->get_item_quantity( 10 ); $rss_items = $rss->get_items( 0, $maxitems ); if ( $maxitems > 0 ) { foreach ( $rss_items as $item ) { $links = $item->get_permalink(); $title = $item->get_title(); if($cnt > 0) { $spliter = $mxrf_spliter; } $mxrf = $mxrf . $spliter . "" . $title . ""; $cnt = $cnt + 1; } } } $mxrf_marquee = $mxrf_marquee . "
"; $mxrf_marquee = $mxrf_marquee . ""; $mxrf_marquee = $mxrf_marquee . $mxrf; $mxrf_marquee = $mxrf_marquee . ""; $mxrf_marquee = $mxrf_marquee . "
"; echo $mxrf_marquee; } add_shortcode( 'rss-marquee', 'mxrf_shortcode' ); function mxrf_cdata($data) { $data = str_replace('', '', $data); if ( substr($data, -1) == ']' ) { $data .= ' '; } return $data; } function mxrf_shortcode( $atts ) { global $wpdb; //[rss-marquee rssfeed="RSS1"] if ( ! is_array( $atts ) ) { return ''; } $type = $atts['rssfeed']; //@$type = $matches[1]; $mxrf_marquee = ""; $spliter=""; $mxrf=""; $mxrf_scrollamount = get_option('mxrf_scrollamount'); $mxrf_scrolldelay = get_option('mxrf_scrolldelay'); $mxrf_direction = get_option('mxrf_direction'); $mxrf_style = get_option('mxrf_style'); $mxrf_rss1 = get_option('mxrf_rss1'); $mxrf_spliter = get_option('mxrf_spliter'); $mxrf_target = get_option('mxrf_target'); if(!is_numeric($mxrf_scrollamount)){ $mxrf_scrollamount = 2; } if(!is_numeric($mxrf_scrolldelay)){ $mxrf_scrolldelay = 5; } if($type == "RSS1") { $url = get_option('mxrf_rss1'); } elseif($type == "RSS2") { $url = get_option('mxrf_rss2'); } elseif($type == "RSS3") { $url = get_option('mxrf_rss3'); } elseif($type == "RSS4") { $url = get_option('mxrf_rss4'); } elseif($type == "RSS5") { $url = get_option('mxrf_rss5'); } else { $url = "http://www.gopiplus.com/work/feed/"; } $maxitems = 0; $spliter = ""; $mxrf = ""; include_once( ABSPATH . WPINC . '/feed.php' ); $rss = fetch_feed( $url ); if ( ! is_wp_error( $rss ) ) { $cnt = 0; $maxitems = $rss->get_item_quantity( 10 ); $rss_items = $rss->get_items( 0, $maxitems ); if ( $maxitems > 0 ) { foreach ( $rss_items as $item ) { $links = $item->get_permalink(); $title = $item->get_title(); if($cnt > 0) { $spliter = $mxrf_spliter; } $mxrf = $mxrf . $spliter . "" . $title . ""; $cnt = $cnt + 1; } } } $mxrf_marquee = $mxrf_marquee . "
"; $mxrf_marquee = $mxrf_marquee . ""; $mxrf_marquee = $mxrf_marquee . $mxrf; $mxrf_marquee = $mxrf_marquee . ""; $mxrf_marquee = $mxrf_marquee . "
"; return $mxrf_marquee; } function mxrf_install() { add_option('mxrf_title', "Marquee xml rss feed"); add_option('mxrf_scrollamount', "2"); add_option('mxrf_scrolldelay', "5"); add_option('mxrf_direction', "left"); add_option('mxrf_style', "color:#FF0000;font:Arial;"); add_option('mxrf_rss1', "http://www.gopiplus.com/work/category/word-press-plug-in/feed/"); add_option('mxrf_rss2', "http://www.gopiplus.com/extensions/feed"); add_option('mxrf_rss3', "http://www.gopiplus.com/work/category/word-press-plug-in/feed/"); add_option('mxrf_rss4', "http://www.gopiplus.com/work/category/word-press-plug-in/feed/"); add_option('mxrf_rss5', "http://www.gopiplus.com/work/category/word-press-plug-in/feed/"); add_option('mxrf_spliter', " - "); add_option('mxrf_target', "_blank"); } function mxrf_widget($args) { extract($args); if(get_option('mxrf_title') <> "") { echo $before_widget; echo $before_title; echo get_option('mxrf_title'); echo $after_title; } rssshow(); if(get_option('mxrf_title') <> "") { echo $after_widget; } } function mxrf_control() { echo '

'; _e('Marquee xml rss feed', 'marquee-xml'); echo '. '; _e('Check official website for more information', 'marquee-xml'); ?> <?php _e('click here', 'marquee-xml'); ?>

<?php

}

function mxrf_widget_init()
{
if(function_exists(‘wp_register_sidebar_widget’))
{
wp_register_sidebar_widget(‘marquee-xml-rss-feed’, __(‘Marquee xml rss feed’, ‘marquee-xml’), ‘mxrf_widget’);
}

if(function_exists('wp_register_widget_control')) 
{
	wp_register_widget_control('marquee-xml-rss-feed', array(__('Marquee xml rss feed', 'marquee-xml'), 'widgets'), 'mxrf_control');
} 

}

function mxrf_deactivation()
{
//No action required.
}

function mxrf_option()
{
global $wpdb;
?>






<?php _e('Marquee xml rss feed', 'marquee-xml'); ?>


<?php _e('Plugin setting', 'marquee-xml'); ?>


<?php
$mxrf_title = get_option('mxrf_title');

$mxrf_scrollamount = get_option('mxrf_scrollamount');
$mxrf_scrolldelay = get_option('mxrf_scrolldelay');
$mxrf_direction = get_option('mxrf_direction');
$mxrf_style = get_option('mxrf_style');

$mxrf_rss1 = get_option('mxrf_rss1');
$mxrf_rss2 = get_option('mxrf_rss2');
$mxrf_rss3 = get_option('mxrf_rss3');
$mxrf_rss4 = get_option('mxrf_rss4');
$mxrf_rss5 = get_option('mxrf_rss5');
$mxrf_spliter = get_option('mxrf_spliter');
$mxrf_target = get_option('mxrf_target');

if (isset($_POST['mxrf_submit'])) 
{
	//	Just security thingy that wordpress offers us
	check_admin_referer('mxrf_form_setting');
	
	$mxrf_title = stripslashes($_POST['mxrf_title']);
	
	$mxrf_scrollamount = stripslashes($_POST['mxrf_scrollamount']);
	$mxrf_scrolldelay = stripslashes($_POST['mxrf_scrolldelay']);
	$mxrf_direction = stripslashes($_POST['mxrf_direction']);
	$mxrf_style = stripslashes($_POST['mxrf_style']);
	
	$mxrf_rss1 = stripslashes($_POST['mxrf_rss1']);
	$mxrf_rss2 = stripslashes($_POST['mxrf_rss2']);
	$mxrf_rss3 = stripslashes($_POST['mxrf_rss3']);
	$mxrf_rss4 = stripslashes($_POST['mxrf_rss4']);
	$mxrf_rss5 = stripslashes($_POST['mxrf_rss5']);
	$mxrf_spliter = stripslashes($_POST['mxrf_spliter']);
	$mxrf_target = stripslashes($_POST['mxrf_target']);
	
	update_option('mxrf_title', $mxrf_title );
	
	update_option('mxrf_scrollamount', $mxrf_scrollamount );
	update_option('mxrf_scrolldelay', $mxrf_scrolldelay );
	update_option('mxrf_direction', $mxrf_direction );
	update_option('mxrf_style', $mxrf_style );
	
	update_option('mxrf_rss1', $mxrf_rss1 );
	update_option('mxrf_rss2', $mxrf_rss2 );
	update_option('mxrf_rss3', $mxrf_rss3 );
	update_option('mxrf_rss4', $mxrf_rss4 );
	update_option('mxrf_rss5', $mxrf_rss5 );
	update_option('mxrf_spliter', $mxrf_spliter );
	update_option('mxrf_target', $mxrf_target );
	
	?>
	<div class="updated fade">
		<p><strong><?php _e('Details successfully updated.', 'marquee-xml'); ?></strong></p>
	</div>
	<?php
}

echo '<form name="mxrf_form" method="post" action="">';

echo '<label for="tag-title">'.__('Title :', 'marquee-xml').'</label><input  style="width: 250px;" type="text" value="';
echo $mxrf_title . '" name="mxrf_title" id="mxrf_title" /><p></p>';

echo '<label for="tag-title">'.__('Scroll amount :', 'marquee-xml').'</label><input  style="width: 100px;" type="text" value="';
echo $mxrf_scrollamount . '" name="mxrf_scrollamount" id="mxrf_scrollamount" /><p></p>';

echo '<label for="tag-title">'.__('Scroll delay :', 'marquee-xml').'</label><input  style="width: 100px;" type="text" value="';
echo $mxrf_scrolldelay . '" name="mxrf_scrolldelay" id="mxrf_scrolldelay" /><p></p>';

echo '<label for="tag-title">'.__('Scroll direction :', 'marquee-xml').'</label><input  style="width: 100px;" type="text" value="';
echo $mxrf_direction . '" name="mxrf_direction" id="mxrf_direction" /><p>Enter Left (or) Right</p>';

echo '<label for="tag-title">'.__('Scroll style :', 'marquee-xml').'</label><input  style="width: 250px;" type="text" value="';
echo $mxrf_style . '" name="mxrf_style" id="mxrf_style" /><p></p>';

echo '<label for="tag-title">'.__('Spliter :', 'marquee-xml').'</label><input  style="width: 100px;" type="text" value="';
echo $mxrf_spliter . '" name="mxrf_spliter" id="mxrf_spliter" /><p></p>';

echo '<label for="tag-title">'.__('Target :', 'marquee-xml').'</label><input  style="width: 100px;" type="text" value="';
echo $mxrf_target . '" name="mxrf_target" id="mxrf_target" /> <p> Enter: _blank   (or)   _parent   (or)   _new</p>';

echo '<label for="tag-title">'.__('Rss feed 1 :', 'marquee-xml').'</label><input  style="width: 550px;" type="text" value="';
echo $mxrf_rss1 . '" name="mxrf_rss1" id="mxrf_rss1" /><p>'.__('This is default for widget', 'marquee-xml').', Short Code : [rss-marquee rssfeed="RSS1"] </p>';

echo '<label for="tag-title">'.__('Rss feed 2 :', 'marquee-xml').'</label><input  style="width: 550px;" type="text" value="';
echo $mxrf_rss2 . '" name="mxrf_rss2" id="mxrf_rss2" /><p> Short Code : [rss-marquee rssfeed="RSS2"]</p>';

echo '<label for="tag-title">'.__('Rss feed 3 :', 'marquee-xml').'</label><input  style="width: 550px;" type="text" value="';
echo $mxrf_rss3 . '" name="mxrf_rss3" id="mxrf_rss3" /><p> Short Code : [rss-marquee rssfeed="RSS3"]</p>';

echo '<label for="tag-title">'.__('Rss feed 4 :', 'marquee-xml').'</label><input  style="width: 550px;" type="text" value="';
echo $mxrf_rss4 . '" name="mxrf_rss4" id="mxrf_rss4" /><p> Short Code : [rss-marquee rssfeed="RSS4"]</p>';

echo '<label for="tag-title">'.__('Rss feed 5 :', 'marquee-xml').'</label><input  style="width: 550px;" type="text" value="';
echo $mxrf_rss5 . '" name="mxrf_rss5" id="mxrf_rss5" /><p> Short Code : [rss-marquee rssfeed="RSS5"]</p>';

echo '<input name="mxrf_submit" id="mxrf_submit" lang="publish" class="button-primary" value="'.__('Click to Update', 'marquee-xml').'" type="Submit" />';

wp_nonce_field('mxrf_form_setting');

echo '</form>';
?>
<h2><?php _e('Plugin configuration option', 'marquee-xml'); ?></h2>
<ol>
	<li><?php _e('Drag and drop the widget.', 'marquee-xml'); ?></li>
	<li><?php _e('Add the plugin in the posts or pages using short code.', 'marquee-xml'); ?></li>
	<li><?php _e('Add directly in to the theme using PHP code.', 'marquee-xml'); ?></li>
</ol>
 <?php _e('Check official website for more information', 'marquee-xml'); ?>
<a href="http://www.gopiplus.com/work/2011/08/10/marquee-xml-rss-feed-scroll-wordpress-scroll/" target="_blank"><?php _e('click here', 'marquee-xml'); ?></a>
<?php

}

function mxrf_add_to_menu()
{
add_options_page(__(‘Marquee xml rss feed’, ‘marquee-xml’), __(‘Marquee xml rss feed’, ‘marquee-xml’), ‘manage_options’, FILE, ‘mxrf_option’ );
}

if (is_admin())
{
add_action(‘admin_menu’, ‘mxrf_add_to_menu’);
}

function mxrf_textdomain()
{
load_plugin_textdomain( ‘marquee-xml’, false, dirname( plugin_basename( FILE ) ) . ‘/languages/’ );
}

add_action(‘plugins_loaded’, ‘mxrf_textdomain’);
add_action(“plugins_loaded”, “mxrf_widget_init”);
register_activation_hook(FILE, ‘mxrf_install’);
register_deactivation_hook(FILE, ‘mxrf_deactivation’);
add_action(‘init’, ‘mxrf_widget_init’);
?>

Well, I do not use WordPress, but a quick peek at the code you posted showed that the
maximum number of items is stored in a variable named “$maxitems”. This is currently set
to zero. If set to zero, the code only pulls the first item. You most likely need to set it to 5.
Also note that the items are pulled using the “rss->get_items” routine. This also passes on
and uses the max-items count.

Try that change from zero to five and see if it works as it should. Hope it helps!

Thanks for the quick reply Ernie though that is what I though but tried to set it to 5 and it it still only shows one feed. I can stack the feeds by adding the short code one right after the other but what I am looking for is to show the feeds in a line with a space between each one.

Well, there are two places where the max items can be set. One in the show routine and one in
the shortcode routine. Not sure about it.

On Gobi’s site (gobiplus.com), he mentions that in the Wordpress control panel once you set up
the plugin into Wordpress that you can add up to five RSS feeds. Then, all five are played out in
the marquee. Are these options inside your control panel for the plugin?

Not sure how to help you further without installing Wordpress on one of my servers and trying it
myself… Hope that helps somehow…

Ernie. As you can see in the attachment the functions in the admin panel are limited as to what you can adjust.
What I am trying to accomplish for a client is to create a horizontal marquee scroller that will display multiple aviation METAR weather observations from different airports around Ohio in a straigh line across the screen of thier site. The feed site is http://rss.aviatorjoe.net/2/KOSU.rss the last 4 letters before the .rss is the location identifier of the airport. This plugin I though would do the trick but I can only get one feed to display even though I add in the admin screen 3 other locations. Now as I noted earlier I can use the short code like this:

[rss-marquee rssfeed=“RSS1”][rss-marquee rssfeed=“RSS2”][rss-marquee rssfeed=“RSS3”]

Now it provides the RSS Feeds for each airport but it stacks it like this

[rss-marquee rssfeed=“RSS1”]
[rss-marquee rssfeed=“RSS2”]
[rss-marquee rssfeed=“RSS3”]

I would like it displayed in a single line scrolling across the screen. One observation after another.

Thank for all your help by the way.

Gary


Hmmm… Well, if you are using someone else’s library that allows you to grab the RSS feed and
then display it, it would be for just one RSS feed.

So, to solve this one, you would need to grab the data in the feed(s) and then combine them in
some manner and then display that as a new feed.

There are tons of these listed online. Here is one sample version that seems to be able to do this.
http://creative-software-design-solutions.com/creative-software-design-solutions-marquee-news-ticker-wordpress-plugin/

Ernie. Thnaks for the effort though I looked at the solution you linked. The News Ticker software is a modified version of the software I am using and I tried it with no luck. The feeds do not even display.

Post two or three of your feeds and I will get a sample page working for you.

If the feeds are not public, send them to me by personal message.

It should work as in that link I sent, but, sometimes this can be a little tricky…

Sponsor our Newsletter | Privacy Policy | Terms of Service