13
13
wp_die(__('Cheatin’ uh?'));
15
15
// Handle bulk actions
16
if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
17
$doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
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() );
20
if ( strpos($sendback, 'page.php') !== false )
21
$sendback = admin_url('page-new.php');
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 ) );
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'];
31
wp_redirect( admin_url('edit-pages.php') );
19
34
switch ( $doaction ) {
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.') );
41
if ( !wp_trash_post($post_id) )
42
wp_die( __('Error in moving to trash...') );
46
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback );
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.') );
54
if ( !wp_untrash_post($post_id) )
55
wp_die( __('Error in restoring from trash...') );
59
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
21
if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
22
check_admin_referer('bulk-pages');
24
foreach( (array) $_GET['post'] as $post_id_del ) {
25
$post_del = & get_post($post_id_del);
27
if ( !current_user_can('delete_page', $post_id_del) )
28
wp_die( __('You are not allowed to delete this page.') );
30
if ( $post_del->post_type == 'attachment' ) {
31
if ( ! wp_delete_attachment($post_id_del) )
32
wp_die( __('Error in deleting...') );
34
if ( !wp_delete_post($post_id_del) )
35
wp_die( __('Error in deleting...') );
63
foreach( (array) $post_ids as $post_id ) {
64
$post_del = & get_post($post_id);
66
if ( !current_user_can('delete_page', $post_id) )
67
wp_die( __('You are not allowed to delete this page.') );
69
if ( $post_del->post_type == 'attachment' ) {
70
if ( ! wp_delete_attachment($post_id) )
71
wp_die( __('Error in deleting...') );
73
if ( !wp_delete_post($post_id) )
74
wp_die( __('Error in deleting...') );
78
$sendback = add_query_arg('deleted', $deleted, $sendback);
42
if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
43
check_admin_referer('bulk-pages');
45
if ( -1 == $_GET['_status'] ) {
46
$_GET['post_status'] = null;
47
unset($_GET['_status'], $_GET['post_status']);
49
$_GET['post_status'] = $_GET['_status'];
52
$done = bulk_edit_posts($_GET);
81
$_GET['post_type'] = 'page';
82
$done = bulk_edit_posts($_GET);
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 );
57
$sendback = wp_get_referer();
58
if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
59
elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
61
$done['updated'] = count( $done['updated'] );
62
$done['skipped'] = count( $done['skipped'] );
63
$done['locked'] = count( $done['locked'] );
64
$sendback = add_query_arg( $done, $sendback );
66
if ( isset($deleted) )
67
$sendback = add_query_arg('deleted', $deleted, $sendback);
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 );
68
96
wp_redirect($sendback);
70
98
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
82
110
'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')),
83
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')),
84
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')),
85
'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <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'))
117
if ( !EMPTY_TRASH_DAYS )
118
unset($post_stati['trash']);
88
120
$post_stati = apply_filters('page_stati', $post_stati);
90
122
$query = array('post_type' => 'page', 'orderby' => 'menu_order title',
110
142
<div class="wrap">
111
143
<?php screen_icon(); ?>
112
<h2><?php echo esc_html( $title );
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
113
145
if ( isset($_GET['s']) && $_GET['s'] )
114
146
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?>
117
<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
149
<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
118
150
<div id="message" class="updated fade"><p>
119
151
<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
120
152
printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
121
153
unset($_GET['updated']);
124
155
if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
125
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'] ) );
126
157
unset($_GET['skipped']);
129
159
if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
130
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'] ) );
131
161
unset($_GET['locked']);
134
163
if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
135
printf( _n( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
164
printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
136
165
unset($_GET['deleted']);
138
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
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']);
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']);
177
$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );