diff -r 53cff4b4a802 -r bde1974c263b web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php Wed Feb 03 15:37:20 2010 +0000 @@ -0,0 +1,162 @@ +Widgets and Drag "Posts of Current Category" widget to your Sidebar. +Version: 0.1 +Author: Anup Raj +Author URI: http://anupraj.com.np/home/ +// modified by sam 21/01/2010 +*/ + +class posts_cur_cat extends WP_Widget { + function posts_cur_cat() { + $widget_ops = array('description' => __('Display Posts of current category and order it.', 'posts-of-cur-cat') ); + //Create widget + $this->WP_Widget('postsofcurrentcategory', __('Posts of Current Category', 'posts-of-cur-cat'), $widget_ops); + } + + function widget($args, $instance) { + extract($args, EXTR_SKIP); + echo $before_widget; + + $title = empty($instance['title']) ? __('', 'posts-of-cur-cat') : apply_filters('widget_title', $instance['title']); + $parameters = array( + 'title' => $title, + 'limit' => (int) $instance['show-num'], + 'excerpt' => (int) $instance['excerpt-length'], + 'AscDesc' => esc_attr($instance['AscDesc']), + 'OrderBy' => esc_attr($instance['OrderBy']) + + ); + if ( !empty( $title ) ) { + echo $before_title . $title . $after_title; + }; + + //print recent posts + post_of_curCat($parameters); + echo $after_widget; + + } //end of widget + + //Update widget options + function update($new_instance, $old_instance) { + + $instance = $old_instance; + //get old variables + $instance['title'] = esc_attr($new_instance['title']); + $instance['show-num'] = (int) abs($new_instance['show-num']); + + $instance['OrderBy'] = esc_attr($new_instance['OrderBy']); + $instance['AscDesc'] = esc_attr($new_instance['AscDesc']); + + return $instance; + } //end of update + + //Widget options form + function form($instance) { + + $instance = wp_parse_args( + (array) $instance, + array( + 'title' => __('Posts of Current Category','posts-of-cur-cat'), + 'show-num' => 10, + 'AscDesc' => "ASC", + 'OrderBy' => "ID" + ) + ); + + $title = esc_attr($instance['title']); + $show_num = (int) $instance['show-num']; + $AscDesc = esc_attr($instance['AscDesc']); + $OrderBy = esc_attr($instance['OrderBy']); + + ?> +

+ +

+

+ +

+

+ + +

+

+ + +

+ 10, + 'AscDesc' => "ASC", + 'OrderBy' =>'ID', + + ); + $args = wp_parse_args( $args, $defaults ); + extract($args); + + $limit = (int) abs($limit); + + if(is_category()){ + $curCategoryID = get_query_var('cat'); + } + if (is_single()) { + $curCategoryID = ''; + foreach (get_the_category() as $catt) { + $curCategoryID .= $catt->cat_ID.' '; + } + $curCategoryID = str_replace(" ", ",", trim($curCategoryID)); + } + if (!intval($curCategoryID)) $curCategoryID=''; + + $query = "&category=$curCategoryID&showposts=$limit&orderby=$OrderBy&order=$AscDesc"; + $posts = get_posts($query); //get posts + $postlist = ''; + foreach ($posts as $post) { + $post_title_s = htmlspecialchars(stripslashes(cache_cutter($post->post_title))); + $post_title_l = htmlspecialchars(stripslashes(text_cutter($post->post_title,200))); + // modif here (cache_cutter(); ) + $postlist .= '
  • ' . $post_title_l . '
  • '; + } + + echo ''; + } + +?> \ No newline at end of file