Make WordPress Core

Ticket #6709: edit-pages.php

File edit-pages.php, 6.6 KB (added by jabecker, 16 years ago)

modified edit-pages.php

Line 
1<?php
2require_once('admin.php');
3
4// Handle bulk deletes
5if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
6        check_admin_referer('bulk-pages');
7        foreach( (array) $_GET['delete'] as $post_id_del ) {
8                $post_del = & get_post($post_id_del);
9
10                if ( !current_user_can('delete_page', $post_id_del) )
11                        wp_die( __('You are not allowed to delete this page.') );
12
13                if ( $post_del->post_type == 'attachment' ) {
14                        if ( ! wp_delete_attachment($post_id_del) )
15                                wp_die( __('Error in deleting...') );
16                } else {
17                        if ( !wp_delete_post($post_id_del) )
18                                wp_die( __('Error in deleting...') );
19                }
20        }
21
22        $sendback = wp_get_referer();
23        if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page-new.php';
24        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
25        $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
26
27        wp_redirect($sendback);
28        exit();
29} elseif ( !empty($_GET['_wp_http_referer']) ) {
30         wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
31         exit;
32}
33
34$title = __('Pages');
35$parent_file = 'edit.php';
36wp_enqueue_script('admin-forms');
37
38$post_stati  = array(   //      array( adj, noun )
39                'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
40                'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
41                'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
42                'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
43                'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)'))
44        );
45
46$post_status_label = __('Manage Pages');
47$post_status_q = '';
48if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
49        $post_status_label = $post_stati[$_GET['post_status']][1];
50        $post_status_q = '&post_status=' . $_GET['post_status'];
51        $post_status_q .= '&perm=readable';
52}
53
54$query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc";
55
56$query_str = apply_filters('manage_pages_query', $query_str);
57wp($query_str);
58
59if ( is_singular() )
60        wp_enqueue_script( 'admin-comments' );
61require_once('admin-header.php');
62
63?>
64<div class="wrap">
65<form id="posts-filter" action="" method="get">
66<h2><?php
67// Use $_GET instead of is_ since they can override each other
68$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
69$h2_author = '';
70if ( isset($_GET['author']) && $_GET['author'] ) {
71        $author_user = get_userdata( (int) $_GET['author'] );
72        $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
73}
74printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search );
75?></h2>
76
77<ul class="subsubsub">
78<?php
79
80$avail_post_stati = get_available_post_statuses('page');
81
82$status_links = array();
83$num_posts = wp_count_posts('page', 'readable');
84$class = empty($_GET['post_status']) ? ' class="current"' : '';
85$status_links[] = "<li><a href=\"edit-pages.php\"$class>".__('All Pages')."</a>";
86foreach ( $post_stati as $status => $label ) {
87        $class = '';
88
89        if ( !in_array($status, $avail_post_stati) )
90                continue;
91
92        if ( $status == $_GET['post_status'] )
93                $class = ' class="current"';
94
95        $status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
96        sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), number_format_i18n( $num_posts->$status ) ) . '</a>';
97}
98echo implode(' |</li>', $status_links) . '</li>';
99unset($status_links);
100?>
101</ul>
102
103<?php if ( isset($_GET['post_status'] ) ) : ?>
104<input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
105<?php
106endif;
107if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
108<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="page.php?action=edit&amp;post=<?php echo $_GET['posted']; ?>"><?php _e('Edit page'); ?></a></p></div>
109<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
110endif;
111?>
112
113<p id="post-search">
114        <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
115        <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
116</p>
117
118<div class="tablenav">
119
120<div class="alignleft">
121<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
122<?php wp_nonce_field('bulk-pages'); ?>
123</div>
124
125<br class="clear" />
126</div>
127
128<br class="clear" />
129
130<?php
131
132$all = !( $h2_search || $post_status_q );
133
134if ($posts) {
135?>
136<table class="widefat">
137  <thead>
138  <tr>
139<?php $posts_columns = wp_manage_pages_columns(); ?>
140<?php foreach($posts_columns as $post_column_key => $column_display_name) {
141        if ( 'cb' === $post_column_key )
142                $class = ' class="check-column"';
143        elseif ( 'comments' === $post_column_key )
144                $class = ' class="num"';
145        else
146                $class = '';
147?>
148        <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
149<?php } ?>
150  </tr>
151  </thead>
152  <tbody>
153  <?php page_rows($posts); ?>
154  </tbody>
155</table>
156
157</form>
158
159<div id="ajax-response"></div>
160
161<?php
162} else {
163?>
164</form>
165<p><?php _e('No pages found.') ?></p>
166<?php
167} // end if ($posts)
168?>
169
170<div class="tablenav">
171<br class="clear" />
172</div>
173
174<?php
175
176if ( 1 == count($posts) && is_singular() ) :
177
178        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
179        if ( $comments ) :
180                // Make sure comments, post, and post_author are cached
181                update_comment_cache($comments);
182                $post = get_post($id);
183                $authordata = get_userdata($post->post_author);
184        ?>
185
186<br class="clear" />
187
188<table class="widefat" style="margin-top: .5em">
189<thead>
190  <tr>
191    <th scope="col"><?php _e('Comment') ?></th>
192    <th scope="col"><?php _e('Date') ?></th>
193    <th scope="col"><?php _e('Actions') ?></th>
194  </tr>
195</thead>
196<tbody id="the-comment-list" class="list:comment">
197<?php
198        foreach ($comments as $comment)
199                _wp_comment_row( $comment->comment_ID, 'detail', false, false );
200?>
201</tbody>
202</table>
203
204<?php
205
206endif; // comments
207endif; // posts;
208
209?>
210
211</div>
212
213<?php include('admin-footer.php'); ?>