";
echo $after_widget;
} else { return $widget_mdv_most_commented_per_cat; }
}
}
// This is the function that outputs the form to let the users edit
// the widget's parameters.
function widget_mdv_most_commented_per_cat_control() {
// Fetch the options, check them and if need be, update the options array
$bfa_pic_options = $bfa_pic_newoptions = get_option('widget_mdv_most_commented_per_cat');
if ( isset($_POST["bfa_pic_src-submit"]) ) {
$bfa_pic_newoptions['bfa_pic_title'] = strip_tags(stripslashes($_POST["bfa_pic_src-title"]));
$bfa_pic_newoptions['bfa_pic_no_posts'] = (int) $_POST["bfa_pic_no_posts"];
$bfa_pic_newoptions['bfa_pic_duration'] = (int) $_POST["bfa_pic_duration"];
$bfa_pic_newoptions['bfa_pic_min_amount_comments'] = (int) $_POST["bfa_pic_min_amount_comments"];
$bfa_pic_newoptions['bfa_pic_append_cat_title'] = !isset($_POST["bfa_pic_append_cat_title"]) ? NULL : $_POST["bfa_pic_append_cat_title"];
$bfa_pic_newoptions['bfa_pic_prepend_cat_title'] = !isset($_POST["bfa_pic_prepend_cat_title"]) ? NULL : $_POST["bfa_pic_prepend_cat_title"];
}
if ( $bfa_pic_options != $bfa_pic_newoptions ) {
$bfa_pic_options = $bfa_pic_newoptions;
update_option('widget_mdv_most_commented_per_cat', $bfa_pic_options);
}
// Default options to the parameters
if ( !isset($bfa_pic_options['bfa_pic_no_posts']) ) $bfa_pic_options['bfa_pic_no_posts'] = 10;
if ( !isset($bfa_pic_options['bfa_pic_min_amount_comments']) ) $bfa_pic_options['bfa_pic_min_amount_comments'] = 1;
$bfa_pic_no_posts = $bfa_pic_options['bfa_pic_no_posts'];
$bfa_pic_duration = $bfa_pic_options['bfa_pic_duration'];
$bfa_pic_min_amount_comments = $bfa_pic_options['bfa_pic_min_amount_comments'];
$bfa_pic_append_cat_title = $bfa_pic_options['bfa_pic_append_cat_title'];
$bfa_pic_prepend_cat_title = $bfa_pic_options['bfa_pic_prepend_cat_title'];
// Deal with HTML in the parameters
$bfa_pic_title = htmlspecialchars($bfa_pic_options['bfa_pic_title'], ENT_QUOTES);
?>
Title:
/>Prepend
/> Append Category Name to Title
Show
posts not older than days and with at least
comments
'widget_popular_in_cat', 'description' => __("Lists most commented posts of given category","atahualpa") );
$control_ops = array('width' => 600, 'height' => 500);
wp_register_sidebar_widget('popular_in_cat', __('BFA Popular in Cat','atahualpa'), 'widget_mdv_most_commented_per_cat', $widget_ops);
wp_register_widget_control('popular_in_cat', __('BFA Popular in Cat','atahualpa'), 'widget_mdv_most_commented_per_cat_control', $control_ops);
?>