web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
--- a/web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php	Thu Sep 16 15:45:36 2010 +0000
+++ b/web/wp-content/plugins/posts-of-current-category/posts-of-current-category.php	Mon Nov 19 18:26:13 2012 +0100
@@ -1,12 +1,11 @@
 <?php
 /*
 Plugin Name: Posts of Current Category
-Plugin URI: http://anupraj.com.np/home/wp-plugins/display-posts-of-current-category-widget/
+Plugin URI: http://anupraj.com.np/index.php/display-posts-of-current-category-widget/68
 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.
-Version: 0.1
+Version: 0.4
 Author: Anup Raj
-Author URI: http://anupraj.com.np/home/
-// modified by sam 21/01/2010
+Author URI: http://anupraj.com.np/
 */
 
 class posts_cur_cat extends WP_Widget {
@@ -18,7 +17,6 @@
 
   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(
@@ -29,12 +27,47 @@
 				'OrderBy' => esc_attr($instance['OrderBy'])
 				
 			);
+			echo $before_title;
+			echo '<a href="';
+			echo get_permalink($post->post_parent);
+			echo '" tile="';
 			if ( !empty( $title ) ) {
-		    echo $before_title . $title . $after_title;
-			};
+				echo $title;
+				echo '">';
+				echo $title;
+			}else{
+				if($post->post_parent) {
+					$parent_title = get_the_title($post->post_parent);
+					echo $parent_title;
+					echo '">';
+					echo $parent_title;
+				} else {
+					wp_title('');
+					echo '">';
+					wp_title('');
+				}
+			}
+			echo '</a>';
+			echo $after_title;
 			
-			//print recent posts
-			post_of_curCat($parameters);
+			echo $before_widget;
+			if (is_page()){
+			/*
+				if($post->post_parent){
+					$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order"); 
+				}else{
+					$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order");
+				}
+				if ($children && !$s) { 
+					//echo '<ul>';
+					echo $children; 
+					//echo '</ul>';
+				}
+			*/
+			}
+			if(is_category()){//print recent posts
+					post_of_curCat($parameters);
+			}
 			echo $after_widget;
 			
   } //end of widget
@@ -74,7 +107,8 @@
 		?>
 		<p>
 		   <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:');?> 
-			<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; ?>" />
+			<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; ?>" /><br />
+			<em>Leave this field blank, if you want to display Parent's Post's or Page's Title on widget heading</em>
 		   </label>
 		</p>
 		<p>
@@ -148,15 +182,12 @@
 	$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 .= '<li><a href="' . get_permalink($post->ID) . '" title="'.  $post_title_s .'" >' . $post_title_l . ' </a> </li>';
+		$post_title = htmlspecialchars(stripslashes($post->post_title));
+		$postlist .= '<li><a href="' . get_permalink($post->ID) . '" title="'. $post_title .'" >' . $post_title . '</a> </li>';
     }
 	
-	echo '<ul class="advanced-recent-posts">';		
+	echo '<ul class="posts-of-current-category">';		
 		echo $postlist;
 	echo '</ul>';
  }
-
 ?>
\ No newline at end of file