'."\n";
}
/**********************************************************/
/* Recent widget
/**********************************************************/
function widget_ngg_recentimage() {
// Check for the required plugin functions. This will prevent fatal
// errors occurring when you deactivate the dynamic-sidebar plugin.
if ( !function_exists('register_sidebar_widget') )
return;
// Check for NextGEN Gallery
if ( !class_exists('nggallery') )
return;
function widget_nextgenrecentimage($args) {
extract($args);
// Each widget can store its own options. We keep strings here.
$options = get_option('widget_NextGenrecentimage');
$title = $options['title'];
$thumb = $options['thumb'];
$number = $options['number'];
$sizeX = $options['sizeX'];
$sizeY = $options['sizeY'];
$mode = $options['mode'];
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
$imgtype = "recent";
$show_widget = false; // checking display status (category or home)
$categorieslist = nggGetCSVValues($categorylist,','); // Make array for checking the categories
if (($showcategory == "denied")) { // Denied list -> enable everywhere and make false if found!
$show_widget = true;
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = false;
}
}
if (($showcategory == "allow")) // Allow list -> false is the default -> enable if found
foreach((get_the_category()) as $cat)
{ if ((in_array($cat->cat_ID , $categorieslist)))
$show_widget = true;
}
if (($showcategory == "all")) // All categories -> if it's not the home -> enable
if ((is_home() != true))
$show_widget = true;
if (($showinhome == "yes")) // Home page -> If yes -> enable
if ((is_home()))
$show_widget = true;
$url_parts = parse_url(get_bloginfo('home'));
// Null parameters check
if ( ($number == '') ) $number = 1;
if ( ($sizeX == '') ) $sizeX = 190;
if ( ($sizeY == '') ) $sizeY = 190;
if ($show_widget) {
echo $before_widget . $before_title . $title . $after_title;
echo "\n".'
'."\n";
echo $after_widget;
}
}
/**
* @desc Output of pluginīs editform in the adminarea
* @author KeViN
*/
function widget_nextgenimage_control($number=1) {
$options = get_option('widget_NextGenimage');
if ( !is_array($options) )
$options = array('title'=>'', 'buttontext'=>__('NextGEN Random Image','nggallery'));
if ( $_POST['nextgen-submit'] ) {
// Remember to sanitize and format use input appropriately.
$options = "";
$options['title'] = strip_tags(stripslashes($_POST['nextgen-title']));
$options['thumb'] = strip_tags(stripslashes($_POST['nextgen-thumb']));
$options['number'] = strip_tags(stripslashes($_POST['nextgen-number']));
$options['sizeX'] = strip_tags(stripslashes($_POST['nextgen-sizeX']));
$options['sizeY'] = strip_tags(stripslashes($_POST['nextgen-sizeY']));
$options['mode'] = strip_tags(stripslashes($_POST['nextgen-mode']));
// [0.80] [new functiions and newvariables] -> Category controll
$options['showinhome'] = strip_tags(stripslashes($_POST['nextgen-showinhome']));
$options['showcategory']= strip_tags(stripslashes($_POST['nextgen-showcategory']));
$options['categorylist']= strip_tags(stripslashes($_POST['nextgen-categorylist']));
// [0.95] [new variable] -> (random / recent)
$options['imgtype'] = strip_tags(stripslashes($_POST['nextgen-imgtype']));
update_option('widget_NextGenimage', $options);
}
// Be sure you format your options to be valid HTML attributes.
$title = htmlspecialchars($options['title'], ENT_QUOTES);
$thumb = htmlspecialchars($options['thumb'], ENT_QUOTES);
$number = htmlspecialchars($options['number'], ENT_QUOTES);
$sizeX = htmlspecialchars($options['sizeX'], ENT_QUOTES);
$sizeY = htmlspecialchars($options['sizeY'], ENT_QUOTES);
//$mode = htmlspecialchars($options['mode'], ENT_QUOTES);
$showinhome = htmlspecialchars($options['showinhome'], ENT_QUOTES);
$showcategory = htmlspecialchars($options['showcategory'], ENT_QUOTES);
$categorylist = htmlspecialchars($options['categorylist'], ENT_QUOTES);
$mode = htmlspecialchars($options['imgtype'], ENT_QUOTES);
// Here comes the form
echo'';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
}
// This registers our widget so it appears with the other available
// widgets and can be dragged and dropped into any active sidebars.
register_sidebar_widget(array('NextGEN Random Image', 'widgets'), 'widget_nextgenimage');
register_widget_control(array('NextGEN Random Image', 'widgets'), 'widget_nextgenimage_control', 300, 400);
}
// Run our code later in case this loads prior to any required plugins.
add_action('widgets_init', 'widget_ngg_randomimage');
add_action('widgets_init', 'widget_ngg_slideshow');
add_action('widgets_init', 'widget_ngg_recentimage');
?>