Popularity Contest plugin by Alex King. Please install and activate the plugin before using this widget.
Author: Debashish Chakrabarty
Author URI: http://www.debashish.com
Min WP Version: 2.7
*/
//-----------------------------------------------------------------------------
?>
';
if (function_exists('akpc_most_popular')) {
akpc_most_popular($limit=5);
}
else {
echo '
The Popularity Contest Widget needs Alex Kings Popularity Contest plugin to function. Please install and activate the plugin first. ';
}
echo '';
echo $after_widget;
// output done
return;
}
function dc_popcontest_widget_control() {
// options
$options = $newoptions = get_option('dc_popcontest_widget'); // get options
// set new options
if( $_POST['dc-popcontest-widget-submit'] ) {
$newoptions['title'] = strip_tags( stripslashes($_POST['dc-popcontest-widget-title']) );
$newoptions['ulclass'] = strip_tags( stripslashes($_POST['dc-popcontest-ul-classname']) );
}
// update options if needed
if( $options != $newoptions ) {
$options = $newoptions;
update_option('dc_popcontest_widget', $options);
}
// output
echo ''._e('Title');
echo ' '.' ';
echo '
';
echo ''._e('UL Class');
echo ' '.' ';
echo '
';
echo ' ';
}
// activate and deactivate plugin
function popcontest_activate() {
// options, defaultvalues
$options = array(
'widget' => array(
'title' => 'Popular Posts',
'ulclass' => 'popularposts'
)
);
// register option
add_option( 'dc_popcontest_widget', $options['widget'] );
// activated
return;
}
function popcontest_deactivate() {
// unregister option
delete_option('dc_popcontest_widget');
// deactivated
return;
}
// initialization
function popcontest_init() {
// register widget
$class['classname'] = 'dc_popcontest_widget';
wp_register_sidebar_widget('related_posts', __('Popular Posts'), 'dc_popcontest_widget', $class);
wp_register_widget_control('related_posts', __('Popular Posts'), 'dc_popcontest_widget_control', 'width=300&height=200');
// initialization done
return;
}
// actions
add_action( 'activate_'.plugin_basename(__FILE__), 'popcontest_activate' );
add_action( 'deactivate_'.plugin_basename(__FILE__), 'popcontest_deactivate' );
add_action( 'init', 'popcontest_init');
?>