11 |
11 |
12 if ( !current_user_can('edit_pages') ) |
12 if ( !current_user_can('edit_pages') ) |
13 wp_die(__('Cheatin’ uh?')); |
13 wp_die(__('Cheatin’ uh?')); |
14 |
14 |
15 // Handle bulk actions |
15 // Handle bulk actions |
16 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { |
16 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { |
17 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; |
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 } |
18 |
33 |
19 switch ( $doaction ) { |
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; |
20 case 'delete': |
61 case 'delete': |
21 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { |
62 $deleted = 0; |
22 check_admin_referer('bulk-pages'); |
63 foreach( (array) $post_ids as $post_id ) { |
23 $deleted = 0; |
64 $post_del = & get_post($post_id); |
24 foreach( (array) $_GET['post'] as $post_id_del ) { |
65 |
25 $post_del = & get_post($post_id_del); |
66 if ( !current_user_can('delete_page', $post_id) ) |
26 |
67 wp_die( __('You are not allowed to delete this page.') ); |
27 if ( !current_user_can('delete_page', $post_id_del) ) |
68 |
28 wp_die( __('You are not allowed to delete this page.') ); |
69 if ( $post_del->post_type == 'attachment' ) { |
29 |
70 if ( ! wp_delete_attachment($post_id) ) |
30 if ( $post_del->post_type == 'attachment' ) { |
71 wp_die( __('Error in deleting...') ); |
31 if ( ! wp_delete_attachment($post_id_del) ) |
72 } else { |
32 wp_die( __('Error in deleting...') ); |
73 if ( !wp_delete_post($post_id) ) |
33 } else { |
74 wp_die( __('Error in deleting...') ); |
34 if ( !wp_delete_post($post_id_del) ) |
|
35 wp_die( __('Error in deleting...') ); |
|
36 } |
|
37 $deleted++; |
|
38 } |
75 } |
|
76 $deleted++; |
39 } |
77 } |
|
78 $sendback = add_query_arg('deleted', $deleted, $sendback); |
40 break; |
79 break; |
41 case 'edit': |
80 case 'edit': |
42 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { |
81 $_GET['post_type'] = 'page'; |
43 check_admin_referer('bulk-pages'); |
82 $done = bulk_edit_posts($_GET); |
44 |
83 |
45 if ( -1 == $_GET['_status'] ) { |
84 if ( is_array($done) ) { |
46 $_GET['post_status'] = null; |
85 $done['updated'] = count( $done['updated'] ); |
47 unset($_GET['_status'], $_GET['post_status']); |
86 $done['skipped'] = count( $done['skipped'] ); |
48 } else { |
87 $done['locked'] = count( $done['locked'] ); |
49 $_GET['post_status'] = $_GET['_status']; |
88 $sendback = add_query_arg( $done, $sendback ); |
50 } |
|
51 |
|
52 $done = bulk_edit_posts($_GET); |
|
53 } |
89 } |
54 break; |
90 break; |
55 } |
91 } |
56 |
92 |
57 $sendback = wp_get_referer(); |
93 if ( isset($_GET['action']) ) |
58 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php'); |
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 ); |
59 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); |
95 |
60 if ( isset($done) ) { |
|
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 ); |
|
65 } |
|
66 if ( isset($deleted) ) |
|
67 $sendback = add_query_arg('deleted', $deleted, $sendback); |
|
68 wp_redirect($sendback); |
96 wp_redirect($sendback); |
69 exit(); |
97 exit(); |
70 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { |
98 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { |
71 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); |
99 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); |
72 exit; |
100 exit; |
80 $post_stati = array( // array( adj, noun ) |
108 $post_stati = array( // array( adj, noun ) |
81 'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')), |
109 'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>', 'page')), |
82 'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <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')), |
83 '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')), |
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 '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')), |
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')) |
86 ); |
115 ); |
|
116 |
|
117 if ( !EMPTY_TRASH_DAYS ) |
|
118 unset($post_stati['trash']); |
87 |
119 |
88 $post_stati = apply_filters('page_stati', $post_stati); |
120 $post_stati = apply_filters('page_stati', $post_stati); |
89 |
121 |
90 $query = array('post_type' => 'page', 'orderby' => 'menu_order title', |
122 $query = array('post_type' => 'page', 'orderby' => 'menu_order title', |
91 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc'); |
123 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc'); |
107 |
139 |
108 require_once('admin-header.php'); ?> |
140 require_once('admin-header.php'); ?> |
109 |
141 |
110 <div class="wrap"> |
142 <div class="wrap"> |
111 <?php screen_icon(); ?> |
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 if ( isset($_GET['s']) && $_GET['s'] ) |
145 if ( isset($_GET['s']) && $_GET['s'] ) |
114 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> |
146 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( get_search_query() ) ); ?> |
115 </h2> |
147 </h2> |
116 |
148 |
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 <div id="message" class="updated fade"><p> |
150 <div id="message" class="updated fade"><p> |
119 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { |
151 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { |
120 printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); |
152 printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) ); |
121 unset($_GET['updated']); |
153 unset($_GET['updated']); |
122 } |
154 } |
123 |
|
124 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) { |
155 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) { |
125 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'] ) ); |
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 unset($_GET['skipped']); |
157 unset($_GET['skipped']); |
127 } |
158 } |
128 |
|
129 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { |
159 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { |
130 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'] ) ); |
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 unset($_GET['locked']); |
161 unset($_GET['locked']); |
132 } |
162 } |
133 |
|
134 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { |
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 unset($_GET['deleted']); |
165 unset($_GET['deleted']); |
137 } |
166 } |
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']); |
|
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'] ); |
139 ?> |
178 ?> |
140 </p></div> |
179 </p></div> |
141 <?php } ?> |
180 <?php } ?> |
142 |
181 |
143 <?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
182 <?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?> |
144 <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> |
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> |
145 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
184 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']); |
146 endif; ?> |
185 endif; ?> |
147 |
186 |
148 <form id="posts-filter" action="" method="get"> |
187 <form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get"> |
149 <ul class="subsubsub"> |
188 <ul class="subsubsub"> |
150 <?php |
189 <?php |
151 |
190 |
152 $avail_post_stati = get_available_post_statuses('page'); |
191 $avail_post_stati = get_available_post_statuses('page'); |
153 if ( empty($locked_post_status) ) : |
192 if ( empty($locked_post_status) ) : |
154 $status_links = array(); |
193 $status_links = array(); |
155 $num_posts = wp_count_posts('page', 'readable'); |
194 $num_posts = wp_count_posts('page', 'readable'); |
156 $total_posts = array_sum( (array) $num_posts ); |
195 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; |
157 $class = empty($_GET['post_status']) ? ' class="current"' : ''; |
196 $class = empty($_GET['post_status']) ? ' class="current"' : ''; |
158 $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>'; |
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>'; |
159 foreach ( $post_stati as $status => $label ) { |
198 foreach ( $post_stati as $status => $label ) { |
160 $class = ''; |
199 $class = ''; |
161 |
200 |
162 if ( !in_array($status, $avail_post_stati) ) |
201 if ( !in_array($status, $avail_post_stati) || $num_posts->$status <= 0 ) |
163 continue; |
202 continue; |
164 |
203 |
165 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] ) |
204 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] ) |
166 $class = ' class="current"'; |
205 $class = ' class="current"'; |
167 |
206 |
177 <label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label> |
216 <label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label> |
178 <input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" /> |
217 <input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" /> |
179 <input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" /> |
218 <input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" /> |
180 </p> |
219 </p> |
181 |
220 |
182 <?php if ( isset($_GET['post_status'] ) ) : ?> |
221 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" /> |
183 <input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']) ?>" /> |
|
184 <?php endif; ?> |
|
185 |
222 |
186 <?php if ($posts) { ?> |
223 <?php if ($posts) { ?> |
187 |
224 |
188 <div class="tablenav"> |
225 <div class="tablenav"> |
189 |
226 |
190 <?php |
227 <?php |
191 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
228 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
192 if ( empty($pagenum) ) |
229 if ( empty($pagenum) ) |
193 $pagenum = 1; |
230 $pagenum = 1; |
194 $per_page = get_user_option('edit_pages_per_page'); |
231 $per_page = (int) get_user_option( 'edit_pages_per_page', 0, false ); |
195 if ( empty( $per_page ) || $per_page < 0 ) |
232 if ( empty( $per_page ) || $per_page < 1 ) |
196 $per_page = 20; |
233 $per_page = 20; |
|
234 $per_page = apply_filters( 'edit_pages_per_page', $per_page ); |
197 |
235 |
198 $num_pages = ceil($wp_query->post_count / $per_page); |
236 $num_pages = ceil($wp_query->post_count / $per_page); |
199 $page_links = paginate_links( array( |
237 $page_links = paginate_links( array( |
200 'base' => add_query_arg( 'pagenum', '%#%' ), |
238 'base' => add_query_arg( 'pagenum', '%#%' ), |
201 'format' => '', |
239 'format' => '', |