'arras_tabbed_sidebar',
'description' => __('Sidebar containing tabs that displays posts, comments and tags.', 'arras'),
);
$this->WP_Widget('arras_tabbed_sidebar', __('Tabbed Sidebar', 'arras'), $widget_args);
add_action('arras_tabbed_sidebar_tab-featured', array(&$this, 'featured_tab'));
add_action('arras_tabbed_sidebar_tab-latest', array(&$this, 'latest_tab'));
add_action('arras_tabbed_sidebar_tab-comments', array(&$this, 'comments_tab'));
add_action('arras_tabbed_sidebar_tab-tags', array(&$this, 'tags_tab'));
add_action('arras_tabbed_sidebar_tab-popular', array(&$this, 'popular_tab'));
}
function get_tabs() {
$_default_tabs = array(
'featured' => __('Featured', 'arras'),
'latest' => __('Latest', 'arras'),
'comments' => __('Comments', 'arras'),
'tags' => __('Tags', 'arras')
);
if ( function_exists('akpc_most_popular') ) {
$_default_tabs['popular'] = __('Popular', 'arras');
}
return apply_filters('arras_tabbed_sidebar_tabs', $_default_tabs);
}
function widget($args, $instance) {
global $wpdb;
extract($args, EXTR_SKIP);
$this->query_source = $instance['query'];
$this->postcount = $instance['postcount'];
$this->commentcount = $instance['commentcount'];
$this->display_thumbs = isset($instance['display_thumbs']);
if (!$instance['order']) $instance['order'] = $this->get_tabs();
if ($instance['display_home'] && !is_home()) {
return false;
}
?>
query_source) {
case 'slideshow':
$q = arras_parse_query(
arras_get_option('slideshow_cat'),
$this->postcount,
0,
arras_get_option('slideshow_posttype'),
arras_get_option('slideshow_tax')
);
break;
case 'featured2':
$q = arras_parse_query(
arras_get_option('featured2_cat'),
$this->postcount,
0,
arras_get_option('featured2_posttype'),
arras_get_option('featured2_tax')
);
break;
default:
$q = arras_parse_query(
arras_get_option('featured1_cat'),
$this->postcount,
0,
arras_get_option('featured1_posttype'),
arras_get_option('featured1_tax')
);
}
$f = new WP_Query($q);
if (!$f->have_posts()) {
echo '' . __('No posts at the moment. Check back again later!', 'arras') . ' ';
} else {
echo '';
while ($f->have_posts()) {
$f->the_post();
?>
display_thumbs) : ?>
|
';
}
}
function latest_tab() {
$f = new WP_Query('showposts=' . $this->postcount);
if (!$f->have_posts()) {
echo '' . __('No posts at the moment. Check back again later!', 'arras') . ' ';
} else {
echo '';
while ($f->have_posts()) {
$f->the_post();
?>
display_thumbs) : ?>
|
';
}
}
function comments_tab() {
$comments = get_comments( array('status' => 'approve', 'number' => $this->commentcount) );
if ($comments) {
echo '';
}
}
function tags_tab() {
echo '';
if (function_exists('wp_cumulus_insert')) {
$args = array(
'width' => 280,
'height' => 280
);
wp_cumulus_insert($args);
} else {
wp_tag_cloud('smallest=9&largest=16');
}
echo '
';
}
function popular_tab() {
if ( function_exists('akpc_most_popular') ) {
echo '';
akpc_most_popular(10, '', ' ');
echo ' ';
}
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['order'] = $new_instance['order'];
$instance['display_home'] = $new_instance['display_home'];
$instance['display_thumbs'] = $new_instance['display_thumbs'];
$instance['query'] = $new_instance['query'];
$instance['postcount'] = $new_instance['postcount'];
$instance['commentcount'] = $new_instance['commentcount'];
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array)$instance, array(
'order' => array('featured', 'latest', 'comments', 'tags'),
'display_home' => true,
'display_thumbs' => true,
'query' => 'slideshow',
'postcount' => 8,
'commentcount' => 8
) );
$order = $instance['order'];
?>
value="slideshow">
value="featured1">
value="featured2">
get_tabbed_opts( $order[0], 'featured'); ?>
get_tabbed_opts( $order[1], 'latest'); ?>
get_tabbed_opts( $order[2], 'comments'); ?>
get_tabbed_opts( $order[3], 'tags'); ?>
Popularity Contest is enabled.', 'arras') ?>
selected="selected">
checked="checked" />
checked="checked" />
get_tabs();
if (!$selected) $selected = $default;
foreach ( $opts as $id => $val ) {
echo '';
echo $val;
echo ' ';
}
}
function render_sidebar_tabs($order) {
$order = array_unique($order);
$list = $this->get_tabs();
foreach ($order as $t) {
?> 'arras_featured_stories',
'description' => __('Featured stories containing post thumbnails and the excerpt based on categories.', 'arras'),
);
$this->WP_Widget('arras_featured_stories', __('Featured Stories', 'arras'), $widget_args);
}
function widget($args, $instance) {
global $wpdb;
extract($args, EXTR_SKIP);
if ($instance['no_display_in_home'] && is_home()) {
return false;
}
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
echo $before_title . $title . $after_title;
$q = arras_parse_query($instance['featured_cat'], $instance['postcount']);
$r = new WP_Query($q);
if ($r->have_posts()) {
echo '';
while ($r->have_posts()) : $r->the_post();
?>
';
}
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['featured_cat'] = $new_instance['featured_cat'];
$instance['postcount'] = (int)strip_tags($new_instance['postcount']);
$instance['no_display_in_home'] = strip_tags($new_instance['no_display_in_home']);
$instance['show_excerpts'] = strip_tags($new_instance['show_excerpts']);
$instance['show_thumbs'] = strip_tags($new_instance['show_thumbs']);
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array)$instance, array(
'title' => __('Featured Stories', 'arras'),
'featured_cat' => 0,
'postcount' => 5,
'no_display_in_home' => true,
'show_excerpts' => true,
'show_thumbs' => true
) );
if (!is_array($instance['featured_cat'])) $instance['featured_cat'] = array(0);
?>
value="0">
cat_ID, $instance['featured_cat'])) $selected = ' selected="selected"';
echo '' . $c->cat_name . ' ';
}
?>
selected="selected">
checked="checked" />
checked="checked" />
checked="checked" />
WP_Widget_Tag_Cloud();
}
function widget( $args, $instance ) {
extract($args);
// for WordPress 3.0+
if ( function_exists('_get_current_taxonomy') ) {
$current_taxonomy = $this->_get_current_taxonomy($instance);
if ( !empty($instance['title']) ) {
$title = $instance['title'];
} else {
if ( 'post_tag' == $current_taxonomy ) {
$title = __('Tags');
} else {
$tax = get_taxonomy($current_taxonomy);
$title = $tax->label;
}
}
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '';
wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'smallest' => 9, 'largest' => 16) ) );
echo "
\n";
echo $after_widget;
} else {
$title = apply_filters('widget_title', empty($instance['title']) ? __('Tags') : $instance['title']);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
echo '';
wp_tag_cloud(apply_filters('widget_tag_cloud_args', array()));
echo "
\n";
echo $after_widget;
}
}
}
class Arras_Widget_Search extends WP_Widget {
function Arras_Widget_Search() {
$widget_ops = array('classname' => 'widget_search', 'description' => __( "A search form for your site") );
$this->WP_Widget('search', __('Search'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
// Use current theme search form if it exists
echo '';
get_search_form();
echo '
';
}
function form( $instance ) {
}
function update( $new_instance, $old_instance ) {
}
}
// Register Widgets
function arras_widgets_init() {
unregister_widget('WP_Widget_Tag_Cloud');
unregister_widget('WP_Widget_Search');
register_widget('Arras_Tabbed_Sidebar');
register_widget('Arras_Featured_Stories');
register_widget('Arras_Widget_Tag_Cloud');
register_widget('Arras_Widget_Search');
}
add_action('widgets_init', 'arras_widgets_init', 1);
/* End of file widgets.php */
/* Location: ./library/widgets.php */
?>