Ticket #3945: 3945b.diff

File 3945b.diff, 17.6 KB (added by mdawaffe, 6 years ago)

for posts. all on one tab. pagination may need some work

Line 
1Index: wp-includes/query.php
2===================================================================
3--- wp-includes/query.php       (revision 5555)
4+++ wp-includes/query.php       (working copy)
5@@ -995,30 +995,39 @@
6                }
7 
8                if ( $this->is_attachment ) {
9-                       $where .= " AND (post_type = 'attachment')";
10+                       $where .= " AND post_type = 'attachment'";
11                } elseif ($this->is_page) {
12-                       $where .= " AND (post_type = 'page')";
13+                       $where .= " AND post_type = 'page'";
14                } elseif ($this->is_single) {
15-                       $where .= " AND (post_type = 'post')";
16+                       $where .= " AND post_type = 'post'";
17                } else {
18-                       $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
19+                       $where .= " AND post_type = '$post_type'";
20+               }
21 
22+               if ( isset($q['post_status']) && '' != $q['post_status'] ) {
23+                       $q_status = explode(',', $q['post_status']);
24+                       $r_status = array();
25+                       if ( in_array( 'draft'  , $q_status ) )
26+                               $r_status[] = "post_status = 'draft'";
27+                       if ( in_array( 'future' , $q_status ) )
28+                               $r_status[] = "post_status = 'future'";
29+                       if ( in_array( 'inherit' , $q_status ) )
30+                               $r_status[] = "post_status = 'inherit'";
31+                       if ( in_array( 'private', $q_status ) )
32+                               $r_status[] = "post_status = 'private'";
33+                       if ( in_array( 'publish', $q_status ) )
34+                               $r_status[] = "post_status = 'publish'";
35+                       if ( !empty($r_status) )
36+                               $where .= " AND (" . join( ' OR ', $r_status ) . ")";
37+               } elseif ( !$this->is_singular ) {
38+                       $where .= " AND (post_status = 'publish'";
39+
40                        if ( is_admin() )
41                                $where .= " OR post_status = 'future' OR post_status = 'draft'";
42 
43-                       if ( is_user_logged_in() ) {
44-                               if ( 'post' == $post_type )
45-                                       $cap = 'read_private_posts';
46-                               else
47-                                       $cap = 'read_private_pages';
48+                       $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'";
49 
50-                               if ( current_user_can($cap) )
51-                                       $where .= " OR post_status = 'private'";
52-                               else
53-                               $where .= " OR post_author = $user_ID AND post_status = 'private'";
54-                       }
55-
56-                       $where .= '))';
57+                       $where .= ')';
58                }
59 
60                // Apply filters on where and join prior to paging so that any
61Index: wp-includes/link-template.php
62===================================================================
63--- wp-includes/link-template.php       (revision 5555)
64+++ wp-includes/link-template.php       (working copy)
65@@ -476,9 +476,9 @@
66        $request = preg_replace('|^'. $home_root . '|', '', $request);
67        $request = preg_replace('|^/+|', '', $request);
68       
69-       if ( !$wp_rewrite->using_permalinks() ) {
70+       if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
71                $base = trailingslashit( get_bloginfo( 'home' ) );
72-               
73+
74                if ( $pagenum > 1 ) {
75                        $result = add_query_arg( 'paged', $pagenum, $base . $request );
76                } else {
77Index: wp-includes/capabilities.php
78===================================================================
79--- wp-includes/capabilities.php        (revision 5555)
80+++ wp-includes/capabilities.php        (working copy)
81@@ -445,12 +445,12 @@
82 function current_user_can($capability) {
83        $current_user = wp_get_current_user();
84 
85+       if ( empty($current_user) )
86+               return false;
87+
88        $args = array_slice(func_get_args(), 1);
89        $args = array_merge(array($capability), $args);
90 
91-       if ( empty($current_user) )
92-               return false;
93-
94        return call_user_func_array(array(&$current_user, 'has_cap'), $args);
95 }
96 
97Index: wp-includes/classes.php
98===================================================================
99--- wp-includes/classes.php     (revision 5555)
100+++ wp-includes/classes.php     (working copy)
101@@ -3,7 +3,7 @@
102 class WP {
103        var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
104 
105-       var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
106+       var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status');
107        var $extra_query_vars = array();
108 
109        var $query_vars;
110Index: wp-admin/wp-admin.css
111===================================================================
112--- wp-admin/wp-admin.css       (revision 5555)
113+++ wp-admin/wp-admin.css       (working copy)
114@@ -790,22 +790,17 @@
115        width: 320px;
116 }
117 
118-#searchform {
119+#searchform fieldset {
120        float: left;
121-       margin-right: 1em;
122-       width: 18em;
123+       margin-right: 1.5ex;
124 }
125 
126-#viewarc {
127-       float: left;
128-       width: 23em;
129-       margin-bottom: 1em;
130+#searchform #s {
131+       padding: 4px 3px;
132 }
133 
134-#viewcat {
135+#searchform #post-query-submit {
136        float: left;
137-       width: 30em;
138-       margin-bottom: 1em;
139 }
140 
141 #postcustom .updatemeta, #postcustom .deletemeta {
142Index: wp-admin/edit-post-rows.php
143===================================================================
144--- wp-admin/edit-post-rows.php (revision 0)
145+++ wp-admin/edit-post-rows.php (revision 0)
146@@ -0,0 +1,103 @@
147+<table class="widefat">
148+       <thead>
149+       <tr>
150+
151+<?php foreach($posts_columns as $column_display_name) { ?>
152+       <th scope="col"><?php echo $column_display_name; ?></th>
153+<?php } ?>
154+
155+       </tr>
156+       </thead>
157+       <tbody id="the-list">
158+<?php
159+if ($posts) {
160+$bgcolor = '';
161+while (have_posts()) : the_post();
162+add_filter('the_title','wp_specialchars');
163+$class = ('alternate' == $class) ? '' : 'alternate';
164+?>
165+       <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
166+
167+<?php
168+
169+foreach($posts_columns as $column_name=>$column_display_name) {
170+
171+       switch($column_name) {
172+
173+       case 'id':
174+               ?>
175+               <th scope="row" style="text-align: center"><?php echo $id ?></th>
176+               <?php
177+               break;
178+
179+       case 'date':
180+               ?>
181+               <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
182+               <?php
183+               break;
184+       case 'title':
185+               ?>
186+               <td><?php the_title() ?>
187+               <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
188+               <?php
189+               break;
190+
191+       case 'categories':
192+               ?>
193+               <td><?php the_category(','); ?></td>
194+               <?php
195+               break;
196+
197+       case 'comments':
198+               ?>
199+               <td style="text-align: center">
200+                       <?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
201+                       </td>
202+               <?php
203+               break;
204+
205+       case 'author':
206+               ?>
207+               <td><?php the_author() ?></td>
208+               <?php
209+               break;
210+
211+       case 'control_view':
212+               ?>
213+               <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
214+               <?php
215+               break;
216+
217+       case 'control_edit':
218+               ?>
219+               <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
220+               <?php
221+               break;
222+
223+       case 'control_delete':
224+               ?>
225+               <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
226+               <?php
227+               break;
228+
229+       default:
230+               ?>
231+               <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
232+               <?php
233+               break;
234+       }
235+}
236+?>
237+       </tr>
238+<?php
239+endwhile;
240+} else {
241+?>
242+  <tr style='background-color: <?php echo $bgcolor; ?>'>
243+    <td colspan="8"><?php _e('No posts found.') ?></td>
244+  </tr>
245+<?php
246+} // end if ($posts)
247+?>
248+       </tbody>
249+</table>
250Index: wp-admin/edit.php
251===================================================================
252--- wp-admin/edit.php   (revision 5555)
253+++ wp-admin/edit.php   (working copy)
254@@ -8,56 +8,38 @@
255 
256 $_GET['m'] = (int) $_GET['m'];
257 
258-$drafts = get_users_drafts( $user_ID );
259-$other_drafts = get_others_drafts( $user_ID);
260+$post_stati = array('draft' => __('Draft'), 'future' => __('Future Dated'), 'private' => __('Private'), 'publish' => __('Published'));
261 
262-if ($drafts || $other_drafts) {
263+$post_status_q = isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ? "&author=$user_ID&post_status=" . $_GET['post_status'] : '';
264 ?>
265+
266 <div class="wrap">
267-<?php if ($drafts) { ?>
268-       <p><strong><?php _e('Your Drafts:') ?></strong>
269-       <?php
270-       $i = 0;
271-       foreach ($drafts as $draft) {
272-               if (0 != $i)
273-                       echo ', ';
274-               $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
275-               if ($draft->post_title == '')
276-                       $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
277-               echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
278-               ++$i;
279-               }
280-       ?>
281-.</p>
282-<?php } ?>
283 
284-<?php if ($other_drafts) { ?>
285-       <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
286-       <?php
287-       $i = 0;
288-       foreach ($other_drafts as $draft) {
289-               if (0 != $i)
290-                       echo ', ';
291-               $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
292-               if ($draft->post_title == '')
293-                       $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
294-               echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
295-               ++$i;
296-               }
297-       ?>
298-       .</p>
299+<?php
300 
301-<?php } ?>
302+wp("what_to_show=posts$post_status_q&posts_per_page=15&posts_per_archive_page=-1");
303 
304-</div>
305-<?php } ?>
306+do_action('restrict_manage_posts');
307 
308-<div class="wrap">
309-<h2>
310-<?php
311+// define the columns to display, the syntax is 'internal name' => 'display name'
312+$posts_columns = array(
313+       'id'         => '<div style="text-align: center">' . __('ID') . '</div>',
314+       'date'       => __('When'),
315+       'title'      => __('Title'),
316+       'categories' => __('Categories'),
317+       'comments'   => '<div style="text-align: center">' . __('Comments') . '</div>',
318+       'author'     => __('Author')
319+);
320+$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
321 
322-wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
323+// you can not edit these at the moment
324+$posts_columns['control_view']   = '';
325+$posts_columns['control_edit']   = '';
326+$posts_columns['control_delete'] = '';
327 
328+?>
329+
330+<h2><?php
331 if ( is_month() ) {
332        single_month_title(' ');
333 } elseif ( is_search() ) {
334@@ -70,26 +52,38 @@
335        else
336                _e('Previous Posts');
337 }
338-?>
339-</h2>
340+?></h2>
341 
342+
343 <form name="searchform" id="searchform" action="" method="get">
344-  <fieldset>
345-  <legend><?php _e('Search Posts&hellip;') ?></legend>
346-  <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
347-  <input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
348-  </fieldset>
349-</form>
350+       <fieldset><legend><?php _e('Search terms&hellip;'); ?></legend>
351+               <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
352+       </fieldset>
353 
354-<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
355+       <fieldset><legend><?php _e('Post Type&hellip;'); ?></legend>
356+               <select name='post_status'>
357+                       <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
358+<?php  foreach ( $post_stati as $status => $label ) : ?>
359+                       <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label; ?></option>
360+<?php  endforeach; ?>
361+               </select>
362+       </fieldset>
363 
364-if ( count($arc_result) ) { ?>
365+<?php
366 
367-<form name="viewarc" id="viewarc" action="" method="get">
368-       <fieldset>
369-       <legend><?php _e('Browse Month&hellip;') ?></legend>
370-       <select name='m'>
371-       <?php
372+
373+$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
374+
375+$arc_result = $wpdb->get_results( $arc_query );
376+
377+$month_count = count($arc_result);
378+
379+if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
380+
381+       <fieldset><legend><?php _e('Month&hellip;') ?></legend>
382+               <select name='m'>
383+                       <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
384+               <?php
385                foreach ($arc_result as $arc_row) {
386                        if ( $arc_row->yyear == 0 )
387                                continue;
388@@ -104,148 +98,45 @@
389                        echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
390                        echo "</option>\n";
391                }
392-       ?>
393-       </select>
394-               <input type="submit" name="submit" value="<?php _e('Show Month') ?>" class="button" />
395+               ?>
396+               </select>
397        </fieldset>
398-</form>
399 
400 <?php } ?>
401 
402-<form name="viewcat" id="viewcat" action="" method="get">
403-       <fieldset>
404-       <legend><?php _e('Browse Category&hellip;') ?></legend>
405-       <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
406-       <input type="submit" name="submit" value="<?php _e('Show Category') ?>" class="button" />
407+       <fieldset><legend><?php _e('Category&hellip;') ?></legend>
408+               <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
409        </fieldset>
410+       <input type="submit" id="post-query-submit" value="<?php _e('Go &#187;'); ?>" class="button" />
411 </form>
412 
413-<?php do_action('restrict_manage_posts'); ?>
414-
415 <br style="clear:both;" />
416 
417 <?php
418-// define the columns to display, the syntax is 'internal name' => 'display name'
419-$posts_columns = array(
420-       'id'         => '<div style="text-align: center">' . __('ID') . '</div>',
421-       'date'       => __('When'),
422-       'title'      => __('Title'),
423-       'categories' => __('Categories'),
424-       'comments'   => '<div style="text-align: center">' . __('Comments') . '</div>',
425-       'author'     => __('Author')
426-);
427-$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
428+if ( $post_status_q && ( false !== strpos($post_status_q, 'draft') || false !== strpos($post_status_q, 'private') ) ) {
429+       echo '<h3>' . __('Your Posts') . "</h3>\n";
430+       include( 'edit-post-rows.php' );
431 
432-// you can not edit these at the moment
433-$posts_columns['control_view']   = '';
434-$posts_columns['control_edit']   = '';
435-$posts_columns['control_delete'] = '';
436+       $editable_ids = get_editable_user_ids( $user_ID );
437 
438-?>
439+       if ( $editable_ids && count($editable_ids) > 1 ) {
440+               $_editable_ids = join(',', array_diff($editable_ids, array($user_ID)));
441 
442-<table class="widefat">
443-       <thead>
444-       <tr>
445+               $post_status_q = "&post_status=" . $_GET['post_status'];
446 
447-<?php foreach($posts_columns as $column_display_name) { ?>
448-       <th scope="col"><?php echo $column_display_name; ?></th>
449-<?php } ?>
450+               unset($GLOBALS['day']); // setup_postdata does this
451+               wp("what_to_show=posts&author=$_editable_ids$post_status_q&posts_per_archive_page=-1");
452 
453-       </tr>
454-       </thead>
455-       <tbody id="the-list">
456-<?php
457-if ($posts) {
458-$bgcolor = '';
459-while (have_posts()) : the_post();
460-add_filter('the_title','wp_specialchars');
461-$class = ('alternate' == $class) ? '' : 'alternate';
462-?>
463-       <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
464-
465-<?php
466-
467-foreach($posts_columns as $column_name=>$column_display_name) {
468-
469-       switch($column_name) {
470-
471-       case 'id':
472-               ?>
473-               <th scope="row" style="text-align: center"><?php echo $id ?></th>
474-               <?php
475-               break;
476-
477-       case 'date':
478-               ?>
479-               <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
480-               <?php
481-               break;
482-       case 'title':
483-               ?>
484-               <td><?php the_title() ?>
485-               <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
486-               <?php
487-               break;
488-
489-       case 'categories':
490-               ?>
491-               <td><?php the_category(','); ?></td>
492-               <?php
493-               break;
494-
495-       case 'comments':
496-               ?>
497-               <td style="text-align: center">
498-                       <?php comments_number("<a href='edit.php?p=$id&amp;c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
499-                       </td>
500-               <?php
501-               break;
502-
503-       case 'author':
504-               ?>
505-               <td><?php the_author() ?></td>
506-               <?php
507-               break;
508-
509-       case 'control_view':
510-               ?>
511-               <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
512-               <?php
513-               break;
514-
515-       case 'control_edit':
516-               ?>
517-               <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
518-               <?php
519-               break;
520-
521-       case 'control_delete':
522-               ?>
523-               <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
524-               <?php
525-               break;
526-
527-       default:
528-               ?>
529-               <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
530-               <?php
531-               break;
532+               if ( have_posts() ) {
533+                       echo '<h3>' . __("Others' Posts") . "</h3>\n";
534+                       include( 'edit-post-rows.php' );
535+               }
536        }
537+
538+} else {
539+       include( 'edit-post-rows.php' );
540 }
541 ?>
542-       </tr>
543-<?php
544-endwhile;
545-} else {
546-?>
547-  <tr style='background-color: <?php echo $bgcolor; ?>'>
548-    <td colspan="8"><?php _e('No posts found.') ?></td>
549-  </tr>
550-<?php
551-} // end if ($posts)
552-?>
553-       </tbody>
554-</table>
555 
556 <div id="ajax-response"></div>
557 
558@@ -255,6 +146,7 @@
559 </div>
560 
561 <?php
562+
563 if ( 1 == count($posts) ) {
564 
565        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
566@@ -301,6 +193,5 @@
567        ?>
568 <?php } ?>
569 </div>
570-<?php
571- include('admin-footer.php');
572-?>
573+
574+<?php include('admin-footer.php'); ?>