'and_pop_widget', 'description' => __('A Triton widget that displays the most popular posts of the site, Based on the comments count ', 'Triton') );
/* Widget control settings */
//$control_ops = array( 'width' => 160, 'height' => 600, 'id_base' => 'and_pop_widget' );
/* Create the widget */
$this->WP_Widget( 'and_pop_widget', __('Popular Posts Widget', 'Triton'), $widget_ops );
}
/* ---------------------------- */
/* ------- Display Widget -------- */
/* ---------------------------- */
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$num = $instance['num'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
/* Display a containing div */
echo '
';
/* Display Posts */
if ( $num )
$popular = new WP_Query('orderby=comment_count&posts_per_page=' . $num);
echo '
';
while ($popular->have_posts()) : $popular->the_post();
echo '
';
/* After widget (defined by themes). */
echo $after_widget;
}
/* ---------------------------- */
/* ------- Update Widget -------- */
/* ---------------------------- */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags for title and name to remove HTML (important for text inputs). */
$instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] );
/* No need to strip tags */
$instance['num'] = $new_instance['num'];
return $instance;
}
/* ---------------------------- */
/* ------- Widget Settings ------- */
/* ---------------------------- */
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array(
'title' => '',
'num' => 3,
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
'and_rand_widget', 'description' => __('A Triton widget that displays the random posts of the site', 'Triton') );
/* Widget control settings */
//$control_ops = array( 'width' => 160, 'height' => 600, 'id_base' => 'and_rand_widget' );
/* Create the widget */
$this->WP_Widget( 'and_rand_widget', __('Random Posts Widget', 'Triton'), $widget_ops );
}
/* ---------------------------- */
/* ------- Display Widget -------- */
/* ---------------------------- */
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$num = $instance['num'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
/* Display a containing div */
echo '
';
/* Display Posts */
if ( $num )
$popular = new WP_Query('orderby=rand&posts_per_page=' . $num);
echo '
';
while ($popular->have_posts()) : $popular->the_post();
echo '
';
/* After widget (defined by themes). */
echo $after_widget;
}
/* ---------------------------- */
/* ------- Update Widget -------- */
/* ---------------------------- */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags for title and name to remove HTML (important for text inputs). */
$instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] );
/* No need to strip tags */
$instance['num'] = $new_instance['num'];
return $instance;
}
/* ---------------------------- */
/* ------- Widget Settings ------- */
/* ---------------------------- */
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array(
'title' => '',
'num' => 3,
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
'and_feat_widget', 'description' => __('A Triton widget that displays the featured posts from your selected category', 'Triton') );
/* Widget control settings */
//$control_ops = array( 'width' => 160, 'height' => 600, 'id_base' => 'and_feat_widget' );
/* Create the widget */
$this->WP_Widget( 'and_feat_widget', __('Featured Posts Widget', 'Triton'), $widget_ops );
}
/* ---------------------------- */
/* ------- Display Widget -------- */
/* ---------------------------- */
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$num = $instance['num'];
$cat = $instance['cat'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
/* Display a containing div */
echo '
';
/* After widget (defined by themes). */
echo $after_widget;
}
/* ---------------------------- */
/* ------- Update Widget -------- */
/* ---------------------------- */
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags for title and name to remove HTML (important for text inputs). */
$instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] );
/* No need to strip tags */
$instance['num'] = $new_instance['num'];
$instance['cat'] = $new_instance['cat'];
return $instance;
}
/* ---------------------------- */
/* ------- Widget Settings ------- */
/* ---------------------------- */
/**
* Displays the widget settings controls on the widget panel.
* Make use of the get_field_id() and get_field_name() function
* when creating your form elements. This handles the confusing stuff.
*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array(
'title' => '',
'num' => 3,
'cat' => 0,
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>