1
|
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 |
if ( !current_user_can('edit_pages') ) |
|
13 |
wp_die(__('Cheatin’ uh?')); |
|
14 |
|
|
15 |
// Handle bulk actions |
|
16 |
if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { |
|
17 |
check_admin_referer('bulk-pages'); |
|
18 |
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); |
|
19 |
|
|
20 |
if ( strpos($sendback, 'page.php') !== false ) |
|
21 |
$sendback = admin_url('page-new.php'); |
|
22 |
|
|
23 |
if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { |
|
24 |
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); |
|
25 |
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = %s", $post_status ) ); |
|
26 |
$doaction = 'delete'; |
|
27 |
} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['post']) || isset($_GET['ids']) ) ) { |
|
28 |
$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']); |
|
29 |
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; |
|
30 |
} else { |
|
31 |
wp_redirect( admin_url('edit-pages.php') ); |
|
32 |
} |
|
33 |
|
|
34 |
switch ( $doaction ) { |
|
35 |
case 'trash': |
|
36 |
$trashed = 0; |
|
37 |
foreach( (array) $post_ids as $post_id ) { |
|
38 |
if ( !current_user_can('delete_page', $post_id) ) |
|
39 |
wp_die( __('You are not allowed to move this page to the trash.') ); |
|
40 |
|
|
41 |
if ( !wp_trash_post($post_id) ) |
|
42 |
wp_die( __('Error in moving to trash...') ); |
|
43 |
|
|
44 |
$trashed++; |
|
45 |
} |
|
46 |
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback ); |
|
47 |
break; |
|
48 |
case 'untrash': |
|
49 |
$untrashed = 0; |
|
50 |
foreach( (array) $post_ids as $post_id ) { |
|
51 |
if ( !current_user_can('delete_page', $post_id) ) |
|
52 |
wp_die( __('You are not allowed to restore this page from the trash.') ); |
|
53 |
|
|
54 |
if ( !wp_untrash_post($post_id) ) |
|
55 |
wp_die( __('Error in restoring from trash...') ); |
|
56 |
|
|
57 |
$untrashed++; |
|
58 |
} |
|
59 |
$sendback = add_query_arg('untrashed', $untrashed, $sendback); |
|
60 |
break; |
|
61 |
case 'delete': |
|
62 |
$deleted = 0; |
|
63 |
foreach( (array) $post_ids as $post_id ) { |
|
64 |
$post_del = & get_post($post_id); |
|
65 |
|
|
66 |
if ( !current_user_can('delete_page', $post_id) ) |
|
67 |
wp_die( __('You are not allowed to delete this page.') ); |
|
68 |
|
|
69 |
if ( $post_del->post_type == 'attachment' ) { |
|
70 |
if ( ! wp_delete_attachment($post_id) ) |
|
71 |
wp_die( __('Error in deleting...') ); |
|
72 |
} else { |
|
73 |
if ( !wp_delete_post($post_id) ) |
|
74 |
wp_die( __('Error in deleting...') ); |
|
75 |
} |
|
76 |
$deleted++; |
|
77 |
} |
|
78 |
$sendback = add_query_arg('deleted', $deleted, $sendback); |
|
79 |
break; |
|
80 |
case 'edit': |
|
81 |
$_GET['post_type'] = 'page'; |
|
82 |
$done = bulk_edit_posts($_GET); |
|
83 |
|
|
84 |
if ( is_array($done) ) { |
|
85 |
$done['updated'] = count( $done['updated'] ); |
|
86 |
$done['skipped'] = count( $done['skipped'] ); |
|
87 |
$done['locked'] = count( $done['locked'] ); |
|
88 |
$sendback = add_query_arg( $done, $sendback ); |
|
89 |
} |
|
90 |
break; |
|
91 |
} |
|
92 |
|
|
93 |
if ( isset($_GET['action']) ) |
|
94 |
$sendback = remove_query_arg( array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback ); |
|
95 |
|
|
96 |
wp_redirect($sendback); |
|
97 |
exit(); |
|
98 |
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { |
|
99 |
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); |
|
100 |
exit; |
|
101 |
} |
|
102 |
|
|
103 |
if ( empty($title) ) |
|
104 |
$title = __('Edit Pages'); |
|
105 |
$parent_file = 'edit-pages.php'; |
|
106 |
wp_enqueue_script('inline-edit-post'); |
|
107 |
|
|
108 |
$post_stati = array( // array( adj, noun ) |
|
109 |
'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')), |
|
110 |
'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), |
|
111 |
'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')), |
|
112 |
'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')), |
|
113 |
'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), |
|
114 |
'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')) |
|
115 |
); |
|
116 |
|
|
117 |
if ( !EMPTY_TRASH_DAYS ) |
|
118 |
unset($post_stati['trash']); |
|
119 |
|
|
120 |
$post_stati = apply_filters('page_stati', $post_stati); |
|
121 |
|
|
122 |
$query = array('post_type' => 'page', 'orderby' => 'menu_order title', |
|
123 |
'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc'); |
|
124 |
|
|
125 |
$post_status_label = __('Pages'); |
|
126 |
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { |
|
127 |
$post_status_label = $post_stati[$_GET['post_status']][1]; |
|
128 |
$query['post_status'] = $_GET['post_status']; |
|
129 |
$query['perm'] = 'readable'; |
|
130 |
} |
|
131 |
|
|
132 |
$query = apply_filters('manage_pages_query', $query); |
|
133 |
wp($query); |
|
134 |
|
|
135 |
if ( is_singular() ) { |
|
136 |
wp_enqueue_script( 'admin-comments' ); |
|
137 |
enqueue_comment_hotkeys_js(); |
|
138 |
} |
|
139 |
|
|
140 |
require_once('admin-header.php'); ?> |
|
141 |
|
|
142 |
<div class="wrap"> |
|
143 |
<?php screen_icon(); ?> |
|
144 |
<h2><?php echo esc_html( $title ); ?> <a href="page-new.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php |
|
145 |
if ( isset($_GET['s']) && $_GET['s'] ) |
|
146 |
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> |
|
147 |
</h2> |
|
148 |
|
|
149 |
<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> |
|
150 |
<div id="message" class="updated fade"><p> |
|
151 |
<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { |
|
152 |
printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); |
|
153 |
unset($_GET['updated']); |
|
154 |
} |
|
155 |
if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) { |
|
156 |
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'] ) ); |
|
157 |
unset($_GET['skipped']); |
|
158 |
} |
|
159 |
if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { |
|
160 |
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'] ) ); |
|
161 |
unset($_GET['locked']); |
|
162 |
} |
|
163 |
if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { |
|
164 |
printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); |
|
165 |
unset($_GET['deleted']); |
|
166 |
} |
|
167 |
if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { |
|
168 |
printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); |
|
169 |
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0; |
|
170 |
echo ' <a href="' . esc_url( wp_nonce_url( "edit-pages.php?doaction=undo&action=untrash&ids=$ids", "bulk-pages" ) ) . '">' . __('Undo') . '</a><br />'; |
|
171 |
unset($_GET['trashed']); |
|
172 |
} |
|
173 |
if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { |
|
174 |
printf( _n( 'Page restored from the trash.', '%s pages restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); |
|
175 |
unset($_GET['untrashed']); |
|
176 |
} |
|
177 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); |
|
178 |
?> |
|
179 |
</p></div> |
|
180 |
<?php } ?> |
|
181 |
|
|
182 |
<?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
|
183 |
<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> |
|
184 |
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
|
185 |
endif; ?> |
|
186 |
|
|
187 |
<form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get"> |
|
188 |
<ul class="subsubsub"> |
|
189 |
<?php |
|
190 |
|
|
191 |
$avail_post_stati = get_available_post_statuses('page'); |
|
192 |
if ( empty($locked_post_status) ) : |
|
193 |
$status_links = array(); |
|
194 |
$num_posts = wp_count_posts('page', 'readable'); |
|
195 |
$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; |
|
196 |
$class = empty($_GET['post_status']) ? ' class="current"' : ''; |
|
197 |
$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>'; |
|
198 |
foreach ( $post_stati as $status => $label ) { |
|
199 |
$class = ''; |
|
200 |
|
|
201 |
if ( !in_array($status, $avail_post_stati) || $num_posts->$status <= 0 ) |
|
202 |
continue; |
|
203 |
|
|
204 |
if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] ) |
|
205 |
$class = ' class="current"'; |
|
206 |
|
|
207 |
$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>'; |
|
208 |
} |
|
209 |
echo implode( " |</li>\n", $status_links ) . '</li>'; |
|
210 |
unset($status_links); |
|
211 |
endif; |
|
212 |
?> |
|
213 |
</ul> |
|
214 |
|
|
215 |
<p class="search-box"> |
|
216 |
<label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label> |
|
217 |
<input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" /> |
|
218 |
<input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" /> |
|
219 |
</p> |
|
220 |
|
|
221 |
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" /> |
|
222 |
|
|
223 |
<?php if ($posts) { ?> |
|
224 |
|
|
225 |
<div class="tablenav"> |
|
226 |
|
|
227 |
<?php |
|
228 |
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
|
229 |
if ( empty($pagenum) ) |
|
230 |
$pagenum = 1; |
|
231 |
$per_page = (int) get_user_option( 'edit_pages_per_page', 0, false ); |
|
232 |
if ( empty( $per_page ) || $per_page < 1 ) |
|
233 |
$per_page = 20; |
|
234 |
$per_page = apply_filters( 'edit_pages_per_page', $per_page ); |
|
235 |
|
|
236 |
$num_pages = ceil($wp_query->post_count / $per_page); |
|
237 |
$page_links = paginate_links( array( |
|
238 |
'base' => add_query_arg( 'pagenum', '%#%' ), |
|
239 |
'format' => '', |
|
240 |
'prev_text' => __('«'), |
|
241 |
'next_text' => __('»'), |
|
242 |
'total' => $num_pages, |
|
243 |
'current' => $pagenum |
|
244 |
)); |
|
245 |
|
|
246 |
$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash'; |
|
247 |
|
|
248 |
if ( $page_links ) : ?> |
|
249 |
<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', |
|
250 |
number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), |
|
251 |
number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ), |
|
252 |
number_format_i18n( $wp_query->post_count ), |
|
253 |
$page_links |
|
254 |
); echo $page_links_text; ?></div> |
|
255 |
<?php endif; ?> |
|
256 |
|
|
257 |
<div class="alignleft actions"> |
|
258 |
<select name="action"> |
|
259 |
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
|
260 |
<?php if ( $is_trash ) { ?> |
|
261 |
<option value="untrash"><?php _e('Restore'); ?></option> |
|
262 |
<?php } else { ?> |
|
263 |
<option value="edit"><?php _e('Edit'); ?></option> |
|
264 |
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?> |
|
265 |
<option value="delete"><?php _e('Delete Permanently'); ?></option> |
|
266 |
<?php } else { ?> |
|
267 |
<option value="trash"><?php _e('Move to Trash'); ?></option> |
|
268 |
<?php } ?> |
|
269 |
</select> |
|
270 |
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> |
|
271 |
<?php wp_nonce_field('bulk-pages'); ?> |
|
272 |
<?php if ( $is_trash ) { ?> |
|
273 |
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> |
|
274 |
<?php } ?> |
|
275 |
</div> |
|
276 |
|
|
277 |
<br class="clear" /> |
|
278 |
</div> |
|
279 |
|
|
280 |
<div class="clear"></div> |
|
281 |
|
|
282 |
<table class="widefat page fixed" cellspacing="0"> |
|
283 |
<thead> |
|
284 |
<tr> |
|
285 |
<?php print_column_headers('edit-pages'); ?> |
|
286 |
</tr> |
|
287 |
</thead> |
|
288 |
|
|
289 |
<tfoot> |
|
290 |
<tr> |
|
291 |
<?php print_column_headers('edit-pages', false); ?> |
|
292 |
</tr> |
|
293 |
</tfoot> |
|
294 |
|
|
295 |
<tbody> |
|
296 |
<?php page_rows($posts, $pagenum, $per_page); ?> |
|
297 |
</tbody> |
|
298 |
</table> |
|
299 |
|
|
300 |
<div class="tablenav"> |
|
301 |
<?php |
|
302 |
if ( $page_links ) |
|
303 |
echo "<div class='tablenav-pages'>$page_links_text</div>"; |
|
304 |
?> |
|
305 |
|
|
306 |
<div class="alignleft actions"> |
|
307 |
<select name="action2"> |
|
308 |
<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> |
|
309 |
<?php if ( $is_trash ) { ?> |
|
310 |
<option value="untrash"><?php _e('Restore'); ?></option> |
|
311 |
<?php } else { ?> |
|
312 |
<option value="edit"><?php _e('Edit'); ?></option> |
|
313 |
<?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?> |
|
314 |
<option value="delete"><?php _e('Delete Permanently'); ?></option> |
|
315 |
<?php } else { ?> |
|
316 |
<option value="trash"><?php _e('Move to Trash'); ?></option> |
|
317 |
<?php } ?> |
|
318 |
</select> |
|
319 |
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> |
|
320 |
<?php if ( $is_trash ) { ?> |
|
321 |
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> |
|
322 |
<?php } ?> |
|
323 |
</div> |
|
324 |
|
|
325 |
<br class="clear" /> |
|
326 |
</div> |
|
327 |
|
|
328 |
<?php } else { ?> |
|
329 |
<div class="clear"></div> |
|
330 |
<p><?php _e('No pages found.') ?></p> |
|
331 |
<?php |
|
332 |
} // end if ($posts) |
|
333 |
?> |
|
334 |
|
|
335 |
</form> |
|
336 |
|
|
337 |
<?php inline_edit_row( 'page' ) ?> |
|
338 |
|
|
339 |
<div id="ajax-response"></div> |
|
340 |
|
|
341 |
|
|
342 |
<?php |
|
343 |
|
|
344 |
if ( 1 == count($posts) && is_singular() ) : |
|
345 |
|
|
346 |
$comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) ); |
|
347 |
if ( $comments ) : |
|
348 |
// Make sure comments, post, and post_author are cached |
|
349 |
update_comment_cache($comments); |
|
350 |
$post = get_post($id); |
|
351 |
$authordata = get_userdata($post->post_author); |
|
352 |
?> |
|
353 |
|
|
354 |
<br class="clear" /> |
|
355 |
|
|
356 |
<table class="widefat" cellspacing="0"> |
|
357 |
<thead> |
|
358 |
<tr> |
|
359 |
<th scope="col" class="column-comment"> |
|
360 |
<?php /* translators: column name */ echo _x('Comment', 'column name') ?> |
|
361 |
</th> |
|
362 |
<th scope="col" class="column-author"><?php _e('Author') ?></th> |
|
363 |
<th scope="col" class="column-date"><?php _e('Submitted') ?></th> |
|
364 |
</tr> |
|
365 |
</thead> |
|
366 |
<tbody id="the-comment-list" class="list:comment"> |
|
367 |
<?php |
|
368 |
foreach ($comments as $comment) |
|
369 |
_wp_comment_row( $comment->comment_ID, 'single', false, false ); |
|
370 |
?> |
|
371 |
</tbody> |
|
372 |
</table> |
|
373 |
|
|
374 |
<?php |
|
375 |
wp_comment_reply(); |
|
376 |
endif; // comments |
|
377 |
endif; // posts; |
|
378 |
|
|
379 |
?> |
|
380 |
|
|
381 |
</div> |
|
382 |
|
|
383 |
<?php |
|
384 |
include('admin-footer.php'); |