Ticket #3945: 3945.diff
File 3945.diff, 18.6 KB (added by , 18 years ago) |
---|
-
wp-includes/query.php
995 995 } 996 996 997 997 if ( $this->is_attachment ) { 998 $where .= " AND (post_type = 'attachment')";998 $where .= " AND post_type = 'attachment'"; 999 999 } elseif ($this->is_page) { 1000 $where .= " AND (post_type = 'page')";1000 $where .= " AND post_type = 'page'"; 1001 1001 } elseif ($this->is_single) { 1002 $where .= " AND (post_type = 'post')";1002 $where .= " AND post_type = 'post'"; 1003 1003 } else { 1004 $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'"; 1004 $where .= " AND post_type = '$post_type'"; 1005 } 1005 1006 1007 if ( isset($q['post_status']) && '' != $q['post_status'] ) { 1008 $q_status = explode(',', $q['post_status']); 1009 $r_status = array(); 1010 if ( in_array( 'draft' , $q_status ) ) 1011 $r_status[] = "post_status = 'draft'"; 1012 if ( in_array( 'future' , $q_status ) ) 1013 $r_status[] = "post_status = 'future'"; 1014 if ( in_array( 'inherit' , $q_status ) ) 1015 $r_status[] = "post_status = 'inherit'"; 1016 if ( in_array( 'private', $q_status ) ) 1017 $r_status[] = "post_status = 'private'"; 1018 if ( in_array( 'publish', $q_status ) ) 1019 $r_status[] = "post_status = 'publish'"; 1020 if ( !empty($r_status) ) 1021 $where .= " AND (" . join( ' OR ', $r_status ) . ")"; 1022 } elseif ( !$this->is_singular ) { 1023 $where .= " AND (post_status = 'publish'"; 1024 1006 1025 if ( is_admin() ) 1007 1026 $where .= " OR post_status = 'future' OR post_status = 'draft'"; 1008 1027 1009 if ( is_user_logged_in() ) { 1010 if ( 'post' == $post_type ) 1011 $cap = 'read_private_posts'; 1012 else 1013 $cap = 'read_private_pages'; 1028 $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID AND post_status = 'private'"; 1014 1029 1015 if ( current_user_can($cap) ) 1016 $where .= " OR post_status = 'private'"; 1017 else 1018 $where .= " OR post_author = $user_ID AND post_status = 'private'"; 1019 } 1020 1021 $where .= '))'; 1030 $where .= ')'; 1022 1031 } 1023 1032 1024 1033 // Apply filters on where and join prior to paging so that any -
wp-includes/link-template.php
476 476 $request = preg_replace('|^'. $home_root . '|', '', $request); 477 477 $request = preg_replace('|^/+|', '', $request); 478 478 479 if ( !$wp_rewrite->using_permalinks() ) {479 if ( !$wp_rewrite->using_permalinks() || is_admin() ) { 480 480 $base = trailingslashit( get_bloginfo( 'home' ) ); 481 481 482 482 if ( $pagenum > 1 ) { 483 483 $result = add_query_arg( 'paged', $pagenum, $base . $request ); 484 484 } else { -
wp-includes/capabilities.php
445 445 function current_user_can($capability) { 446 446 $current_user = wp_get_current_user(); 447 447 448 if ( empty($current_user) ) 449 return false; 450 448 451 $args = array_slice(func_get_args(), 1); 449 452 $args = array_merge(array($capability), $args); 450 453 451 if ( empty($current_user) )452 return false;453 454 454 return call_user_func_array(array(&$current_user, 'has_cap'), $args); 455 455 } 456 456 -
wp-includes/classes.php
3 3 class WP { 4 4 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'); 5 5 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type' );6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status'); 7 7 var $extra_query_vars = array(); 8 8 9 9 var $query_vars; -
wp-admin/edit-post-rows.php
1 <table class="widefat"> 2 <thead> 3 <tr> 4 5 <?php foreach($posts_columns as $column_display_name) { ?> 6 <th scope="col"><?php echo $column_display_name; ?></th> 7 <?php } ?> 8 9 </tr> 10 </thead> 11 <tbody id="the-list"> 12 <?php 13 if ($posts) { 14 $bgcolor = ''; 15 while (have_posts()) : the_post(); 16 add_filter('the_title','wp_specialchars'); 17 $class = ('alternate' == $class) ? '' : 'alternate'; 18 ?> 19 <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'> 20 21 <?php 22 23 foreach($posts_columns as $column_name=>$column_display_name) { 24 25 switch($column_name) { 26 27 case 'id': 28 ?> 29 <th scope="row" style="text-align: center"><?php echo $id ?></th> 30 <?php 31 break; 32 33 case 'date': 34 ?> 35 <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> 36 <?php 37 break; 38 case 'title': 39 ?> 40 <td><?php the_title() ?> 41 <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td> 42 <?php 43 break; 44 45 case 'categories': 46 ?> 47 <td><?php the_category(','); ?></td> 48 <?php 49 break; 50 51 case 'comments': 52 ?> 53 <td style="text-align: center"> 54 <?php comments_number("<a href='edit.php?p=$id&c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('%') . '</a>') ?> 55 </td> 56 <?php 57 break; 58 59 case 'author': 60 ?> 61 <td><?php the_author() ?></td> 62 <?php 63 break; 64 65 case 'control_view': 66 ?> 67 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 68 <?php 69 break; 70 71 case 'control_edit': 72 ?> 73 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 74 <?php 75 break; 76 77 case 'control_delete': 78 ?> 79 <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&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> 80 <?php 81 break; 82 83 default: 84 ?> 85 <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td> 86 <?php 87 break; 88 } 89 } 90 ?> 91 </tr> 92 <?php 93 endwhile; 94 } else { 95 ?> 96 <tr style='background-color: <?php echo $bgcolor; ?>'> 97 <td colspan="8"><?php _e('No posts found.') ?></td> 98 </tr> 99 <?php 100 } // end if ($posts) 101 ?> 102 </tbody> 103 </table> 104 105 <div id="ajax-response"></div> 106 107 <div class="navigation"> 108 <div class="alignleft"><?php next_posts_link(__('« Previous Entries')) ?></div> 109 <div class="alignright"><?php previous_posts_link(__('Next Entries »')) ?></div> 110 </div> -
wp-admin/menu.php
37 37 38 38 $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); 39 39 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 40 $submenu['edit.php'][11] = array(__('Drafts'), 'edit_posts', 'edit-drafts.php'); 40 41 $submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php'); 41 42 $submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); 42 43 $submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php'); -
wp-admin/edit.php
53 53 <?php } ?> 54 54 55 55 <div class="wrap"> 56 <h2>57 56 <?php 58 57 59 58 wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1'); 60 59 60 do_action('restrict_manage_posts'); 61 62 // define the columns to display, the syntax is 'internal name' => 'display name' 63 $posts_columns = array( 64 'id' => '<div style="text-align: center">' . __('ID') . '</div>', 65 'date' => __('When'), 66 'title' => __('Title'), 67 'categories' => __('Categories'), 68 'comments' => '<div style="text-align: center">' . __('Comments') . '</div>', 69 'author' => __('Author') 70 ); 71 $posts_columns = apply_filters('manage_posts_columns', $posts_columns); 72 73 // you can not edit these at the moment 74 $posts_columns['control_view'] = ''; 75 $posts_columns['control_edit'] = ''; 76 $posts_columns['control_delete'] = ''; 77 78 ?> 79 80 <h2><?php 61 81 if ( is_month() ) { 62 82 single_month_title(' '); 63 83 } elseif ( is_search() ) { … … 70 90 else 71 91 _e('Previous Posts'); 72 92 } 73 ?> 74 </h2> 93 ?></h2> 75 94 95 76 96 <form name="searchform" id="searchform" action="" method="get"> 77 97 <fieldset> 78 <legend><?php _e('Search Posts…') ?></legend>98 <legend><?php _e('Search Posts…'); ?></legend> 79 99 <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" /> 80 <input type="submit" name="submit"value="<?php _e('Search') ?>" class="button" />100 <input type="submit" value="<?php _e('Search') ?>" class="button" /> 81 101 </fieldset> 82 102 </form> 83 103 84 <?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");104 <?php 85 105 86 if ( count($arc_result) ) { ?>87 106 107 $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"; 108 109 $arc_result = $wpdb->get_results( $arc_query ); 110 111 $month_count = count($arc_result); 112 113 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> 114 88 115 <form name="viewarc" id="viewarc" action="" method="get"> 89 116 <fieldset> 90 117 <legend><?php _e('Browse Month…') ?></legend> … … 106 133 } 107 134 ?> 108 135 </select> 109 <input type="submit" name="submit"value="<?php _e('Show Month') ?>" class="button" />136 <input type="submit" value="<?php _e('Show Month') ?>" class="button" /> 110 137 </fieldset> 111 138 </form> 112 139 … … 116 143 <fieldset> 117 144 <legend><?php _e('Browse Category…') ?></legend> 118 145 <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?> 119 <input type="submit" name="submit"value="<?php _e('Show Category') ?>" class="button" />146 <input type="submit" value="<?php _e('Show Category') ?>" class="button" /> 120 147 </fieldset> 121 148 </form> 122 149 123 <?php do_action('restrict_manage_posts'); ?>124 125 150 <br style="clear:both;" /> 126 151 127 152 <?php 128 // define the columns to display, the syntax is 'internal name' => 'display name' 129 $posts_columns = array( 130 'id' => '<div style="text-align: center">' . __('ID') . '</div>', 131 'date' => __('When'), 132 'title' => __('Title'), 133 'categories' => __('Categories'), 134 'comments' => '<div style="text-align: center">' . __('Comments') . '</div>', 135 'author' => __('Author') 136 ); 137 $posts_columns = apply_filters('manage_posts_columns', $posts_columns); 153 include( 'edit-post-rows.php' ); 138 154 139 // you can not edit these at the moment140 $posts_columns['control_view'] = '';141 $posts_columns['control_edit'] = '';142 $posts_columns['control_delete'] = '';143 144 ?>145 146 <table class="widefat">147 <thead>148 <tr>149 150 <?php foreach($posts_columns as $column_display_name) { ?>151 <th scope="col"><?php echo $column_display_name; ?></th>152 <?php } ?>153 154 </tr>155 </thead>156 <tbody id="the-list">157 <?php158 if ($posts) {159 $bgcolor = '';160 while (have_posts()) : the_post();161 add_filter('the_title','wp_specialchars');162 $class = ('alternate' == $class) ? '' : 'alternate';163 ?>164 <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>165 166 <?php167 168 foreach($posts_columns as $column_name=>$column_display_name) {169 170 switch($column_name) {171 172 case 'id':173 ?>174 <th scope="row" style="text-align: center"><?php echo $id ?></th>175 <?php176 break;177 178 case 'date':179 ?>180 <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>181 <?php182 break;183 case 'title':184 ?>185 <td><?php the_title() ?>186 <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>187 <?php188 break;189 190 case 'categories':191 ?>192 <td><?php the_category(','); ?></td>193 <?php194 break;195 196 case 'comments':197 ?>198 <td style="text-align: center">199 <?php comments_number("<a href='edit.php?p=$id&c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('%') . '</a>') ?>200 </td>201 <?php202 break;203 204 case 'author':205 ?>206 <td><?php the_author() ?></td>207 <?php208 break;209 210 case 'control_view':211 ?>212 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>213 <?php214 break;215 216 case 'control_edit':217 ?>218 <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>219 <?php220 break;221 222 case 'control_delete':223 ?>224 <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&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>225 <?php226 break;227 228 default:229 ?>230 <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>231 <?php232 break;233 }234 }235 ?>236 </tr>237 <?php238 endwhile;239 } else {240 ?>241 <tr style='background-color: <?php echo $bgcolor; ?>'>242 <td colspan="8"><?php _e('No posts found.') ?></td>243 </tr>244 <?php245 } // end if ($posts)246 ?>247 </tbody>248 </table>249 250 <div id="ajax-response"></div>251 252 <div class="navigation">253 <div class="alignleft"><?php next_posts_link(__('« Previous Entries')) ?></div>254 <div class="alignright"><?php previous_posts_link(__('Next Entries »')) ?></div>255 </div>256 257 <?php258 155 if ( 1 == count($posts) ) { 259 156 260 157 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date"); -
wp-admin/edit-drafts.php
1 <?php 2 require_once('admin.php'); 3 4 $title = __('Drafts'); 5 $parent_file = 'edit.php'; 6 require_once('admin-header.php'); 7 8 $found_drafts = false; 9 10 if ( isset($_GET['m']) ) 11 $_GET['m'] = (int) $_GET['m']; 12 ?> 13 14 <div class="wrap"> 15 16 <?php 17 wp("what_to_show=posts&author=$user_ID&post_status=draft&posts_per_archive_page=-1"); 18 19 do_action('restrict_manage_drafts'); 20 21 // define the columns to display, the syntax is 'internal name' => 'display name' 22 $posts_columns = array( 23 'id' => '<div style="text-align: center">' . __('ID') . '</div>', 24 'date' => __('When'), 25 'title' => __('Title'), 26 'categories' => __('Categories'), 27 'comments' => '<div style="text-align: center">' . __('Comments') . '</div>', 28 'author' => __('Author') 29 ); 30 $posts_columns = apply_filters('manage_drafts_columns', $posts_columns); 31 32 // you can not edit these at the moment 33 $posts_columns['control_view'] = ''; 34 $posts_columns['control_edit'] = ''; 35 $posts_columns['control_delete'] = ''; 36 37 ?> 38 39 <h2><?php 40 if ( is_month() ) 41 printf(__('Drafts from %s'), single_month_title(' ', false) ); 42 elseif ( is_search() ) 43 printf(__('Search drafts for “%s”'), wp_specialchars($_GET['s']) ); 44 else 45 _e('Drafts'); 46 ?></h2> 47 48 <form name="searchform" id="searchform" action="" method="get"> 49 <fieldset> 50 <legend><?php _e('Search Drafts…'); ?></legend> 51 <input type="text" name="s" id="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" /> 52 <input type="submit" value="<?php _e('Search') ?>" class="button" /> 53 </fieldset> 54 </form> 55 56 <?php 57 58 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' ORDER BY post_date DESC"; 59 60 $arc_result = $wpdb->get_results( $arc_query ); 61 62 $month_count = count($arc_result); 63 64 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> 65 66 <form name="viewarc" id="viewarc" action="" method="get"> 67 <fieldset> 68 <legend><?php _e('Browse Month…') ?></legend> 69 <select name='m'> 70 <?php 71 foreach ($arc_result as $arc_row) { 72 if ( $arc_row->yyear == 0 ) 73 continue; 74 $arc_row->mmonth = zeroise($arc_row->mmonth, 2); 75 76 if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] ) 77 $default = 'selected="selected"'; 78 else 79 $default = null; 80 81 echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>"; 82 echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear"; 83 echo "</option>\n"; 84 } 85 ?> 86 </select> 87 <input type="submit" value="<?php _e('Show Month') ?>" class="button" /> 88 </fieldset> 89 </form> 90 91 <?php } ?> 92 93 <form name="viewcat" id="viewcat" action="" method="get"> 94 <fieldset> 95 <legend><?php _e('Browse Category…') ?></legend> 96 <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?> 97 <input type="submit" value="<?php _e('Show Category') ?>" class="button" /> 98 </fieldset> 99 </form> 100 101 <br style="clear:both;" /> 102 103 <?php 104 105 if ( have_posts() ) { 106 $found_drafts = true; 107 echo '<h3>' . __('Your Drafts') . "</h3>\n"; 108 include( 'edit-post-rows.php' ); 109 } 110 111 $editable_ids = get_editable_user_ids( $user_ID ); 112 113 if ( $editable_ids && count($editable_ids) > 1 ) { 114 $_editable_ids = join(',', array_diff($editable_ids, array($user_ID))); 115 116 unset($GLOBALS['day']); // setup_postdata does this 117 wp("what_to_show=posts&author=$_editable_ids&post_status=draft&posts_per_archive_page=-1"); 118 119 if ( have_posts() ) { 120 $found_drafts = true; 121 echo '<h3>' . __('Others Drafts') . "</h3>\n"; 122 include( 'edit-post-rows.php' ); 123 } 124 } 125 126 if ( !$found_drafts ) 127 echo '<p>' . __('There are no drafts') . "</p>\n"; 128 129 ?> 130 131 </div> 132 133 <?php include('admin-footer.php'); ?>