Plugin Name: Horizontal scrolling announcement
Plugin URI: http://www.gopiplus.com/work/2010/07/18/horizontal-scrolling-announcement/
Description: This horizontal scrolling announcement wordpress plug-in let's scroll the content from one end to another end like reel.
Version: 4.0
Author: Gopi.R
Author URI: http://www.gopiplus.com/work/2010/07/18/horizontal-scrolling-announcement/
Donate link: http://www.gopiplus.com/work/2010/07/18/horizontal-scrolling-announcement/
*/
global $wpdb, $wp_version;
define("WP_HSA_TABLE", $wpdb->prefix . "hsa_plugin");
function horizontal_scrolling_announcement()
{
global $wpdb;
$data = $wpdb->get_results("select hsa_text,hsa_link from ".WP_HSA_TABLE." where hsa_status='YES' ORDER BY hsa_order");
if ( ! empty($data) )
{
$cnt = 0;
foreach ( $data as $data )
{
@$link = $data->hsa_link;
if($cnt==0)
{
// KM 120208 initialize hsa
if (!isset($hsa)) {$hsa = '';}
if($link != "") { $hsa = $hsa . ""; }
$hsa = $hsa . stripslashes($data->hsa_text);
if($link != "") { $hsa = $hsa . ""; }
}
else
{
$hsa = $hsa . " - ";
if($link != "") { $hsa = $hsa . ""; }
$hsa = $hsa . stripslashes($data->hsa_text);
if($link != "") { $hsa = $hsa . ""; }
}
$cnt = $cnt + 1;
}
}
$hsa_title = get_option('hsa_title');
$hsa_scrollamount = get_option('hsa_scrollamount');
$hsa_scrolldelay = get_option('hsa_scrolldelay');
$hsa_direction = get_option('hsa_direction');
$hsa_style = get_option('hsa_style');
// KM 111124 initialize what_marquee
if (!isset($what_marquee)) {$what_marquee = '';}
$what_marquee = $what_marquee . "
";
$what_marquee = $what_marquee . "";
$what_marquee = $what_marquee . "
";
echo $what_marquee;
}
//if (function_exists (horizontal_scrolling_announcement)) horizontal_scrolling_announcement();
add_filter('the_content','HSA_show_filter');
function HSA_show_filter($content)
{
return preg_replace_callback('/\[HORIZONTAL-SCROLLING(.*?)\]/sim','HSA_show_filter_callback',$content);
}
function HSA_show_filter_callback($matches)
{
global $wpdb;
$data = $wpdb->get_results("select hsa_text,hsa_link from ".WP_HSA_TABLE." where hsa_status='YES' ORDER BY hsa_order");
if ( ! empty($data) )
{
$cnt = 0;
foreach ( $data as $data )
{
@$link = $data->hsa_link;
if($cnt==0)
{
if($link != "") { $hsa = $hsa . ""; }
$hsa = $hsa . stripslashes($data->hsa_text);
if($link != "") { $hsa = $hsa . ""; }
}
else
{
$hsa = $hsa . " - ";
if($link != "") { $hsa = $hsa . ""; }
$hsa = $hsa . stripslashes($data->hsa_text);
if($link != "") { $hsa = $hsa . ""; }
}
$cnt = $cnt + 1;
}
}
$hsa_title = get_option('hsa_title');
$hsa_scrollamount = get_option('hsa_scrollamount');
$hsa_scrolldelay = get_option('hsa_scrolldelay');
$hsa_direction = get_option('hsa_direction');
$hsa_style = get_option('hsa_style');
$what_marquee = $what_marquee . "";
$what_marquee = $what_marquee . "";
$what_marquee = $what_marquee . "
";
return $what_marquee;
}
function HSA_deactivate()
{
delete_option('hsa_title');
delete_option('hsa_scrollamount');
delete_option('hsa_scrolldelay');
delete_option('hsa_direction');
delete_option('hsa_style');
}
function HSA_activation()
{
global $wpdb;
if($wpdb->get_var("show tables like '". WP_HSA_TABLE . "'") != WP_HSA_TABLE)
{
$wpdb->query("
CREATE TABLE IF NOT EXISTS `". WP_HSA_TABLE . "` (
`hsa_id` int(11) NOT NULL auto_increment,
`hsa_text` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`hsa_order` int(11) NOT NULL default '0',
`hsa_status` char(3) NOT NULL default 'No',
`hsa_date` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`hsa_id`) )
");
$sSql = "INSERT INTO `". WP_HSA_TABLE . "` (`hsa_text`, `hsa_order`, `hsa_status`, `hsa_date`)";
$sSql = $sSql . "VALUES ('This is sample text for horizontal scrolling announcement.', '1', 'YES', '0000-00-00 00:00:00');";
$wpdb->query($sSql);
}
$sSql = "ALTER TABLE `". WP_HSA_TABLE . "` ADD `hsa_link` VARCHAR( 1024 ) NOT NULL ";
$wpdb->query($sSql);
add_option('hsa_title', "Announcement");
add_option('hsa_scrollamount', "2");
add_option('hsa_scrolldelay', "5");
add_option('hsa_direction', "left");
add_option('hsa_style', "color:#FF0000;font:Arial;");
}
function HSA_admin_options()
{
global $wpdb;
?>
"DEL" and trim($_POST['hsa_text']) <>"")
{
if($_POST['hsa_id'] == "" )
{
$sql = "insert into ".WP_HSA_TABLE.""
. " set `hsa_text` = '" . mysql_real_escape_string(trim($_POST['hsa_text']))
. "', `hsa_order` = '" . $_POST['hsa_order']
. "', `hsa_status` = '" . $_POST['hsa_status']
. "', `hsa_link` = '" . $_POST['hsa_link']
. "'";
}
else
{
$sql = "update ".WP_HSA_TABLE.""
. " set `hsa_text` = '" . mysql_real_escape_string(trim($_POST['hsa_text']))
. "', `hsa_order` = '" . $_POST['hsa_order']
. "', `hsa_status` = '" . $_POST['hsa_status']
. "', `hsa_link` = '" . $_POST['hsa_link']
. "' where `hsa_id` = '" . $_POST['hsa_id']
. "'";
}
$wpdb->get_results($sql);
}
if($AC=="DEL" && $DID > 0)
{
$wpdb->get_results("delete from ".WP_HSA_TABLE." where hsa_id=".$DID);
}
if($DID<>"" and $AC <> "DEL")
{
//select query
$data = $wpdb->get_results("select * from ".WP_HSA_TABLE." where hsa_id=$DID limit 1");
//bad feedback
if ( empty($data) )
{
echo "
No data available! use below form to create!
";
return;
}
$data = $data[0];
//encode strings
if ( !empty($data) ) $hsa_id_x = htmlspecialchars(stripslashes($data->hsa_id));
if ( !empty($data) ) $hsa_text_x = htmlspecialchars(stripslashes($data->hsa_text));
if ( !empty($data) ) $hsa_status_x = htmlspecialchars(stripslashes($data->hsa_status));
if ( !empty($data) ) $hsa_link_x = htmlspecialchars(stripslashes($data->hsa_link));
if ( !empty($data) ) $hsa_order_x = htmlspecialchars(stripslashes($data->hsa_order));
$submittext = "Update Message";
}
?>
"")
{
echo $before_widget . $before_title;
echo get_option('hsa_title');
echo $after_title;
}
else
{
echo "";
}
horizontal_scrolling_announcement();
if($hsa_title <> "")
{
echo $after_widget;
}
else
{
echo "
";
}
}
add_action("plugins_loaded", "HSA_widget_init");
register_activation_hook(__FILE__, 'HSA_activation');
add_action('admin_menu', 'HSA_add_to_menu');
register_deactivation_hook( __FILE__, 'HSA_deactivate' );
add_action('init', 'HSA_widget_init');
?>