mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Edit Pages Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 // Handle bulk actions
mp-wp_genesis 13 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
mp-wp_genesis 14 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
mp-wp_genesis 15
mp-wp_genesis 16 switch ( $doaction ) {
mp-wp_genesis 17 case 'delete':
mp-wp_genesis 18 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
mp-wp_genesis 19 check_admin_referer('bulk-pages');
mp-wp_genesis 20 $deleted = 0;
mp-wp_genesis 21 foreach( (array) $_GET['post'] as $post_id_del ) {
mp-wp_genesis 22 $post_del = & get_post($post_id_del);
mp-wp_genesis 23
mp-wp_genesis 24 if ( !current_user_can('delete_page', $post_id_del) )
mp-wp_genesis 25 wp_die( __('You are not allowed to delete this page.') );
mp-wp_genesis 26
mp-wp_genesis 27 if ( $post_del->post_type == 'attachment' ) {
mp-wp_genesis 28 if ( ! wp_delete_attachment($post_id_del) )
mp-wp_genesis 29 wp_die( __('Error in deleting...') );
mp-wp_genesis 30 } else {
mp-wp_genesis 31 if ( !wp_delete_post($post_id_del) )
mp-wp_genesis 32 wp_die( __('Error in deleting...') );
mp-wp_genesis 33 }
mp-wp_genesis 34 $deleted++;
mp-wp_genesis 35 }
mp-wp_genesis 36 }
mp-wp_genesis 37 break;
mp-wp_genesis 38 case 'edit':
mp-wp_genesis 39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
mp-wp_genesis 40 check_admin_referer('bulk-pages');
mp-wp_genesis 41
mp-wp_genesis 42 if ( -1 == $_GET['_status'] ) {
mp-wp_genesis 43 $_GET['post_status'] = null;
mp-wp_genesis 44 unset($_GET['_status'], $_GET['post_status']);
mp-wp_genesis 45 } else {
mp-wp_genesis 46 $_GET['post_status'] = $_GET['_status'];
mp-wp_genesis 47 }
mp-wp_genesis 48
mp-wp_genesis 49 $done = bulk_edit_posts($_GET);
mp-wp_genesis 50 }
mp-wp_genesis 51 break;
mp-wp_genesis 52 }
mp-wp_genesis 53
mp-wp_genesis 54 $sendback = wp_get_referer();
mp-wp_genesis 55 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
mp-wp_genesis 56 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
mp-wp_genesis 57 if ( isset($done) ) {
mp-wp_genesis 58 $done['updated'] = count( $done['updated'] );
mp-wp_genesis 59 $done['skipped'] = count( $done['skipped'] );
mp-wp_genesis 60 $done['locked'] = count( $done['locked'] );
mp-wp_genesis 61 $sendback = add_query_arg( $done, $sendback );
mp-wp_genesis 62 }
mp-wp_genesis 63 if ( isset($deleted) )
mp-wp_genesis 64 $sendback = add_query_arg('deleted', $deleted, $sendback);
mp-wp_genesis 65 wp_redirect($sendback);
mp-wp_genesis 66 exit();
mp-wp_genesis 67 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 68 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 69 exit;
mp-wp_genesis 70 }
mp-wp_genesis 71
mp-wp_genesis 72 if ( empty($title) )
mp-wp_genesis 73 $title = __('Edit Pages');
mp-wp_genesis 74 $parent_file = 'edit-pages.php';
mp-wp_genesis 75 wp_enqueue_script('inline-edit-post');
mp-wp_genesis 76
mp-wp_genesis 77 $post_stati = array( // array( adj, noun )
mp-wp_genesis 78 'publish' => array(__('Published|page'), __('Published pages'), _n_noop('Published <span class="count">(%s)</span>|page', 'Published <span class="count">(%s)</span>')),
mp-wp_genesis 79 'future' => array(__('Scheduled|page'), __('Scheduled pages'), _n_noop('Scheduled <span class="count">(%s)</span>|page', 'Scheduled <span class="count">(%s)</span>')),
mp-wp_genesis 80 'pending' => array(__('Pending Review|page'), __('Pending pages'), _n_noop('Pending Review <span class="count">(%s)</span>|page', 'Pending Review <span class="count">(%s)</span>')),
mp-wp_genesis 81 'draft' => array(__('Draft|page'), _c('Drafts|manage posts header'), _n_noop('Draft <span class="count">(%s)</span>|page', 'Drafts <span class="count">(%s)</span>')),
mp-wp_genesis 82 'private' => array(__('Private|page'), __('Private pages'), _n_noop('Private <span class="count">(%s)</span>|page', 'Private <span class="count">(%s)</span>'))
mp-wp_genesis 83 );
mp-wp_genesis 84
mp-wp_genesis 85 $query = array('post_type' => 'page', 'orderby' => 'menu_order title', 'what_to_show' => 'posts',
mp-wp_genesis 86 'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
mp-wp_genesis 87
mp-wp_genesis 88 $post_status_label = __('Pages');
mp-wp_genesis 89 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
mp-wp_genesis 90 $post_status_label = $post_stati[$_GET['post_status']][1];
mp-wp_genesis 91 $query['post_status'] = $_GET['post_status'];
mp-wp_genesis 92 $query['perm'] = 'readable';
mp-wp_genesis 93 }
mp-wp_genesis 94
mp-wp_genesis 95 $query = apply_filters('manage_pages_query', $query);
mp-wp_genesis 96 wp($query);
mp-wp_genesis 97
mp-wp_genesis 98 if ( is_singular() ) {
mp-wp_genesis 99 wp_enqueue_script( 'admin-comments' );
mp-wp_genesis 100 enqueue_comment_hotkeys_js();
mp-wp_genesis 101 }
mp-wp_genesis 102
mp-wp_genesis 103 require_once('admin-header.php'); ?>
mp-wp_genesis 104
mp-wp_genesis 105 <div class="wrap">
mp-wp_genesis 106 <?php screen_icon(); ?>
mp-wp_genesis 107 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 108 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 109 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
mp-wp_genesis 110 </h2>
mp-wp_genesis 111
mp-wp_genesis 112 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
mp-wp_genesis 113 <div id="message" class="updated fade"><p>
mp-wp_genesis 114 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
mp-wp_genesis 115 printf( __ngettext( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
mp-wp_genesis 116 unset($_GET['updated']);
mp-wp_genesis 117 }
mp-wp_genesis 118
mp-wp_genesis 119 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
mp-wp_genesis 120 printf( __ngettext( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
mp-wp_genesis 121 unset($_GET['skipped']);
mp-wp_genesis 122 }
mp-wp_genesis 123
mp-wp_genesis 124 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
mp-wp_genesis 125 printf( __ngettext( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) );
mp-wp_genesis 126 unset($_GET['locked']);
mp-wp_genesis 127 }
mp-wp_genesis 128
mp-wp_genesis 129 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
mp-wp_genesis 130 printf( __ngettext( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
mp-wp_genesis 131 unset($_GET['deleted']);
mp-wp_genesis 132 }
mp-wp_genesis 133 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
mp-wp_genesis 134 ?>
mp-wp_genesis 135 </p></div>
mp-wp_genesis 136 <?php } ?>
mp-wp_genesis 137
mp-wp_genesis 138 <?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
mp-wp_genesis 139 <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>
mp-wp_genesis 140 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 141 endif; ?>
mp-wp_genesis 142
mp-wp_genesis 143 <form id="posts-filter" action="" method="get">
mp-wp_genesis 144 <ul class="subsubsub">
mp-wp_genesis 145 <?php
mp-wp_genesis 146
mp-wp_genesis 147 $avail_post_stati = get_available_post_statuses('page');
mp-wp_genesis 148 if ( empty($locked_post_status) ) :
mp-wp_genesis 149 $status_links = array();
mp-wp_genesis 150 $num_posts = wp_count_posts('page', 'readable');
mp-wp_genesis 151 $total_posts = array_sum( (array) $num_posts );
mp-wp_genesis 152 $class = empty($_GET['post_status']) ? ' class="current"' : '';
mp-wp_genesis 153 $status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
mp-wp_genesis 154 foreach ( $post_stati as $status => $label ) {
mp-wp_genesis 155 $class = '';
mp-wp_genesis 156
mp-wp_genesis 157 if ( !in_array($status, $avail_post_stati) )
mp-wp_genesis 158 continue;
mp-wp_genesis 159
mp-wp_genesis 160 if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
mp-wp_genesis 161 $class = ' class="current"';
mp-wp_genesis 162
mp-wp_genesis 163 $status_links[] = "<li><a href='edit-pages.php?post_status=$status'$class>" . sprintf( _nc( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
mp-wp_genesis 164 }
mp-wp_genesis 165 echo implode( " |</li>\n", $status_links ) . '</li>';
mp-wp_genesis 166 unset($status_links);
mp-wp_genesis 167 endif;
mp-wp_genesis 168 ?>
mp-wp_genesis 169 </ul>
mp-wp_genesis 170
mp-wp_genesis 171 <p class="search-box">
mp-wp_genesis 172 <label class="hidden" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label>
mp-wp_genesis 173 <input type="text" class="search-input" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 174 <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
mp-wp_genesis 175 </p>
mp-wp_genesis 176
mp-wp_genesis 177 <?php if ( isset($_GET['post_status'] ) ) : ?>
mp-wp_genesis 178 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
mp-wp_genesis 179 <?php endif; ?>
mp-wp_genesis 180
mp-wp_genesis 181 <?php if ($posts) { ?>
mp-wp_genesis 182
mp-wp_genesis 183 <div class="tablenav">
mp-wp_genesis 184
mp-wp_genesis 185 <?php
mp-wp_genesis 186 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
mp-wp_genesis 187 if ( empty($pagenum) )
mp-wp_genesis 188 $pagenum = 1;
mp-wp_genesis 189 if( ! isset( $per_page ) || $per_page < 0 )
mp-wp_genesis 190 $per_page = 20;
mp-wp_genesis 191
mp-wp_genesis 192 $num_pages = ceil($wp_query->post_count / $per_page);
mp-wp_genesis 193 $page_links = paginate_links( array(
mp-wp_genesis 194 'base' => add_query_arg( 'pagenum', '%#%' ),
mp-wp_genesis 195 'format' => '',
mp-wp_genesis 196 'prev_text' => __('«'),
mp-wp_genesis 197 'next_text' => __('»'),
mp-wp_genesis 198 'total' => $num_pages,
mp-wp_genesis 199 'current' => $pagenum
mp-wp_genesis 200 ));
mp-wp_genesis 201
mp-wp_genesis 202 if ( $page_links ) : ?>
mp-wp_genesis 203 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
mp-wp_genesis 204 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
mp-wp_genesis 205 number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
mp-wp_genesis 206 number_format_i18n( $wp_query->post_count ),
mp-wp_genesis 207 $page_links
mp-wp_genesis 208 ); echo $page_links_text; ?></div>
mp-wp_genesis 209 <?php endif; ?>
mp-wp_genesis 210
mp-wp_genesis 211 <div class="alignleft actions">
mp-wp_genesis 212 <select name="action">
mp-wp_genesis 213 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 214 <option value="edit"><?php _e('Edit'); ?></option>
mp-wp_genesis 215 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 216 </select>
mp-wp_genesis 217 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 218 <?php wp_nonce_field('bulk-pages'); ?>
mp-wp_genesis 219 </div>
mp-wp_genesis 220
mp-wp_genesis 221 <br class="clear" />
mp-wp_genesis 222 </div>
mp-wp_genesis 223
mp-wp_genesis 224 <div class="clear"></div>
mp-wp_genesis 225
mp-wp_genesis 226 <table class="widefat page fixed" cellspacing="0">
mp-wp_genesis 227 <thead>
mp-wp_genesis 228 <tr>
mp-wp_genesis 229 <?php print_column_headers('edit-pages'); ?>
mp-wp_genesis 230 </tr>
mp-wp_genesis 231 </thead>
mp-wp_genesis 232
mp-wp_genesis 233 <tfoot>
mp-wp_genesis 234 <tr>
mp-wp_genesis 235 <?php print_column_headers('edit-pages', false); ?>
mp-wp_genesis 236 </tr>
mp-wp_genesis 237 </tfoot>
mp-wp_genesis 238
mp-wp_genesis 239 <tbody>
mp-wp_genesis 240 <?php page_rows($posts, $pagenum, $per_page); ?>
mp-wp_genesis 241 </tbody>
mp-wp_genesis 242 </table>
mp-wp_genesis 243
mp-wp_genesis 244 <div class="tablenav">
mp-wp_genesis 245 <?php
mp-wp_genesis 246 if ( $page_links )
mp-wp_genesis 247 echo "<div class='tablenav-pages'>$page_links_text</div>";
mp-wp_genesis 248 ?>
mp-wp_genesis 249
mp-wp_genesis 250 <div class="alignleft actions">
mp-wp_genesis 251 <select name="action2">
mp-wp_genesis 252 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 253 <option value="edit"><?php _e('Edit'); ?></option>
mp-wp_genesis 254 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 255 </select>
mp-wp_genesis 256 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
mp-wp_genesis 257 </div>
mp-wp_genesis 258
mp-wp_genesis 259 <br class="clear" />
mp-wp_genesis 260 </div>
mp-wp_genesis 261
mp-wp_genesis 262 <?php } else { ?>
mp-wp_genesis 263 <div class="clear"></div>
mp-wp_genesis 264 <p><?php _e('No pages found.') ?></p>
mp-wp_genesis 265 <?php
mp-wp_genesis 266 } // end if ($posts)
mp-wp_genesis 267 ?>
mp-wp_genesis 268
mp-wp_genesis 269 </form>
mp-wp_genesis 270
mp-wp_genesis 271 <?php inline_edit_row( 'page' ) ?>
mp-wp_genesis 272
mp-wp_genesis 273 <div id="ajax-response"></div>
mp-wp_genesis 274
mp-wp_genesis 275
mp-wp_genesis 276 <?php
mp-wp_genesis 277
mp-wp_genesis 278 if ( 1 == count($posts) && is_singular() ) :
mp-wp_genesis 279
mp-wp_genesis 280 $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
mp-wp_genesis 281 if ( $comments ) :
mp-wp_genesis 282 // Make sure comments, post, and post_author are cached
mp-wp_genesis 283 update_comment_cache($comments);
mp-wp_genesis 284 $post = get_post($id);
mp-wp_genesis 285 $authordata = get_userdata($post->post_author);
mp-wp_genesis 286 ?>
mp-wp_genesis 287
mp-wp_genesis 288 <br class="clear" />
mp-wp_genesis 289
mp-wp_genesis 290 <table class="widefat" cellspacing="0">
mp-wp_genesis 291 <thead>
mp-wp_genesis 292 <tr>
mp-wp_genesis 293 <th scope="col" class="column-comment"><?php echo _c('Comment|noun') ?></th>
mp-wp_genesis 294 <th scope="col" class="column-author"><?php _e('Author') ?></th>
mp-wp_genesis 295 <th scope="col" class="column-date"><?php _e('Submitted') ?></th>
mp-wp_genesis 296 </tr>
mp-wp_genesis 297 </thead>
mp-wp_genesis 298 <tbody id="the-comment-list" class="list:comment">
mp-wp_genesis 299 <?php
mp-wp_genesis 300 foreach ($comments as $comment)
mp-wp_genesis 301 _wp_comment_row( $comment->comment_ID, 'single', false, false );
mp-wp_genesis 302 ?>
mp-wp_genesis 303 </tbody>
mp-wp_genesis 304 </table>
mp-wp_genesis 305
mp-wp_genesis 306 <?php
mp-wp_genesis 307 wp_comment_reply();
mp-wp_genesis 308 endif; // comments
mp-wp_genesis 309 endif; // posts;
mp-wp_genesis 310
mp-wp_genesis 311 ?>
mp-wp_genesis 312
mp-wp_genesis 313 </div>
mp-wp_genesis 314
mp-wp_genesis 315 <script type="text/javascript">
mp-wp_genesis 316 /* <![CDATA[ */
mp-wp_genesis 317 (function($){
mp-wp_genesis 318 $(document).ready(function(){
mp-wp_genesis 319 $('#doaction, #doaction2').click(function(){
mp-wp_genesis 320 if ( $('select[name^="action"]').val() == 'delete' ) {
mp-wp_genesis 321 var m = '<?php echo js_escape(__("You are about to delete the selected pages.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
mp-wp_genesis 322 return showNotice.warn(m);
mp-wp_genesis 323 }
mp-wp_genesis 324 });
mp-wp_genesis 325 });
mp-wp_genesis 326 })(jQuery);
mp-wp_genesis 327 columns.init('edit-pages');
mp-wp_genesis 328 /* ]]> */
mp-wp_genesis 329 </script>
mp-wp_genesis 330
mp-wp_genesis 331 <?php include('admin-footer.php'); ?>