3 * Edit Pages Administration Panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
12 if ( !current_user_can('edit_pages') )
13 wp_die(__('Cheatin’ uh?'));
15 // Handle bulk actions
16 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
17 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
19 switch ( $doaction ) {
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...') );
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);
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);
68 wp_redirect($sendback);
70 } 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']) ) );
76 $title = __('Edit Pages');
77 $parent_file = 'edit-pages.php';
78 wp_enqueue_script('inline-edit-post');
80 $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')),
82 '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')),
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')),
85 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page'))
88 $post_stati = apply_filters('page_stati', $post_stati);
90 $query = array('post_type' => 'page', 'orderby' => 'menu_order title',
91 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
93 $post_status_label = __('Pages');
94 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
95 $post_status_label = $post_stati[$_GET['post_status']][1];
96 $query['post_status'] = $_GET['post_status'];
97 $query['perm'] = 'readable';
100 $query = apply_filters('manage_pages_query', $query);
103 if ( is_singular() ) {
104 wp_enqueue_script( 'admin-comments' );
105 enqueue_comment_hotkeys_js();
108 require_once('admin-header.php'); ?>
111 <?php screen_icon(); ?>
112 <h2><?php echo esc_html( $title );
113 if ( isset($_GET['s']) && $_GET['s'] )
114 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']) ) { ?>
118 <div id="message" class="updated fade"><p>
119 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
120 printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
121 unset($_GET['updated']);
124 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'] ) );
126 unset($_GET['skipped']);
129 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'] ) );
131 unset($_GET['locked']);
134 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
135 printf( _n( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
136 unset($_GET['deleted']);
138 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
143 <?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>
145 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
148 <form id="posts-filter" action="" method="get">
149 <ul class="subsubsub">
152 $avail_post_stati = get_available_post_statuses('page');
153 if ( empty($locked_post_status) ) :
154 $status_links = array();
155 $num_posts = wp_count_posts('page', 'readable');
156 $total_posts = array_sum( (array) $num_posts );
157 $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>';
159 foreach ( $post_stati as $status => $label ) {
162 if ( !in_array($status, $avail_post_stati) )
165 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
166 $class = ' class="current"';
168 $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>';
170 echo implode( " |</li>\n", $status_links ) . '</li>';
171 unset($status_links);
176 <p class="search-box">
177 <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(); ?>" />
179 <input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" />
182 <?php if ( isset($_GET['post_status'] ) ) : ?>
183 <input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']) ?>" />
186 <?php if ($posts) { ?>
188 <div class="tablenav">
191 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
192 if ( empty($pagenum) )
194 $per_page = get_user_option('edit_pages_per_page');
195 if ( empty( $per_page ) || $per_page < 0 )
198 $num_pages = ceil($wp_query->post_count / $per_page);
199 $page_links = paginate_links( array(
200 'base' => add_query_arg( 'pagenum', '%#%' ),
202 'prev_text' => __('«'),
203 'next_text' => __('»'),
204 'total' => $num_pages,
205 'current' => $pagenum
208 if ( $page_links ) : ?>
209 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
210 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
211 number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
212 number_format_i18n( $wp_query->post_count ),
214 ); echo $page_links_text; ?></div>
217 <div class="alignleft actions">
218 <select name="action">
219 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
220 <option value="edit"><?php _e('Edit'); ?></option>
221 <option value="delete"><?php _e('Delete'); ?></option>
223 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
224 <?php wp_nonce_field('bulk-pages'); ?>
230 <div class="clear"></div>
232 <table class="widefat page fixed" cellspacing="0">
235 <?php print_column_headers('edit-pages'); ?>
241 <?php print_column_headers('edit-pages', false); ?>
246 <?php page_rows($posts, $pagenum, $per_page); ?>
250 <div class="tablenav">
253 echo "<div class='tablenav-pages'>$page_links_text</div>";
256 <div class="alignleft actions">
257 <select name="action2">
258 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
259 <option value="edit"><?php _e('Edit'); ?></option>
260 <option value="delete"><?php _e('Delete'); ?></option>
262 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
269 <div class="clear"></div>
270 <p><?php _e('No pages found.') ?></p>
277 <?php inline_edit_row( 'page' ) ?>
279 <div id="ajax-response"></div>
284 if ( 1 == count($posts) && is_singular() ) :
286 $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
288 // Make sure comments, post, and post_author are cached
289 update_comment_cache($comments);
290 $post = get_post($id);
291 $authordata = get_userdata($post->post_author);
296 <table class="widefat" cellspacing="0">
299 <th scope="col" class="column-comment">
300 <?php /* translators: column name */ echo _x('Comment', 'column name') ?>
302 <th scope="col" class="column-author"><?php _e('Author') ?></th>
303 <th scope="col" class="column-date"><?php _e('Submitted') ?></th>
306 <tbody id="the-comment-list" class="list:comment">
308 foreach ($comments as $comment)
309 _wp_comment_row( $comment->comment_ID, 'single', false, false );
324 include('admin-footer.php');