source: trunk/www.guidonia.net/wp/wp-admin/edit-pages.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 10.8 KB
Line 
1<?php
2/**
3 * Edit Pages Administration Panel.
4 *
5 * @package WordPress
6 * @subpackage Administration
7 */
8
9/** WordPress Administration Bootstrap */
10require_once('admin.php');
11
12// Handle bulk actions
13if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
14 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
15
16 switch ( $doaction ) {
17 case 'delete':
18 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
19 check_admin_referer('bulk-pages');
20 $deleted = 0;
21 foreach( (array) $_GET['post'] as $post_id_del ) {
22 $post_del = & get_post($post_id_del);
23
24 if ( !current_user_can('delete_page', $post_id_del) )
25 wp_die( __('You are not allowed to delete this page.') );
26
27 if ( $post_del->post_type == 'attachment' ) {
28 if ( ! wp_delete_attachment($post_id_del) )
29 wp_die( __('Error in deleting...') );
30 } else {
31 if ( !wp_delete_post($post_id_del) )
32 wp_die( __('Error in deleting...') );
33 }
34 $deleted++;
35 }
36 }
37 break;
38 case 'edit':
39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
40 check_admin_referer('bulk-pages');
41
42 if ( -1 == $_GET['_status'] ) {
43 $_GET['post_status'] = null;
44 unset($_GET['_status'], $_GET['post_status']);
45 } else {
46 $_GET['post_status'] = $_GET['_status'];
47 }
48
49 $done = bulk_edit_posts($_GET);
50 }
51 break;
52 }
53
54 $sendback = wp_get_referer();
55 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
56 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
57 if ( isset($done) ) {
58 $done['updated'] = count( $done['updated'] );
59 $done['skipped'] = count( $done['skipped'] );
60 $done['locked'] = count( $done['locked'] );
61 $sendback = add_query_arg( $done, $sendback );
62 }
63 if ( isset($deleted) )
64 $sendback = add_query_arg('deleted', $deleted, $sendback);
65 wp_redirect($sendback);
66 exit();
67} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
68 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
69 exit;
70}
71
72if ( empty($title) )
73 $title = __('Edit Pages');
74$parent_file = 'edit-pages.php';
75wp_enqueue_script('inline-edit-post');
76
77$post_stati = array( // array( adj, noun )
78 'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')),
79 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')),
80 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')),
81 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')),
82 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page'))
83 );
84
85$post_stati = apply_filters('page_stati', $post_stati);
86
87$query = array('post_type' => 'page', 'orderby' => 'menu_order title',
88 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
89
90$post_status_label = __('Pages');
91if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
92 $post_status_label = $post_stati[$_GET['post_status']][1];
93 $query['post_status'] = $_GET['post_status'];
94 $query['perm'] = 'readable';
95}
96
97$query = apply_filters('manage_pages_query', $query);
98wp($query);
99
100if ( is_singular() ) {
101 wp_enqueue_script( 'admin-comments' );
102 enqueue_comment_hotkeys_js();
103}
104
105require_once('admin-header.php'); ?>
106
107<div class="wrap">
108<?php screen_icon(); ?>
109<h2><?php echo esc_html( $title );
110if ( isset($_GET['s']) && $_GET['s'] )
111 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
112</h2>
113
114<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
115<div id="message" class="updated fade"><p>
116<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
117 printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
118 unset($_GET['updated']);
119}
120
121if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
122 printf( _n( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
123 unset($_GET['skipped']);
124}
125
126if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
127 printf( _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) );
128 unset($_GET['locked']);
129}
130
131if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
132 printf( _n( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
133 unset($_GET['deleted']);
134}
135$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
136?>
137</p></div>
138<?php } ?>
139
140<?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
141<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>
142<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
143endif; ?>
144
145<form id="posts-filter" action="" method="get">
146<ul class="subsubsub">
147<?php
148
149$avail_post_stati = get_available_post_statuses('page');
150if ( empty($locked_post_status) ) :
151$status_links = array();
152$num_posts = wp_count_posts('page', 'readable');
153$total_posts = array_sum( (array) $num_posts );
154$class = empty($_GET['post_status']) ? ' class="current"' : '';
155$status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . '</a>';
156foreach ( $post_stati as $status => $label ) {
157 $class = '';
158
159 if ( !in_array($status, $avail_post_stati) )
160 continue;
161
162 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
163 $class = ' class="current"';
164
165 $status_links[] = "<li><a href='edit-pages.php?post_status=$status'$class>" . sprintf( _nx( $label[2][0], $label[2][1], $num_posts->$status, $label[2][2] ), number_format_i18n( $num_posts->$status ) ) . '</a>';
166}
167echo implode( " |</li>\n", $status_links ) . '</li>';
168unset($status_links);
169endif;
170?>
171</ul>
172
173<p class="search-box">
174 <label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label>
175 <input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" />
176 <input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" />
177</p>
178
179<?php if ( isset($_GET['post_status'] ) ) : ?>
180<input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']) ?>" />
181<?php endif; ?>
182
183<?php if ($posts) { ?>
184
185<div class="tablenav">
186
187<?php
188$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
189if ( empty($pagenum) )
190 $pagenum = 1;
191$per_page = get_user_option('edit_pages_per_page');
192if ( empty( $per_page ) || $per_page < 0 )
193 $per_page = 20;
194
195$num_pages = ceil($wp_query->post_count / $per_page);
196$page_links = paginate_links( array(
197 'base' => add_query_arg( 'pagenum', '%#%' ),
198 'format' => '',
199 'prev_text' => __('&laquo;'),
200 'next_text' => __('&raquo;'),
201 'total' => $num_pages,
202 'current' => $pagenum
203));
204
205if ( $page_links ) : ?>
206<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
207 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
208 number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
209 number_format_i18n( $wp_query->post_count ),
210 $page_links
211); echo $page_links_text; ?></div>
212<?php endif; ?>
213
214<div class="alignleft actions">
215<select name="action">
216<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
217<option value="edit"><?php _e('Edit'); ?></option>
218<option value="delete"><?php _e('Delete'); ?></option>
219</select>
220<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
221<?php wp_nonce_field('bulk-pages'); ?>
222</div>
223
224<br class="clear" />
225</div>
226
227<div class="clear"></div>
228
229<table class="widefat page fixed" cellspacing="0">
230 <thead>
231 <tr>
232<?php print_column_headers('edit-pages'); ?>
233 </tr>
234 </thead>
235
236 <tfoot>
237 <tr>
238<?php print_column_headers('edit-pages', false); ?>
239 </tr>
240 </tfoot>
241
242 <tbody>
243 <?php page_rows($posts, $pagenum, $per_page); ?>
244 </tbody>
245</table>
246
247<div class="tablenav">
248<?php
249if ( $page_links )
250 echo "<div class='tablenav-pages'>$page_links_text</div>";
251?>
252
253<div class="alignleft actions">
254<select name="action2">
255<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
256<option value="edit"><?php _e('Edit'); ?></option>
257<option value="delete"><?php _e('Delete'); ?></option>
258</select>
259<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
260</div>
261
262<br class="clear" />
263</div>
264
265<?php } else { ?>
266<div class="clear"></div>
267<p><?php _e('No pages found.') ?></p>
268<?php
269} // end if ($posts)
270?>
271
272</form>
273
274<?php inline_edit_row( 'page' ) ?>
275
276<div id="ajax-response"></div>
277
278
279<?php
280
281if ( 1 == count($posts) && is_singular() ) :
282
283 $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
284 if ( $comments ) :
285 // Make sure comments, post, and post_author are cached
286 update_comment_cache($comments);
287 $post = get_post($id);
288 $authordata = get_userdata($post->post_author);
289 ?>
290
291<br class="clear" />
292
293<table class="widefat" cellspacing="0">
294<thead>
295 <tr>
296 <th scope="col" class="column-comment">
297 <?php /* translators: column name */ echo _x('Comment', 'column name') ?>
298 </th>
299 <th scope="col" class="column-author"><?php _e('Author') ?></th>
300 <th scope="col" class="column-date"><?php _e('Submitted') ?></th>
301 </tr>
302</thead>
303<tbody id="the-comment-list" class="list:comment">
304<?php
305 foreach ($comments as $comment)
306 _wp_comment_row( $comment->comment_ID, 'single', false, false );
307?>
308</tbody>
309</table>
310
311<?php
312wp_comment_reply();
313endif; // comments
314endif; // posts;
315
316?>
317
318</div>
319
320<?php
321include('admin-footer.php');
Note: See TracBrowser for help on using the repository browser.