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