web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php
author hurons@caf4f556-3d62-0410-8435-a86758001935
Mon, 01 Feb 2010 09:51:57 +0000
branchwordpress
changeset 123 561aa6d282f6
parent 109 03b0d1493584
permissions -rw-r--r--
pre production version : ****************************** Template evolution : - css ( so much things) - js ( new navigation tools ...) - lib for php ZIp - function.php (for download LDT and other litle function) - page (header, home, footer, single, search, searchform, post ...) ****************************** New plug in : - wp touch - wp explorer - TextCutter - ultimate-google-analytics - nice titles ****************************** Plug in customization : - related-posts-by-category - posts-of-current-category - order-categories - event-calendar - translation wp explorer - exec-php ****************************** Road map for next version : - cleaning php code put template function to new plugin - cleaning Css code - re organize Js code - all new correction ask
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     1
<?php
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     2
/*
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     3
Plugin Name: Posts of Current Category
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     4
Plugin URI: http://anupraj.com.np/home/wp-plugins/display-posts-of-current-category-widget/
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     5
Description: Lists (Show/Display title) Posts of Current Category and Order Posts by author,content,date,ID, .. etc  Sort ASC/DESC. Go to Appearance>Widgets and Drag "Posts of Current Category" widget to your Sidebar.
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     6
Version: 0.1
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     7
Author: Anup Raj
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
     8
Author URI: http://anupraj.com.np/home/
123
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
     9
// modified by sam 21/01/2010
109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    10
*/
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    11
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    12
class posts_cur_cat extends WP_Widget {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    13
	function posts_cur_cat() {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    14
		$widget_ops = array('description' => __('Display Posts of current category and order it.', 'posts-of-cur-cat') );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    15
		//Create widget
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    16
		$this->WP_Widget('postsofcurrentcategory', __('Posts of Current Category', 'posts-of-cur-cat'), $widget_ops);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    17
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    18
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    19
  function widget($args, $instance) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    20
	 		extract($args, EXTR_SKIP);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    21
			echo $before_widget;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    22
			
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    23
			$title = empty($instance['title']) ? __('', 'posts-of-cur-cat') : apply_filters('widget_title', $instance['title']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    24
			$parameters = array(
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    25
			  'title' => $title,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    26
				'limit' => (int) $instance['show-num'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    27
				'excerpt' => (int) $instance['excerpt-length'],
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    28
				'AscDesc' => esc_attr($instance['AscDesc']),
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    29
				'OrderBy' => esc_attr($instance['OrderBy'])
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    30
				
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    31
			);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    32
			if ( !empty( $title ) ) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    33
		    echo $before_title . $title . $after_title;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    34
			};
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    35
			
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    36
			//print recent posts
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    37
			post_of_curCat($parameters);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    38
			echo $after_widget;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    39
			
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    40
  } //end of widget
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    41
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    42
	//Update widget options
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    43
  function update($new_instance, $old_instance) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    44
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    45
		$instance = $old_instance;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    46
		//get old variables
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    47
		$instance['title'] = esc_attr($new_instance['title']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    48
		$instance['show-num'] = (int) abs($new_instance['show-num']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    49
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    50
		$instance['OrderBy'] = esc_attr($new_instance['OrderBy']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    51
		$instance['AscDesc'] = esc_attr($new_instance['AscDesc']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    52
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    53
		return $instance;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    54
  } //end of update
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    55
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    56
	//Widget options form
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    57
  function form($instance) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    58
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    59
		$instance = wp_parse_args(
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    60
		(array) $instance, 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    61
		array(
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    62
			'title' => __('Posts of Current Category','posts-of-cur-cat'), 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    63
			'show-num' => 10,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    64
			'AscDesc' => "ASC",
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    65
			'OrderBy' => "ID"
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    66
			)
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    67
		);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    68
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    69
		$title = esc_attr($instance['title']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    70
		$show_num = (int) $instance['show-num'];
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    71
		$AscDesc = esc_attr($instance['AscDesc']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    72
		$OrderBy = esc_attr($instance['OrderBy']);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    73
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    74
		?>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    75
		<p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    76
		   <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:');?> 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    77
			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    78
		   </label>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    79
		</p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    80
		<p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    81
		   <label for="<?php echo $this->get_field_id('show-num'); ?>"><?php _e('Number of posts to show:');?> 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    82
		  <input id="<?php echo $this->get_field_id('show-num'); ?>" name="<?php echo $this->get_field_name('show-num'); ?>" type="text" value="<?php echo $show_num; ?>" size ="3" /><br />
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    83
			
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    84
		  </label>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    85
	  </p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    86
		<p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    87
			<label for="<?php echo $this->get_field_id('OrderBy'); ?>"> <?php _e('Order By, Post\'s :  ', 'posts-of-cur-cat');?></label>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    88
			<select class="select" id="<?php echo $this->get_field_id('OrderBy'); ?>" name="<?php echo $this->get_field_name('OrderBy'); ?>">
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    89
				<option value="author" <?php if($OrderBy=="author") echo "SELECTED"; ?>>author</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    90
				<option value="category" <?php if($OrderBy=="category") echo "SELECTED"; ?>>category</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    91
				<option value="content" <?php if($OrderBy=="content") echo "SELECTED"; ?>>content</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    92
				<option value="date" <?php if($OrderBy=="date") echo "SELECTED"; ?>>date</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    93
				<option value="ID" <?php if($OrderBy=="ID") echo "SELECTED"; ?>>ID</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    94
				<option value="menu_order" <?php if($OrderBy=="menu_order") echo "SELECTED"; ?>>menu_order</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    95
				<option value="mime_type" <?php if($OrderBy=="mime_type") echo "SELECTED"; ?>>mime_type</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    96
				<option value="modified" <?php if($OrderBy=="modified") echo "SELECTED"; ?>>modified</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    97
				<option value="name" <?php if($OrderBy=="name") echo "SELECTED"; ?>>name</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    98
				<option value="parent" <?php if($OrderBy=="parent") echo "SELECTED"; ?>>parent</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
    99
				<option value="password" <?php if($OrderBy=="password") echo "SELECTED"; ?>>password</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   100
				<option value="rand" <?php if($OrderBy=="rand") echo "SELECTED"; ?>>rand</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   101
				<option value="status" <?php if($OrderBy=="status") echo "SELECTED"; ?>>status</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   102
				<option value="title" <?php if($OrderBy=="title") echo "SELECTED"; ?>>title</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   103
				<option value="type" <?php if($OrderBy=="type") echo "SELECTED"; ?>>type</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   104
			</select>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   105
		</p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   106
		<p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   107
			<label for="<?php echo $this->get_field_id('AscDesc'); ?>"> <?php _e('Sort Order By : &nbsp; &nbsp; ', 'posts-of-cur-cat');?></label>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   108
			<select class="select" id="<?php echo $this->get_field_id('AscDesc'); ?>" name="<?php echo $this->get_field_name('AscDesc'); ?>">
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   109
				<option value="ASC" <?php if($AscDesc=="ASC") echo "SELECTED"; ?>>ASCending</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   110
				<option value="DESC" <?php if($AscDesc=="DESC") echo "SELECTED"; ?>>DESCending</option>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   111
			</select>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   112
		</p>
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   113
   <?php
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   114
  } //end of form
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   115
}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   116
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   117
add_action( 'widgets_init', create_function('', 'return register_widget("posts_cur_cat");') );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   118
//Register Widget
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   119
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   120
 // Show recent posts function
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   121
 function post_of_curCat($args = '') {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   122
  global $wpdb;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   123
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   124
	$defaults = array(
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   125
		'limit' => 10,
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   126
		'AscDesc' => "ASC", 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   127
		'OrderBy' =>'ID',
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   128
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   129
	);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   130
	$args = wp_parse_args( $args, $defaults );
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   131
	extract($args);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   132
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   133
	$limit = (int) abs($limit);
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   134
		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   135
	if(is_category()){
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   136
	 $curCategoryID = get_query_var('cat');
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   137
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   138
	if (is_single()) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   139
	 $curCategoryID = '';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   140
	 foreach (get_the_category() as $catt) {
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   141
	   $curCategoryID .= $catt->cat_ID.' '; 
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   142
	 }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   143
	 $curCategoryID = str_replace(" ", ",", trim($curCategoryID));
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   144
	}
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   145
	if (!intval($curCategoryID)) $curCategoryID='';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   146
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   147
	$query = "&category=$curCategoryID&showposts=$limit&orderby=$OrderBy&order=$AscDesc";
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   148
	$posts = get_posts($query); //get posts
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   149
	$postlist = '';	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   150
    foreach ($posts as $post) {
123
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
   151
		$post_title_s = htmlspecialchars(stripslashes(cache_cutter($post->post_title)));
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
   152
		$post_title_l = htmlspecialchars(stripslashes(text_cutter($post->post_title,200)));
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
   153
		// modif here (cache_cutter(); ) 				
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
   154
		$postlist .= '<li><a href="' . get_permalink($post->ID) . '" title="'.  $post_title_s .'" >' . $post_title_l . ' </a> </li>';
109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   155
    }
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   156
	
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   157
	echo '<ul class="advanced-recent-posts">';		
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   158
		echo $postlist;
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   159
	echo '</ul>';
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   160
 }
123
561aa6d282f6 pre production version :
hurons@caf4f556-3d62-0410-8435-a86758001935
parents: 109
diff changeset
   161
109
03b0d1493584 wordpress 2.8 ()
hurons@caf4f556-3d62-0410-8435-a86758001935
parents:
diff changeset
   162
?>