<?php
/*
Plugin Name: Latest News
Description: This is simple plugin to manage latest news and events. The posts that you add under “Latest News” category,will be displayed in the widget.
Author: Mary Suni S
Version: 1.0
*/
?>
<?php
function get_LatestNews()
{
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$current_year = date(‘Y’);
$args = array(‘cat’=>3,’posts_per_page’=>5,’paged’=>$paged, ‘orderby’ => $current_year);
query_posts($args);

?>
<div class=”birthday”>
<div class=”widget_inner”>
<marquee behavior=”scroll” direction=”up” onmouseover=”stop();” onmouseout=”start();” scrollamount=”2″ scrolldelay=”50″ truespeed=”true” class=”mar” >
<?php
while (have_posts()) :
the_post();
?>
<ul style=”list-style-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/4621/treehouse-marker.png); font-size:15px;text-indent:0px;line-height:100%;color:#000;margin-left: 10px;”>
<li>
<a href=”<?php the_permalink();?>”><?php //echo get_the_date(‘d-M’);?><?php the_title(); ?></a></li>
</ul>

<?php endwhile; ?></marquee>

</div>
</div>
<?php

$args = array(‘cat’=>3 ,’paged’=>$paged, ‘orderby’ => $current_month );
$posts = query_posts($args);
$posts_count = count($posts);
if($posts_count > 3) :?>
<div>&nbsp;&nbsp;&nbsp;&nbsp;<a href=”<?php echo bloginfo(‘url’);?>?cat=3/” title=”Full News Listing”>Full News Listing</a></div>
<?php endif; ?>

<?php }

function LatestNews()
{
//extract($args);
$options = get_option(“LatestNews”);

echo $before_widget;
echo $before_title;
//echo $options[‘title’];
echo $after_title;

//Our Widget Content
get_LatestNews();
echo $after_widget;
}

function LatestNews_control()
{
$options = get_option(“LatestNews”);

if($_POST[‘LatestNews-Submit’])
{
$options[‘title’] = htmlspecialchars($_POST[‘LatestNews-WidgetTitle’]);
update_option(“LatestNews”, $options);
}

?>
<p>
<ul style=”display:”>
<label for=”LatestNews-WidgetTitle”>Widget Title: </label>
<input type=”text” id=”LatestNews-WidgetTitle” name=”LatestNews-WidgetTitle” value=”<?php echo $options[‘title’];?>” />
<input type=”hidden” id=”LatestNews-Submit” name=”LatestNews-Submit” value=”1″ />
</p>
<?php
}

function LatestNews_init()
{
register_sidebar_widget(__(‘Latest News’), ‘LatestNews’);
register_widget_control(   ‘Latest News’, ‘LatestNews_control’, 300, 200 );
}
add_action(“plugins_loaded”, “LatestNews_init”);
add_shortcode(“LatestNews”, “LatestNews”);

?>