[wp-hackers] patch for manage pages

Adi Jörg Sieker ml at adsworth.info
Sat Jan 29 15:13:48 GMT 2005


Hi,

when a user has at least one static page. manage/pages would display all
static pages in the database.
Attched is a patch that fixes the problem.

Regards
    Adi
-------------- next part --------------
Index: edit-pages.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/edit-pages.php,v
retrieving revision 1.9
diff -U3 -r1.9 edit-pages.php
--- edit-pages.php	1 Jan 2005 23:05:06 -0000	1.9
+++ edit-pages.php	29 Jan 2005 15:09:16 -0000
@@ -11,10 +11,11 @@
 <h2><?php _e('Page Management'); ?></h2>
 
 <?php
+
 if (isset($user_ID) && ('' != intval($user_ID))) {
-    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' AND post_author = $user_ID");
+    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' AND post_author = $user_ID ORDER BY menu_order");
 } else {
-    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
+    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
 }
 
 if ($posts) {
@@ -29,7 +30,7 @@
     <th scope="col"></th> 
     <th scope="col"></th> 
   </tr> 
-<?php page_rows(); ?>
+<?php page_rows(0,0,$posts); ?>
 </table> 
 <?php
 } else {
Index: admin-functions.php
===================================================================
RCS file: /cvsroot/cafelog/wordpress/wp-admin/admin-functions.php,v
retrieving revision 1.76
diff -U3 -r1.76 admin-functions.php
--- admin-functions.php	24 Jan 2005 06:05:44 -0000	1.76
+++ admin-functions.php	29 Jan 2005 15:09:18 -0000
@@ -136,10 +136,17 @@
 }
 
 function page_rows( $parent = 0, $level = 0, $pages = 0 ) {
-	global $wpdb, $class, $user_level, $post;
-	if (!$pages)
-		$pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
+	global $wpdb, $class, $user_level, $post, $user_ID;
 
+    $author_where = '';
+
+	if (!$pages) {
+        if (isset($user_ID) && ('' != intval($user_ID))) {
+            $author_where = "AND post_author = $user_ID"; 
+        }
+		$pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' $author_where ORDER BY menu_order");
+    }
+    
 	if ($pages) {
 		foreach ($pages as $post) { start_wp();
 			if ($post->post_parent == $parent) {


More information about the hackers mailing list