root/trunk/wp-admin/edit-pages.php

Revision 8720, 7.6 kB (checked in by azaozz, 6 days ago)

Reply to comments from admin, first run, see #7435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * Edit Pages Administration Panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11
12 // Handle bulk deletes
13 if ( isset($_GET['action']) && isset($_GET['delete']) ) {
14     check_admin_referer('bulk-pages');
15     if ( $_GET['action'] == 'delete' ) {
16         foreach( (array) $_GET['delete'] as $post_id_del ) {
17             $post_del = & get_post($post_id_del);
18
19             if ( !current_user_can('delete_page', $post_id_del) )
20                 wp_die( __('You are not allowed to delete this page.') );
21
22             if ( $post_del->post_type == 'attachment' ) {
23                 if ( ! wp_delete_attachment($post_id_del) )
24                     wp_die( __('Error in deleting...') );
25             } else {
26                 if ( !wp_delete_post($post_id_del) )
27                     wp_die( __('Error in deleting...') );
28             }
29         }
30
31         $sendback = wp_get_referer();
32         if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
33         elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
34         $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
35
36         wp_redirect($sendback);
37         exit();
38     }
39 } elseif ( !empty($_GET['_wp_http_referer']) ) {
40      wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
41      exit;
42 }
43
44 $title = __('Pages');
45 $parent_file = 'edit.php';
46 wp_enqueue_script('admin-forms');
47
48 $post_stati  = array(    //    array( adj, noun )
49         'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
50         'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
51         'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
52         'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
53         'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)'))
54     );
55
56 $post_status_label = __('Pages');
57 $post_status_q = '';
58 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
59     $post_status_label = $post_stati[$_GET['post_status']][1];
60     $post_status_q = '&post_status=' . $_GET['post_status'];
61     $post_status_q .= '&perm=readable';
62 }
63
64 $query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc";
65
66 $query_str = apply_filters('manage_pages_query', $query_str);
67 wp($query_str);
68
69 if ( is_singular() )
70     wp_enqueue_script( 'admin-comments' );
71
72 require_once('admin-header.php');
73
74 ?>
75 <div class="wrap">
76 <form id="posts-filter" action="" method="get">
77 <h2><?php
78 // Use $_GET instead of is_ since they can override each other
79 $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
80 $h2_author = '';
81 if ( isset($_GET['author']) && $_GET['author'] ) {
82     $author_user = get_userdata( (int) $_GET['author'] );
83     $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
84 }
85 printf( _c( '%1$s%2$s%3$s (<a href="%4$s">Add New</a>)|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search, 'page-new.php' );
86 ?></h2>
87
88 <ul class="subsubsub">
89 <?php
90
91 $avail_post_stati = get_available_post_statuses('page');
92
93 $status_links = array();
94 $num_posts = wp_count_posts('page', 'readable');
95 $class = empty($_GET['post_status']) ? ' class="current"' : '';
96 $status_links[] = "<li><a href=\"edit-pages.php\"$class>".__('All Pages')."</a>";
97 foreach ( $post_stati as $status => $label ) {
98     $class = '';
99
100     if ( !in_array($status, $avail_post_stati) )
101         continue;
102
103     if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
104         $class = ' class="current"';
105
106     $status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
107     sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), number_format_i18n( $num_posts->$status ) ) . '</a>';
108 }
109 echo implode(' |</li>', $status_links) . '</li>';
110 unset($status_links);
111 ?>
112 </ul>
113
114 <?php if ( isset($_GET['post_status'] ) ) : ?>
115 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
116 <?php
117 endif;
118 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
119 <div id="message" class="updated fade"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit page'); ?></a></p></div>
120 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
121 endif;
122 ?>
123
124 <p id="post-search">
125     <label class="hidden" for="post-search-input"><?php _e( 'Search Pages' ); ?>:</label>
126     <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
127     <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
128 </p>
129
130 <div class="tablenav">
131
132 <?php
133 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
134 if ( empty($pagenum) )
135     $pagenum = 1;
136 if( ! isset( $per_page ) || $per_page < 0 )
137     $per_page = 20;
138
139 $num_pages = ceil(count($posts) / $per_page);
140 $page_links = paginate_links( array(
141     'base' => add_query_arg( 'pagenum', '%#%' ),
142     'format' => '',
143     'total' => $num_pages,
144     'current' => $pagenum
145 ));
146
147 if ( $page_links )
148     echo "<div class='tablenav-pages'>$page_links</div>";
149 ?>
150
151 <div class="alignleft">
152 <select name="action">
153 <option value="" selected><?php _e('Actions'); ?></option>
154 <option value="delete"><?php _e('Delete'); ?></option>
155 </select>
156 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
157 <?php wp_nonce_field('bulk-pages'); ?>
158 </div>
159
160 <br class="clear" />
161 </div>
162
163 <br class="clear" />
164
165 <?php
166
167 $all = !( $h2_search || $post_status_q );
168
169 if ($posts) {
170 ?>
171 <table class="widefat">
172   <thead>
173   <tr>
174 <?php $posts_columns = wp_manage_pages_columns(); ?>
175 <?php foreach($posts_columns as $post_column_key => $column_display_name) {
176     if ( 'cb' === $post_column_key )
177         $class = ' class="check-column"';
178     elseif ( 'comments' === $post_column_key )
179         $class = ' class="num"';
180     else
181         $class = '';
182 ?>
183     <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
184 <?php } ?>
185   </tr>
186   </thead>
187   <tbody>
188   <?php page_rows($posts, $pagenum, $per_page); ?>
189   </tbody>
190 </table>
191
192 </form>
193
194 <div id="ajax-response"></div>
195
196 <?php
197 } else {
198 ?>
199 </form>
200 <p><?php _e('No pages found.') ?></p>
201 <?php
202 } // end if ($posts)
203 ?>
204
205 <div class="tablenav">
206 <?php
207 if ( $page_links )
208     echo "<div class='tablenav-pages'>$page_links</div>";
209 ?>
210 <br class="clear" />
211 </div>
212
213 <?php
214
215 if ( 1 == count($posts) && is_singular() ) :
216
217     $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
218     if ( $comments ) :
219         // Make sure comments, post, and post_author are cached
220         update_comment_cache($comments);
221         $post = get_post($id);
222         $authordata = get_userdata($post->post_author);
223     ?>
224
225 <br class="clear" />
226
227 <table class="widefat" style="margin-top: .5em">
228 <thead>
229   <tr>
230     <th scope="col"><?php _e('Comment') ?></th>
231     <th scope="col"><?php _e('Date') ?></th>
232     <th scope="col"><?php _e('Actions') ?></th>
233   </tr>
234 </thead>
235 <tbody id="the-comment-list" class="list:comment">
236 <?php
237     foreach ($comments as $comment)
238         _wp_comment_row( $comment->comment_ID, 'detail', false, false );
239 ?>
240 </tbody>
241 </table>
242
243 <?php
244 wp_comment_reply();
245 endif; // comments
246 endif; // posts;
247
248 ?>
249
250 </div>
251
252 <?php include('admin-footer.php'); ?>
Note: See TracBrowser for help on using the browser.