'k2-widget-about', 'description' => __('Message about the current area and optional front-page message', 'k2_domain') ); $this->WP_Widget('k2-about', __('K2 About', 'k2_domain'), $widget_ops); } function widget($args, $instance) { extract($args); $title = empty($instance['title']) ? __('About', 'k2_domain') : apply_filters('widget_title', $instance['title']); $message = stripslashes( $instance['message'] ); if ( is_home() or is_front_page() or is_page() ) { if ( ! empty($message) ) { echo $before_widget; if ( $title != '' ) echo $before_title . $title . $after_title; echo '
' . $message . '
' . $after_widget; } } elseif ( ! is_singular() ) { echo $before_widget; if ( $title != '' ) echo $before_title . $title . $after_title; ?>

' . get_bloginfo('name') . '', single_cat_title('', false) ); ?>

' . get_bloginfo('name') . '', get_the_time( __('l, F jS, Y', 'k2_domain') ) ); ?>

' . get_bloginfo('name') . '', get_the_time( __('F, Y', 'k2_domain') ) ); ?>

' . get_bloginfo('name') . '', get_the_time('Y') ); ?>

%2$s.', 'k2_domain'), '' . get_bloginfo('name') . '', esc_attr( get_search_query() ) ); ?>

%s.', 'k2_domain'), get_the_author() ); ?>

%2$s tag.','k2_domain'), '' . get_bloginfo('name') . '', get_query_var('tag') ); ?>

' . get_bloginfo('name') . '' ); ?>

__('About', 'k2_domain'), 'message' => '' ) ); $title = esc_attr( $instance['title'] ); $message = format_to_edit( $instance['message'] ); ?>

'k2-widget-asides', 'description' => __('Asides on your sidebar', 'k2_domain') ); $this->WP_Widget('k2-asides', __('K2 Asides', 'k2_domain'), $widget_ops); } function widget($args, $instance) { extract($args); $k2asidescategory = get_option('k2asidescategory'); if ( $k2asidescategory != '0') { $title = empty($instance['title']) ? apply_filters('single_cat_title', get_the_category_by_ID($k2asidescategory)) : apply_filters('widget_title', $instance['title']); $asides = new WP_Query( array( 'cat' => $k2asidescategory, 'showposts' => $instance['number'], 'what_to_show' => 'posts', 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1 ) ); if ( $asides->have_posts() ) { echo $before_widget; if ( $title != '' ) echo $before_title . $title . $after_title; ?>
have_posts() ): $asides->the_post(); ?>
> »  ', '' ); ?>
'', 'number' => 5 ) ); $title = esc_attr( $instance['title'] ); $number = (int) $instance['number']; ?>

$control ) { if ( $name == $id_base ) { if ( !is_callable( $control['callback'] ) ) continue; $_POST['id_base'] = $id_base; if ( 1 == $control['callback'][0]->number ) { $_POST['multi_number'] = 2; $sidebar[] = $id_base . '-2'; } else { $_POST['multi_number'] = $control['callback'][0]->number; $sidebar[] = $control['callback'][0]->id; } call_user_func_array( $control['callback'], $control['params'] ); break; } } } function k2_widgets_init() { register_widget('K2_Widget_About'); register_widget('K2_Widget_Asides'); } add_action( 'widgets_init', 'k2_widgets_init' ); function k2_asides_filter($query) { $asidescat = get_option('k2asidescategory'); // Only filter when it's in the homepage if ( ($asidescat != 0) and ($query->is_home) and is_active_widget(false, false, 'k2-asides') ) { $exclude_cats = $query->get('category__not_in'); $include_cats = $query->get('category__in'); // Remove asides from list of categories to include if ( !empty($include_cats) and in_array($asidescat, $include_cats) ) { $query->set( 'category__in', array_diff( $include_cats, array($asidescat) ) ); } // Insert asides into list of categories to exclude if ( empty($exclude_cats) ) { $query->set( 'category__not_in', array($asidescat) ); } else if ( !in_array( $asidescat, $exclude_cats ) ) { $query->set( 'category__not_in', array_merge( $exclude_cats, array($asidescat) ) ); } } return $query; } // Filter to remove asides from the loop add_filter('pre_get_posts', 'k2_asides_filter');