Make WordPress Core

Ticket #9674: 9674.16.diff

File 9674.16.diff, 66.5 KB (added by ryan, 15 years ago)

Merge edit-pages.php into edit.php, introduce $current_screen, and more

  • wp-admin/admin-ajax.php

     
    10031003case 'autosave-generate-nonces' :
    10041004        check_ajax_referer( 'autosave', 'autosavenonce' );
    10051005        $ID = (int) $_POST['post_ID'];
    1006         $post_type = ( 'page' == $_POST['post_type'] ) ? 'page' : 'post';
    1007         if ( current_user_can( "edit_{$post_type}", $ID ) )
     1006        $post_type = $_POST['post_type'];
     1007        $post_type_object = get_post_type_object($post_type);
     1008        if ( !$post_type_object )
     1009                die('0');
     1010        if ( current_user_can( $post_type_object->edit_cap, $ID ) )
    10081011                die( json_encode( array( 'updateNonce' => wp_create_nonce( "update-{$post_type}_{$ID}" ), 'deleteURL' => str_replace( '&', '&', wp_nonce_url( admin_url( $post_type . '.php?action=trash&post=' . $ID ), "trash-{$post_type}_{$ID}" ) ) ) ) );
    10091012        do_action('autosave_generate_nonces');
    10101013        die('0');
  • wp-admin/post-new.php

     
    1717if ( 'post' != $post_type ) {
    1818        $parent_file = "edit.php?post_type=$post_type";
    1919        $submenu_file = "post-new.php?post_type=$post_type";
    20         if ( 'page' == $post_type )
    21                 $parent_file = 'edit-pages.php';
    2220} else {
    2321        $parent_file = 'edit.php';
    2422        $submenu_file = 'post-new.php';
  • wp-admin/includes/post.php

     
    819819        $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
    820820        $post_stati  = get_post_stati();
    821821
    822         if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types( array('_show' => true) ) ) )
     822        if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
    823823                $post_type = $q['post_type'];
    824824        else
    825825                $post_type = 'post';
     826        $post_type_object = get_post_type_object($post_type);
    826827
    827828        $avail_post_stati = get_available_post_statuses($post_type);
    828829
     
    842843                $orderby = 'date';
    843844        }
    844845
    845         if ( 'post' != $post_type )
    846                 $per_page = 'edit_' . $post_type . '_per_page';
    847         else
    848                 $per_page = 'edit_per_page';
    849         $posts_per_page = (int) get_user_option( 'edit_per_page' );
     846        $per_page = 'edit_' . $post_type . '_per_page';
     847        $posts_per_page = (int) get_user_option( $per_page );
    850848        if ( empty( $posts_per_page ) || $posts_per_page < 1 )
    851849                $posts_per_page = 15;
    852         $posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page );
     850        $posts_per_page = apply_filters( $per_page, $posts_per_page );
    853851
    854         wp( compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page') );
    855852
     853        $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
     854
     855        // Hierarchical types require special args.
     856        if ( $post_type_object->hierarchical ) {
     857                $query['orderby'] = 'menu_order title';
     858                $query['order'] = 'asc';
     859                $query['posts_per_page'] = -1;
     860                $query['posts_per_archive_page'] = -1;
     861        }
     862
     863        wp( $query );
     864
    856865        return $avail_post_stati;
    857866}
    858867
  • wp-admin/includes/misc.php

     
    407407
    408408                switch ( $map_option ) {
    409409                        case 'edit_per_page':
    410                         case 'edit_pages_per_page':
    411410                        case 'edit_comments_per_page':
    412411                        case 'upload_per_page':
    413412                        case 'categories_per_page':
  • wp-admin/includes/template.php

     
    747747 *
    748748 * @return unknown
    749749 */
    750 function wp_manage_posts_columns() {
    751         global $typenow;
     750function wp_manage_posts_columns( $screen = '') {
     751        if ( empty($screen) )
     752                $post_type = 'post';
     753        else
     754                $post_type = $screen->post_type;
    752755
    753756        $posts_columns = array();
    754757        $posts_columns['cb'] = '<input type="checkbox" />';
    755758        /* translators: manage posts column name */
    756         $posts_columns['title'] = _x('Post', 'column name');
     759        $posts_columns['title'] = _x('Title', 'column name');
    757760        $posts_columns['author'] = __('Author');
    758         if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
     761        if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
    759762                $posts_columns['categories'] = __('Categories');
    760         if ( empty($typenow) || is_object_in_taxonomy($typenow, 'category') )
     763        if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
    761764                $posts_columns['tags'] = __('Tags');
    762765        $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
    763         if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($typenow) || post_type_supports($typenow, 'comments') ) )
     766        if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
    764767                $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
    765768        $posts_columns['date'] = __('Date');
     769        // @todo filter per type
    766770        $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
    767771
    768772        return $posts_columns;
     
    803807 * @return unknown
    804808 */
    805809function wp_manage_pages_columns() {
    806         $posts_columns = array();
    807         $posts_columns['cb'] = '<input type="checkbox" />';
    808         $posts_columns['title'] = __('Title');
    809         $posts_columns['author'] = __('Author');
    810         $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
    811         if ( !in_array( $post_status, array('pending', 'draft', 'future') ) )
    812                 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
    813         $posts_columns['date'] = __('Date');
    814         $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
    815 
    816         return $posts_columns;
     810        return wp_manage_posts_columns();
    817811}
    818812
    819813/**
     
    821815 *
    822816 * @since unknown
    823817 *
    824  * @param unknown_type $page
     818 * @param unknown_type $screen
    825819 * @return unknown
    826820 */
    827 function get_column_headers($page) {
     821function get_column_headers($screen) {
    828822        global $_wp_column_headers;
    829823
    830824        if ( !isset($_wp_column_headers) )
    831825                $_wp_column_headers = array();
    832826
    833         $map_screen = $page;
    834         $type = str_replace('edit-', '', $map_screen);
    835         if ( in_array($type, get_post_types()) )
    836                 $map_screen = 'edit';
     827        if ( is_string($screen) )
     828                $screen = convert_to_screen($screen);
    837829
    838830        // Store in static to avoid running filters on each call
    839         if ( isset($_wp_column_headers[$page]) )
    840                 return $_wp_column_headers[$page];
     831        if ( isset($_wp_column_headers[$screen->id]) )
     832                return $_wp_column_headers[$screen->id];
    841833
    842         switch ($map_screen) {
     834        switch ($screen->base) {
    843835                case 'edit':
    844                          $_wp_column_headers[$page] = wp_manage_posts_columns();
     836                         $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen );
    845837                         break;
    846                 case 'edit-pages':
    847                         $_wp_column_headers[$page] = wp_manage_pages_columns();
    848                         break;
    849838                case 'edit-comments':
    850                         $_wp_column_headers[$page] = array(
     839                        $_wp_column_headers[$screen->id] = array(
    851840                                'cb' => '<input type="checkbox" />',
    852841                                'author' => __('Author'),
    853842                                /* translators: column name */
     
    858847
    859848                        break;
    860849                case 'link-manager':
    861                         $_wp_column_headers[$page] = array(
     850                        $_wp_column_headers[$screen->id] = array(
    862851                                'cb' => '<input type="checkbox" />',
    863852                                'name' => __('Name'),
    864853                                'url' => __('URL'),
     
    870859
    871860                        break;
    872861                case 'upload':
    873                         $_wp_column_headers[$page] = wp_manage_media_columns();
     862                        $_wp_column_headers[$screen->id] = wp_manage_media_columns();
    874863                        break;
    875864                case 'categories':
    876                         $_wp_column_headers[$page] = array(
     865                        $_wp_column_headers[$screen->id] = array(
    877866                                'cb' => '<input type="checkbox" />',
    878867                                'name' => __('Name'),
    879868                                'description' => __('Description'),
     
    883872
    884873                        break;
    885874                case 'edit-link-categories':
    886                         $_wp_column_headers[$page] = array(
     875                        $_wp_column_headers[$screen->id] = array(
    887876                                'cb' => '<input type="checkbox" />',
    888877                                'name' => __('Name'),
    889878                                'description' => __('Description'),
     
    893882
    894883                        break;
    895884                case 'edit-tags':
    896                         $_wp_column_headers[$page] = array(
     885                        $_wp_column_headers[$screen->id] = array(
    897886                                'cb' => '<input type="checkbox" />',
    898887                                'name' => __('Name'),
    899888                                'description' => __('Description'),
     
    903892
    904893                        break;
    905894                case 'users':
    906                         $_wp_column_headers[$page] = array(
     895                        $_wp_column_headers[$screen->id] = array(
    907896                                'cb' => '<input type="checkbox" />',
    908897                                'username' => __('Username'),
    909898                                'name' => __('Name'),
     
    913902                        );
    914903                        break;
    915904                default :
    916                         $_wp_column_headers[$page] = array();
     905                        $_wp_column_headers[$screen->id] = array();
    917906        }
    918907
    919         $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
    920         return $_wp_column_headers[$page];
     908        $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]);
     909        return $_wp_column_headers[$screen->id];
    921910}
    922911
    923912/**
     
    925914 *
    926915 * @since unknown
    927916 *
    928  * @param unknown_type $type
     917 * @param unknown_type $screen
    929918 * @param unknown_type $id
    930919 */
    931 function print_column_headers( $type, $id = true ) {
    932         $type = str_replace('.php', '', $type);
    933         $columns = get_column_headers( $type );
    934         $hidden = get_hidden_columns($type);
     920function print_column_headers( $screen, $id = true ) {
     921        if ( is_string($screen) )
     922                $screen = convert_to_screen($screen);
     923
     924        $columns = get_column_headers( $screen );
     925        $hidden = get_hidden_columns($screen);
    935926        $styles = array();
    936927
    937928        foreach ( $columns as $column_key => $column_display_name ) {
     
    950941                if ( in_array($column_key, $hidden) )
    951942                        $style = 'display:none;';
    952943
    953                 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
    954                         $style .= ' ' . $styles[$type][$column_key];
     944                if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) )
     945                        $style .= ' ' . $styles[$screen>id][$column_key];
    955946                $style = ' style="' . $style . '"';
    956947?>
    957948        <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
     
    970961function register_column_headers($screen, $columns) {
    971962        global $_wp_column_headers;
    972963
     964        if ( is_string($screen) )
     965                $screen = convert_to_screen($screen);
     966
    973967        if ( !isset($_wp_column_headers) )
    974968                $_wp_column_headers = array();
    975969
    976         $_wp_column_headers[$screen] = $columns;
     970        $_wp_column_headers[$screen->id] = $columns;
    977971}
    978972
    979973/**
     
    981975 *
    982976 * @since unknown
    983977 *
    984  * @param unknown_type $page
     978 * @param unknown_type $screen
    985979 */
    986 function get_hidden_columns($page) {
    987         $page = str_replace('.php', '', $page);
    988         return (array) get_user_option( 'manage-' . $page . '-columns-hidden' );
     980function get_hidden_columns($screen) {
     981        if ( is_string($screen) )
     982                $screen = convert_to_screen($screen);
     983
     984        return (array) get_user_option( 'manage-' . $screen->id. '-columns-hidden' );
    989985}
    990986
    991987/**
     
    997993 *
    998994 * @param string $type 'post' or 'page'
    999995 */
    1000 function inline_edit_row( $type ) {
     996function inline_edit_row( $screen ) {
    1001997        global $current_user, $mode;
    1002998
    1003         $is_page = 'page' == $type;
    1004         if ( $is_page ) {
    1005                 $screen = 'edit-pages';
    1006                 $post = get_default_page_to_edit();
    1007         } else {
    1008                 $screen = 'edit';
    1009                 $post = get_default_post_to_edit();
     999        if ( is_string($screen) ) {
     1000                $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen );
     1001                $screen = (object) $screen;
    10101002        }
    10111003
    1012         $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
     1004        $post = get_default_post_to_edit( $screen->post_type );
     1005        $post_type_object = get_post_type_object( $screen->post_type );
     1006
     1007        $columns = wp_manage_posts_columns($screen);
    10131008        $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
    10141009        $col_count = count($columns) - count($hidden);
    10151010        $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
    1016         $can_publish = current_user_can("publish_{$type}s");
     1011        // @todo use capability_type
     1012        $can_publish = current_user_can("publish_{$screen->post_type}s");
    10171013        $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
    10181014
    10191015?>
     
    10231019        $bulk = 0;
    10241020        while ( $bulk < 2 ) { ?>
    10251021
    1026         <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
    1027                 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
     1022        <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$screen->post_type ";
     1023                echo $bulk ? "bulk-edit-row bulk-edit-row-$screen->post_type" : "quick-edit-row quick-edit-row-$screen->post_type";
    10281024        ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
    10291025
    10301026        <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
    1031                 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
     1027                <h4><?php echo $bulk ? ( __( 'Bulk Edit' ) ) : __( 'Quick Edit' ); ?></h4>
    10321028
    10331029
    10341030<?php if ( $bulk ) : ?>
     
    10611057
    10621058<?php endif; // $bulk
    10631059
    1064                 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
     1060                $authors = get_editable_user_ids( $current_user->id, true, $screen->post_type ); // TODO: ROLE SYSTEM
    10651061                $authors_dropdown = '';
    10661062                if ( $authors && count( $authors ) > 1 ) :
    10671063                        $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);
     
    10911087                        </em>
    10921088                        <label class="alignleft inline-edit-private">
    10931089                                <input type="checkbox" name="keep_private" value="private" />
    1094                                 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
     1090                                <span class="checkbox-title"><?php echo __('Private'); ?></span>
    10951091                        </label>
    10961092                </div>
    10971093
     
    10991095
    11001096        </div></fieldset>
    11011097
    1102 <?php if ( !$is_page && !$bulk ) : ?>
     1098<?php if ( is_object_in_taxonomy($screen->post_type, 'categories') && !$bulk ) : ?>
    11031099
    11041100        <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
    11051101                <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
     
    11111107                </ul>
    11121108        </div></fieldset>
    11131109
    1114 <?php endif; // !$is_page && !$bulk ?>
     1110<?php endif; // !hierarchical && !$bulk ?>
    11151111
    11161112        <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
    11171113
     
    11201116                echo $authors_dropdown;
    11211117?>
    11221118
    1123 <?php if ( $is_page ) : ?>
     1119<?php if ( $post_type_object->hierarchical ) : ?>
    11241120
    11251121                <label>
    11261122                        <span class="title"><?php _e( 'Parent' ); ?></span>
     
    12201216                                </select>
    12211217                        </label>
    12221218
    1223 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
     1219<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
    12241220
    12251221<?php   if ( $bulk ) : ?>
    12261222
     
    12591255                <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
    12601256                <?php if ( ! $bulk ) {
    12611257                        wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
    1262                         $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
     1258                        $update_text = __( 'Update' );
    12631259                        ?>
    12641260                        <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
    12651261                        <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
    12661262                <?php } else {
    1267                         $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
     1263                        $update_text = __( 'Update' );
    12681264                ?>
    12691265                        <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
    12701266                <?php } ?>
     
    13681364 * @param unknown_type $mode
    13691365 */
    13701366function _post_row($a_post, $pending_comments, $mode) {
    1371         global $post, $current_user;
     1367        global $post, $current_user, $current_screen;
    13721368        static $rowclass;
    13731369
    13741370        $global_post = $post;
     
    13821378?>
    13831379        <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
    13841380<?php
    1385         $posts_columns = get_column_headers('edit');
    1386         $hidden = get_hidden_columns('edit');
     1381        $posts_columns = get_column_headers( $current_screen );
     1382        $hidden = get_hidden_columns( $current_screen );
    13871383        foreach ( $posts_columns as $column_name=>$column_display_name ) {
    13881384                $class = "class=\"$column_name column-$column_name\"";
    13891385
     
    15781574 * @param unknown_type $level
    15791575 */
    15801576function display_page_row( $page, $level = 0 ) {
    1581         global $post;
     1577        global $post, $current_screen;
    15821578        static $rowclass;
    15831579
    15841580        $post = $page;
     
    16051601        $pad = str_repeat( '&#8212; ', $level );
    16061602        $id = (int) $page->ID;
    16071603        $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
    1608         $posts_columns = get_column_headers('edit-pages');
    1609         $hidden = get_hidden_columns('edit-pages');
     1604        $posts_columns = get_column_headers( $current_screen );
     1605        $hidden = get_hidden_columns(  $current_screen );
    16101606        $title = _draft_or_post_title();
    16111607?>
    16121608<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
     
    30553051 *
    30563052 * @since unknown
    30573053 *
    3058  * @param unknown_type $page
     3054 * @param unknown_type $screen
    30593055 */
    3060 function meta_box_prefs($page) {
     3056function meta_box_prefs($screen) {
    30613057        global $wp_meta_boxes;
    30623058
    3063         if ( empty($wp_meta_boxes[$page]) )
     3059        if ( is_string($screen) )
     3060                $screen = convert_to_screen($screen);
     3061
     3062        if ( empty($wp_meta_boxes[$screen->id]) )
    30643063                return;
    30653064
    3066         $hidden = get_hidden_meta_boxes($page);
     3065        $hidden = get_hidden_meta_boxes($screen);
    30673066
    3068         foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
    3069                 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
    3070                         foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
     3067        foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
     3068                foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
     3069                        foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
    30713070                                if ( false == $box || ! $box['title'] )
    30723071                                        continue;
    30733072                                // Submit box cannot be hidden
     
    30823081        }
    30833082}
    30843083
    3085 function get_hidden_meta_boxes($page) {
    3086         $hidden = (array) get_user_option( "meta-box-hidden_$page" );
     3084function get_hidden_meta_boxes($screen) {
     3085        if ( is_string($screen) )
     3086                $screen = convert_to_screen($screen);
    30873087
     3088        $hidden = (array) get_user_option( "meta-box-hidden_$screen->id" );
     3089
    30883090        // Hide slug boxes by default
    30893091        if ( empty($hidden[0]) ) {
    30903092                $hidden = array('slugdiv');
     
    32783280 * @since unknown
    32793281 */
    32803282function favorite_actions( $screen = null ) {
    3281         switch ( $screen ) {
    3282                 case 'post-new.php':
     3283        if ( is_string($screen) )
     3284                $screen = convert_to_screen($screen);
     3285
     3286        switch ( $screen->id ) {
     3287                case 'post':
    32833288                        $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
    32843289                        break;
    3285                 case 'edit-pages.php':
    3286                         $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
     3290                case 'edit-page':
     3291                        $default_action = array('post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'));
    32873292                        break;
    3288                 case 'page-new.php':
    3289                         $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
     3293                case 'page':
     3294                        $default_action = array('edit.php?post_type=page' => array(__('Edit Pages'), 'edit_pages'));
    32903295                        break;
    32913296                case 'upload.php':
    32923297                        $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
    32933298                        break;
    3294                 case 'media-new.php':
     3299                case 'media':
    32953300                        $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
    32963301                        break;
    3297                 case 'link-manager.php':
     3302                case 'link-manager':
    32983303                        $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
    32993304                        break;
    3300                 case 'link-add.php':
     3305                case 'link-add':
    33013306                        $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
    33023307                        break;
    3303                 case 'users.php':
     3308                case 'users':
    33043309                        $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
    33053310                        break;
    3306                 case 'user-new.php':
     3311                case 'user':
    33073312                        $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
    33083313                        break;
    3309                 case 'plugins.php':
     3314                case 'plugins':
    33103315                        $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
    33113316                        break;
    3312                 case 'plugin-install.php':
     3317                case 'plugin-install':
    33133318                        $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
    33143319                        break;
    3315                 case 'themes.php':
     3320                case 'themes':
    33163321                        $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
    33173322                        break;
    3318                 case 'theme-install.php':
     3323                case 'theme-install':
    33193324                        $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
    33203325                        break;
    33213326                default:
     
    34833488        }
    34843489}
    34853490
    3486 function screen_meta($screen) {
    3487         global $wp_meta_boxes, $_wp_contextual_help, $typenow;
    3488 
     3491// Convert a screen string to a screen object
     3492function convert_to_screen( $screen ) {
    34893493        $screen = str_replace('.php', '', $screen);
    34903494        $screen = str_replace('-new', '', $screen);
    34913495        $screen = str_replace('-add', '', $screen);
    34923496        $screen = apply_filters('screen_meta_screen', $screen);
    34933497
     3498        $screen = array('id' => $screen, 'base' => $screen);
     3499        return (object) $screen;
     3500}
     3501
     3502function screen_meta($screen) {
     3503        global $wp_meta_boxes, $_wp_contextual_help, $post_type;
     3504
     3505        if ( is_string($screen) )
     3506                $screen = convert_to_screen($screen);
     3507
    34943508        $column_screens = get_column_headers($screen);
    34953509        $meta_screens = array('index' => 'dashboard');
    34963510
    3497         // Give post_type pages their own screen
    3498         if ( 'post' == $screen ) {
    3499                 if ( !empty($typenow) )
    3500                         $screen = $typenow;
     3511        if ( isset($meta_screens[$screen->id]) ) {
     3512                $screen->id = $meta_screens[$screen->id];
     3513                $screen->base = $screen->id;
    35013514        }
    3502         if ( 'edit' == $screen ) {
    3503                 if ( !empty($typenow) )
    3504                         $screen = 'edit-' . $typenow;
    3505         }
    35063515
    3507         if ( isset($meta_screens[$screen]) )
    3508                 $screen = $meta_screens[$screen];
    35093516        $show_screen = false;
    35103517        $show_on_screen = false;
    3511         if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) {
     3518        if ( !empty($wp_meta_boxes[$screen->id]) || !empty($column_screens) ) {
    35123519                $show_screen = true;
    35133520                $show_on_screen = true;
    35143521        }
     
    35223529
    35233530        $settings = '';
    35243531
    3525         switch ( $screen ) {
    3526                 case 'post':
    3527                         if ( !isset($_wp_contextual_help['post']) ) {
    3528                                 $help = drag_drop_help();
    3529                                 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
    3530                                 $_wp_contextual_help['post'] = $help;
    3531                         }
    3532                         break;
    3533                 case 'page':
    3534                         if ( !isset($_wp_contextual_help['page']) ) {
    3535                                 $help = drag_drop_help();
    3536                                 $_wp_contextual_help['page'] = $help;
    3537                         }
    3538                         break;
    3539                 case 'dashboard':
    3540                         if ( !isset($_wp_contextual_help['dashboard']) ) {
    3541                                 $help = '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n";
    3542                                 $help .= drag_drop_help();
    3543                                 $_wp_contextual_help['dashboard'] = $help;
    3544                         }
    3545                         break;
    3546                 case 'link':
    3547                         if ( !isset($_wp_contextual_help['link']) ) {
    3548                                 $help = drag_drop_help();
    3549                                 $_wp_contextual_help['link'] = $help;
    3550                         }
    3551                         break;
    3552                 case 'options-general':
    3553                         if ( !isset($_wp_contextual_help['options-general']) )
    3554                                 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
    3555                         break;
    3556                 case 'theme-install':
    3557                 case 'plugin-install':
    3558                         if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) {
    3559                                 $help = plugins_search_help();
    3560                                 $_wp_contextual_help[$screen] = $help;
    3561                         }
    3562                         break;
     3532        switch ( $screen->id ) {
    35633533                case 'widgets':
    3564                         if ( !isset($_wp_contextual_help['widgets']) ) {
    3565                                 $help = widgets_help();
    3566                                 $_wp_contextual_help['widgets'] = $help;
    3567                         }
    35683534                        $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
    35693535                        $show_screen = true;
    35703536                        break;
     
    36043570        <div id="contextual-help-wrap" class="hidden">
    36053571        <?php
    36063572        $contextual_help = '';
    3607         if ( isset($_wp_contextual_help[$screen]) ) {
     3573        if ( isset($_wp_contextual_help[$screen->id]) ) {
    36083574                if ( !empty($title) )
    36093575                        $contextual_help .= '<h5>' . sprintf(__('Get help with &#8220;%s&#8221;'), $title) . '</h5>';
    36103576                else
    36113577                        $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
    3612                 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
     3578                $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
    36133579
    36143580                $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
    36153581        } else {
     
    36513617function add_contextual_help($screen, $help) {
    36523618        global $_wp_contextual_help;
    36533619
     3620        if ( is_string($screen) )
     3621                $screen = convert_to_screen($screen);
     3622
    36543623        if ( !isset($_wp_contextual_help) )
    36553624                $_wp_contextual_help = array();
    36563625
    3657         $_wp_contextual_help[$screen] = $help;
     3626        $_wp_contextual_help[$screen->id] = $help;
    36583627}
    36593628
    36603629function drag_drop_help() {
     
    36743643';
    36753644}
    36763645
    3677 function widgets_help() {
    3678         return '
    3679         <p>' . __('Widgets are added and arranged by simple drag &#8217;n&#8217; drop. If you hover your mouse over the titlebar of a widget, you&#8217;ll see a 4-arrow cursor which indicates that the widget is movable.  Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you&#8217;ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
    3680         <p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
    3681         <p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
    3682         <p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
    3683 ';
    3684 }
    3685 
    36863646function screen_layout($screen) {
    36873647        global $screen_layout_columns;
    36883648
     3649        if ( is_string($screen) )
     3650                $screen = convert_to_screen($screen);
     3651
    36893652        $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
    36903653
    36913654        // Add custom post types
    36923655        foreach ( get_post_types( array('_show' => true) ) as $post_type )
    36933656                $columns[$post_type] = 2;
    36943657
    3695         $columns = apply_filters('screen_layout_columns', $columns, $screen);
     3658        $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen);
    36963659
    3697         if ( !isset($columns[$screen]) ) {
     3660        if ( !isset($columns[$screen->id]) ) {
    36983661                $screen_layout_columns = 0;
    36993662                return '';
    37003663        }
    37013664
    3702         $screen_layout_columns = get_user_option("screen_layout_$screen");
    3703         $num = $columns[$screen];
     3665        $screen_layout_columns = get_user_option("screen_layout_$screen->id");
     3666        $num = $columns[$screen->id];
    37043667
    37053668        if ( ! $screen_layout_columns )
    37063669                        $screen_layout_columns = 2;
     
    37163679}
    37173680
    37183681function screen_options($screen) {
    3719         $map_screen = $screen;
    3720         $type = str_replace('edit-', '', $map_screen);
    3721         if ( in_array($type, get_post_types()) )
    3722                 $map_screen = 'edit';
     3682        if ( is_string($screen) )
     3683                $screen = convert_to_screen($screen);
    37233684
    3724         switch ( $map_screen ) {
     3685        switch ( $screen->base ) {
    37253686                case 'edit':
    37263687                        $per_page_label = __('Posts per page:');
    37273688                        break;
     
    37473708                        return '';
    37483709        }
    37493710
    3750         $option = str_replace( '-', '_', "${screen}_per_page" );
     3711        $option = str_replace( '-', '_', "{$screen->id}_per_page" );
    37513712        $per_page = (int) get_user_option( $option );
    37523713        if ( empty( $per_page ) || $per_page < 1 ) {
    3753                 if ( 'plugins' == $screen )
     3714                if ( 'plugins' == $screen->id )
    37543715                        $per_page = 999;
    37553716                else
    37563717                        $per_page = 20;
     
    37723733        return $return;
    37733734}
    37743735
    3775 function screen_icon($name = '') {
    3776         global $parent_file, $hook_suffix;
     3736function screen_icon($screen = '') {
     3737        global $current_screen;
    37773738
     3739        if ( empty($screen) )
     3740                $screen = $current_screen;
     3741        elseif ( is_string($screen) )
     3742                $name = $screen;
     3743
    37783744        if ( empty($name) ) {
    3779                 if ( isset($parent_file) && !empty($parent_file) ) {
    3780                         $name = $parent_file;
    3781                         if ( false !== $pos = strpos($name, '?post_type=') )
    3782                                 $name = substr($name, 0, $pos);
    3783                         $name = substr($name, 0, -4);
    3784                 }
     3745                if ( !empty($screen->parent_base) )
     3746                        $name = $screen->parent_base;
    37853747                else
    3786                         $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
     3748                        $name = $screen->base;
    37873749        }
    37883750?>
    37893751        <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
  • wp-admin/post.php

     
    2323else
    2424        $post_id = 0;
    2525$post_ID = $post_id;
    26 
    2726$post = null;
    2827$post_type_object = null;
    2928$post_type_cap = null;
     29$post_type = null;
    3030if ( $post_id ) {
    3131        $post = get_post($post_id);
    3232        if ( $post ) {
    3333                $post_type_object = get_post_type_object($post->post_type);
    34                 if ( $post_type_object )
     34                if ( $post_type_object ) {
     35                        $post_type = $post->post_type;
     36                        $current_screen->post_type = $post->post_type;
     37                        $current_screen->id = $current_screen->post_type;
    3538                        $post_type_cap = $post_type_object->capability_type;
     39                }
    3640        }
     41} elseif ( isset($_POST['post_type']) ) {
     42        $post_type_object = get_post_type_object($_POST['post_type']);
     43        if ( $post_type_object ) {
     44                $post_type = $post_type_object->name;
     45                $current_screen->post_type = $post_type;
     46                $current_screen->id = $current_screen->post_type;
     47                $post_type_cap = $post_type_object->capability_type;
     48        }
    3749}
    3850
    3951/**
     
    108120case 'post':
    109121case 'post-quickpress-publish':
    110122case 'post-quickpress-save':
    111         check_admin_referer('add-post');
     123        check_admin_referer('add-' . $post_type);
    112124
    113125        if ( 'post-quickpress-publish' == $action )
    114126                $_POST['publish'] = 'publish'; // tell write_post() to publish
     
    163175        if ( 'post' == $post_type ) {
    164176                $parent_file = "edit.php";
    165177                $submenu_file = "edit.php";
    166         } elseif ( 'page' == $post_type ) {
    167                 $parent_file = "edit-pages.php";
    168                 $submenu_file = "edit-pages.php";
    169178        } else {
    170                 if ( $post_type_object->hierarchical ) {
    171                         $parent_file = "edit-pages.php?post_type=$post_type";
    172                         $submenu_file = "edit-pages.php?post_type=$post_type";
    173                 } else {
    174                         $parent_file = "edit.php?post_type=$post_type";
    175                         $submenu_file = "edit.php?post_type=$post_type";
    176                 }
     179                $parent_file = "edit.php?post_type=$post_type";
     180                $submenu_file = "edit.php?post_type=$post_type";
    177181        }
    178182
    179183        wp_enqueue_script('post');
     
    213217        wp_update_attachment_metadata( $post_id, $newmeta );
    214218
    215219case 'editpost':
    216         check_admin_referer('update-' . $post->post_type . '_' . $post_id);
     220        check_admin_referer('update-' . $post_type . '_' . $post_id);
    217221
    218222        $post_id = edit_post();
    219223
     
    223227        break;
    224228
    225229case 'trash':
    226         check_admin_referer('trash-post_' . $post_id);
     230        check_admin_referer('trash-' . $post_type . '_' . $post_id);
    227231
    228232        $post = & get_post($post_id);
    229233
     
    238242        break;
    239243
    240244case 'untrash':
    241         check_admin_referer('untrash-post_' . $post_id);
     245        check_admin_referer('untrash-' . $post_type . '_' . $post_id);
    242246
    243247        if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
    244248                wp_die( __('You are not allowed to move this item out of the trash.') );
     
    251255        break;
    252256
    253257case 'delete':
    254         check_admin_referer('delete-post_' . $post_id);
     258        check_admin_referer('delete-' . $post_type . '_' . $post_id);
    255259
    256260        if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
    257261                wp_die( __('You are not allowed to delete this item.') );
     
    280284        break;
    281285
    282286default:
    283         if ( $post_type_object->hierarchical )
    284                 wp_redirect('edit-pages.php');
    285         else
    286287                wp_redirect('edit.php');
    287288        exit();
    288289        break;
  • wp-admin/admin.php

     
    177177if ( !empty($_REQUEST['action']) )
    178178        do_action('admin_action_' . $_REQUEST['action']);
    179179
     180$hook_suffix = '';
     181if ( isset($page_hook) )
     182        $hook_suffix = $page_hook;
     183else if ( isset($plugin_page) )
     184        $hook_suffix = $plugin_page;
     185else if ( isset($pagenow) )
     186        $hook_suffix = $pagenow;
     187
     188if ( isset($_GET['post_type']) )
     189        $typenow = $_GET['post_type'];
     190else
     191        $typenow = '';
     192// @todo validate typenow against post types.
     193
     194/**
     195 * Global object containing info about the current screen.
     196 */
     197$current_screen = $hook_suffix;
     198$current_screen = str_replace('.php', '', $current_screen);
     199$current_screen = str_replace('-new', '', $current_screen);
     200$current_screen = str_replace('-add', '', $current_screen);
     201$current_screen = array('id' => $current_screen, 'base' => $current_screen);
     202$current_screen = (object) $current_screen;
     203if ( 'edit' == $current_screen->id ) {
     204        if ( empty($typenow) )
     205                $typenow = 'post';
     206        $current_screen->id .= '-' . $typenow;
     207        $current_screen->post_type = $typenow;
     208} elseif ( 'post' == $current_screen->id ) {
     209        if ( empty($typenow) )
     210                $typenow = 'post';
     211        $current_screen->id = $typenow;
     212        $current_screen->post_type = $typenow;
     213} else {
     214        $typenow = '';
     215}
     216
     217$current_screen = apply_filters('current_screen', $current_screen);
     218
    180219?>
  • wp-admin/edit-post-rows.php

     
    1313<table class="widefat post fixed" cellspacing="0">
    1414        <thead>
    1515        <tr>
    16 <?php print_column_headers('edit'); ?>
     16<?php print_column_headers( $current_screen ); ?>
    1717        </tr>
    1818        </thead>
    1919
    2020        <tfoot>
    2121        <tr>
    22 <?php print_column_headers('edit', false); ?>
     22<?php print_column_headers($current_screen, false); ?>
    2323        </tr>
    2424        </tfoot>
    2525
    2626        <tbody>
    27 <?php post_rows(); ?>
     27<?php
     28if ( $post_type_object->hierarchical )
     29        page_rows($posts, $pagenum, $per_page);
     30else
     31        post_rows();
     32?>
    2833        </tbody>
    2934</table>
     35 No newline at end of file
  • wp-admin/options-general.php

     
    5050}
    5151add_filter('admin_head', 'add_js');
    5252
     53add_contextual_help($current_screen, __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>'));
     54
    5355include('./admin-header.php');
    5456?>
    5557
  • wp-admin/index.php

     
    2323
    2424$title = __('Dashboard');
    2525$parent_file = 'index.php';
     26
     27add_contextual_help($current_screen, '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n" . drag_drop_help() );
     28
    2629require_once('admin-header.php');
    2730
    2831$today = current_time('mysql', 1);
  • wp-admin/edit-link-form.php

     
    3434do_action('do_meta_boxes', 'link', 'advanced', $link);
    3535do_action('do_meta_boxes', 'link', 'side', $link);
    3636
     37add_contextual_help($current_screen, drag_drop_help());
     38
    3739require_once ('admin-header.php');
    3840
    3941?>
  • wp-admin/edit-form-advanced.php

     
    142142do_action('do_meta_boxes', $post_type, 'advanced', $post);
    143143do_action('do_meta_boxes', $post_type, 'side', $post);
    144144
     145add_contextual_help($current_screen, drag_drop_help());
     146
    145147require_once('admin-header.php');
    146148?>
    147149
  • wp-admin/plugin-install.php

     
    5252
    5353do_action('install_plugins_pre_' . $tab); //Used to override the general interface, Eg, install or plugin information.
    5454
     55add_contextual_help($current_screen, plugins_search_help());
     56
    5557include('admin-header.php');
    5658?>
    5759<div class="wrap">
  • wp-admin/menu.php

     
    6868        $submenu['link-manager.php'][10] = array( _x('Add New', 'links'), 'manage_links', 'link-add.php' );
    6969        $submenu['link-manager.php'][15] = array( __('Link Categories'), 'manage_categories', 'edit-link-categories.php' );
    7070
    71 $menu[20] = array( __('Pages'), 'edit_pages', 'edit-pages.php', '', 'menu-top', 'menu-pages', 'div' );
    72         $submenu['edit-pages.php'][5] = array( __('Edit'), 'edit_pages', 'edit-pages.php' );
     71$menu[20] = array( __('Pages'), 'edit_pages', 'edit.php?post_type=page', '', 'menu-top', 'menu-pages', 'div' );
     72        $submenu['edit.php?post_type=page'][5] = array( __('Edit'), 'edit_pages', 'edit.php?post_type=page' );
    7373        /* translators: add new page */
    74         $submenu['edit-pages.php'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
     74        $submenu['edit.php?post_type=page'][10] = array( _x('Add New', 'page'), 'edit_pages', 'post-new.php?post_type=page' );
    7575
    7676$menu[25] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>" ), 'edit_posts', 'edit-comments.php', '', 'menu-top', 'menu-comments', 'div' );
    7777
  • wp-admin/admin-header.php

     
    2929        wp_admin_css( 'css/ms' );
    3030wp_enqueue_script('utils');
    3131
    32 $hook_suffix = '';
    33 if ( isset($page_hook) )
    34         $hook_suffix = $page_hook;
    35 else if ( isset($plugin_page) )
    36         $hook_suffix = $plugin_page;
    37 else if ( isset($pagenow) )
    38         $hook_suffix = $pagenow;
    39 
    40 if ( isset($submenu_file) && (false !== $pos = strpos($submenu_file, 'post_type=')) )
    41         $typenow = substr($submenu_file, $pos + 10);
    42 elseif ( isset($parent_file) && (false !== $pos = strpos($parent_file, 'post_type=')) )
    43         $typenow = substr($parent_file, $pos + 10);
    44 else
    45         $typenow = '';
    46 
    4732$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
    4833?>
    4934<script type="text/javascript">
     
    119104<a href="<?php echo wp_logout_url() ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a></p>
    120105</div>
    121106
    122 <?php favorite_actions($hook_suffix); ?>
     107<?php favorite_actions($current_screen); ?>
    123108</div>
    124109</div>
    125110
    126111<div id="wpbody">
    127 <?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
     112<?php
     113require(ABSPATH . 'wp-admin/menu-header.php');
    128114
     115$current_screen->parent_file = $parent_file;
     116$current_screen->parent_base = preg_replace('/\?.*$/', '', $parent_file);
     117$current_screen->parent_base = str_replace('.php', '', $current_screen->parent_base);
     118?>
     119
    129120<div id="wpbody-content">
    130121<?php
    131 screen_meta($hook_suffix);
     122screen_meta($current_screen);
    132123
    133124do_action('admin_notices');
    134125
  • wp-admin/plugins.php

     
    236236$help .= '<p>' . sprintf(__('You can find additional plugins for your site by using the new <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> directly and installing manually.  To <em>manually</em> install a plugin you generally just need to upload the plugin file into your <code>%2$s</code> directory.  Once a plugin has been installed, you may activate it here.'), 'plugin-install.php', WP_PLUGIN_DIR) . '</p>';
    237237}
    238238
    239 add_contextual_help('plugins', $help);
     239add_contextual_help($current_screen, $help);
    240240
    241241if ( is_multisite() && is_super_admin() ) {
    242242        $menu_perms = get_site_option('menu_items', array());
  • wp-admin/edit.php

     
    2020        unset( $_redirect );
    2121}
    2222
    23 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('_show' => true) ) ) )
     23if ( isset($_GET['post_type']) && ( in_array( $_GET['post_type'], get_post_types( array('_show' => true ) ) ) || in_array( $_GET['post_type'], get_post_types( array('_builtin' => true ) ) ) ) )
    2424        $post_type = $_GET['post_type'];
    2525else
    2626        $post_type = 'post';
    2727$_GET['post_type'] = $post_type;
    2828
    2929$post_type_object = get_post_type_object($post_type);
     30$post_type_cap = $post_type_object->capability_type;
    3031
    3132if ( 'post' != $post_type ) {
    3233        $parent_file = "edit.php?post_type=$post_type";
     
    3839        $post_new_file = 'post-new.php';
    3940}
    4041
     42$pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
     43if ( empty($pagenum) )
     44        $pagenum = 1;
     45$per_page = 'edit_' . $post_type . '_per_page';
     46$per_page = (int) get_user_option( $per_page );
     47if ( empty( $per_page ) || $per_page < 1 )
     48        $per_page = 15;
     49// @todo filter based on type
     50$per_page = apply_filters( 'edit_posts_per_page', $per_page );
     51
    4152// Handle bulk actions
    4253if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    4354        check_admin_referer('bulk-posts');
     
    6172                case 'trash':
    6273                        $trashed = 0;
    6374                        foreach( (array) $post_ids as $post_id ) {
    64                                 if ( !current_user_can('delete_post', $post_id) )
    65                                         wp_die( __('You are not allowed to move this post to the trash.') );
     75                                if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     76                                        wp_die( __('You are not allowed to move this item to the trash.') );
    6677
    6778                                if ( !wp_trash_post($post_id) )
    6879                                        wp_die( __('Error in moving to trash...') );
     
    7485                case 'untrash':
    7586                        $untrashed = 0;
    7687                        foreach( (array) $post_ids as $post_id ) {
    77                                 if ( !current_user_can('delete_post', $post_id) )
    78                                         wp_die( __('You are not allowed to restore this post from the trash.') );
     88                                if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     89                                        wp_die( __('You are not allowed to restore this item from the trash.') );
    7990
    8091                                if ( !wp_untrash_post($post_id) )
    8192                                        wp_die( __('Error in restoring from trash...') );
     
    89100                        foreach( (array) $post_ids as $post_id ) {
    90101                                $post_del = & get_post($post_id);
    91102
    92                                 if ( !current_user_can('delete_post', $post_id) )
    93                                         wp_die( __('You are not allowed to delete this post.') );
     103                                if ( !current_user_can('delete_' .  $post_type_cap, $post_id) )
     104                                        wp_die( __('You are not allowed to delete this item.') );
    94105
    95106                                if ( $post_del->post_type == 'attachment' ) {
    96107                                        if ( ! wp_delete_attachment($post_id) )
     
    130141wp_enqueue_script('inline-edit-post');
    131142
    132143$user_posts = false;
    133 if ( !current_user_can('edit_others_posts') ) {
     144if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) {
    134145        $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) );
    135146        $user_posts = true;
    136147        if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
     
    139150
    140151$avail_post_stati = wp_edit_posts_query();
    141152
     153if ( $post_type_object->hierarchical )
     154        $num_pages = ceil($wp_query->post_count / $per_page);
     155else
     156        $num_pages = $wp_query->max_num_pages;
     157
    142158require_once('admin-header.php');
    143159
    144 if ( !isset( $_GET['paged'] ) )
    145         $_GET['paged'] = 1;
    146 
    147160if ( empty($_GET['mode']) )
    148161        $mode = 'list';
    149162else
     
    158171
    159172<?php
    160173if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
    161 <div id="message" class="updated"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
     174<div id="message" class="updated"><p><strong><?php _e('This has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
    162175<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    163176endif; ?>
    164177
     
    173186        unset($_GET['skipped']);
    174187
    175188if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
    176         printf( _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
     189        printf( _n( '%s item not updated, somebody is editing it.', '%s items not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
    177190        unset($_GET['locked']);
    178191}
    179192
    180193if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
    181         printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
     194        printf( _n( 'Item permanently deleted.', '%s items permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
    182195        unset($_GET['deleted']);
    183196}
    184197
    185198if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
    186         printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
     199        printf( _n( 'Item moved to the trash.', '%s items moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
    187200        $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
    188201        echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a><br />';
    189202        unset($_GET['trashed']);
    190203}
    191204
    192205if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
    193         printf( _n( 'Post restored from the trash.', '%s posts restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     206        printf( _n( 'Item restored from the trash.', '%s items restored from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
    194207        unset($_GET['undeleted']);
    195208}
    196209
     
    212225if ( $user_posts ) {
    213226        if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user->ID ) )
    214227                $class = ' class="current"';
    215         $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'My Posts <span class="count">(%s)</span>', 'My Posts <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';
     228        $status_links[] = "<li><a href='edit.php?author=$current_user->ID'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . '</a>';
    216229        $allposts = '?all_posts=1';
    217230}
    218231
     
    261274        'format' => '',
    262275        'prev_text' => __('&laquo;'),
    263276        'next_text' => __('&raquo;'),
    264         'total' => $wp_query->max_num_pages,
    265         'current' => $_GET['paged']
     277        'total' => $num_pages,
     278        'current' => $pagenum
    266279));
    267280
    268281$is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
     
    318331<?php } ?>
    319332
    320333<?php
    321 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
    322         'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
    323 wp_dropdown_categories($dropdown_options);
    324 do_action('restrict_manage_posts');
     334if ( is_object_in_taxonomy($post_type, 'category') ) {
     335        $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
     336                'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
     337        wp_dropdown_categories($dropdown_options);
     338        do_action('restrict_manage_posts');
     339}
    325340?>
    326341<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
    327342<?php }
    328343
    329 if ( $is_trash && current_user_can('edit_others_posts') ) { ?>
     344if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?>
    330345<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    331346<?php } ?>
    332347</div>
    333348
    334349<?php if ( $page_links ) { ?>
    335350<div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
    336         number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
    337         number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
     351        number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
     352        number_format_i18n( min( $pagenum * $per_page, $wp_query->found_posts ) ),
    338353        number_format_i18n( $wp_query->found_posts ),
    339354        $page_links
    340355); echo $page_links_text; ?></div>
     
    373388<?php } ?>
    374389</select>
    375390<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    376 <?php if ( $is_trash && current_user_can('edit_others_posts') ) { ?>
     391<?php if ( $is_trash && current_user_can('edit_others_' . $post_type_cap . 's') ) { ?>
    377392<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    378393<?php } ?>
    379394<br class="clear" />
     
    393408
    394409</form>
    395410
    396 <?php inline_edit_row( 'post' ); ?>
     411<?php inline_edit_row( $current_screen ); ?>
    397412
    398413<div id="ajax-response"></div>
    399414<br class="clear" />
  • wp-admin/theme-install.php

     
    5252
    5353do_action('install_themes_pre_' . $tab); //Used to override the general interface, Eg, install or theme information.
    5454
     55add_contextual_help($current_screen, plugins_search_help());
     56
    5557include('admin-header.php');
    5658?>
    5759<div class="wrap">
  • wp-admin/widgets.php

     
    3333$title = __( 'Widgets' );
    3434$parent_file = 'themes.php';
    3535
     36$help = '
     37        <p>' . __('Widgets are added and arranged by simple drag &#8217;n&#8217; drop. If you hover your mouse over the titlebar of a widget, you&#8217;ll see a 4-arrow cursor which indicates that the widget is movable.  Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you&#8217;ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
     38        <p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
     39        <p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
     40        <p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
     41';
     42add_contextual_help($current_screen, $help);
     43
    3644// register the inactive_widgets area as sidebar
    3745register_sidebar(array(
    3846        'name' => __('Inactive Widgets'),
  • wp-admin/edit-pages.php

     
    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 if ( !current_user_can('edit_pages') )
    13         wp_die(__('Cheatin&#8217; uh?'));
    14 
    15 // Handle bulk actions
    16 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
    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('post-new.php?post_type=page');
    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         }
    33 
    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;
    61                 case 'delete':
    62                         $deleted = 0;
    63                         foreach( (array) $post_ids as $post_id ) {
    64                                 $post_del = & get_post($post_id);
    65 
    66                                 if ( !current_user_can('delete_page', $post_id) )
    67                                         wp_die( __('You are not allowed to delete this page.') );
    68 
    69                                 if ( $post_del->post_type == 'attachment' ) {
    70                                         if ( ! wp_delete_attachment($post_id) )
    71                                                 wp_die( __('Error in deleting...') );
    72                                 } else {
    73                                         if ( !wp_delete_post($post_id) )
    74                                                 wp_die( __('Error in deleting...') );
    75                                 }
    76                                 $deleted++;
    77                         }
    78                         $sendback = add_query_arg('deleted', $deleted, $sendback);
    79                         break;
    80                 case 'edit':
    81                         $_GET['post_type'] = 'page';
    82                         $done = bulk_edit_posts($_GET);
    83 
    84                         if ( is_array($done) ) {
    85                                 $done['updated'] = count( $done['updated'] );
    86                                 $done['skipped'] = count( $done['skipped'] );
    87                                 $done['locked'] = count( $done['locked'] );
    88                                 $sendback = add_query_arg( $done, $sendback );
    89                         }
    90                         break;
    91         }
    92 
    93         if ( isset($_GET['action']) )
    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 );
    95 
    96         wp_redirect($sendback);
    97         exit();
    98 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
    99          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
    100          exit;
    101 }
    102 
    103 if ( empty($title) )
    104         $title = __('Edit Pages');
    105 $parent_file = 'edit-pages.php';
    106 wp_enqueue_script('inline-edit-post');
    107 
    108 $post_stati  = array(   //      array( adj, noun )
    109                 'publish' => array(_x('Published', 'page'), __('Published pages'), _nx_noop('Published <span class="count">(%s)</span>', 'Published <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')),
    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')),
    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')),
    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'))
    115         );
    116 
    117 if ( !EMPTY_TRASH_DAYS )
    118         unset($post_stati['trash']);
    119 
    120 $post_stati = apply_filters('page_stati', $post_stati);
    121 
    122 $query = array('post_type' => 'page', 'orderby' => 'menu_order title',
    123         'posts_per_page' => -1, 'posts_per_archive_page' => -1, 'order' => 'asc');
    124 
    125 $post_status_label = __('Pages');
    126 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
    127         $post_status_label = $post_stati[$_GET['post_status']][1];
    128         $query['post_status'] = $_GET['post_status'];
    129         $query['perm'] = 'readable';
    130 }
    131 
    132 $query = apply_filters('manage_pages_query', $query);
    133 wp($query);
    134 
    135 if ( is_singular() ) {
    136         wp_enqueue_script( 'admin-comments' );
    137         enqueue_comment_hotkeys_js();
    138 }
    139 
    140 require_once('admin-header.php'); ?>
    141 
    142 <div class="wrap">
    143 <?php screen_icon(); ?>
    144 <h2><?php echo esc_html( $title ); ?> <a href="post-new.php?post_type=page" class="button add-new-h2"><?php echo esc_html_x('Add New', 'page'); ?></a> <?php
    145 if ( isset($_GET['s']) && $_GET['s'] )
    146         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( get_search_query() ) ); ?>
    147 </h2>
    148 
    149 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
    150 <div id="message" class="updated"><p>
    151 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
    152         printf( _n( '%s page updated.', '%s pages updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
    153         unset($_GET['updated']);
    154 }
    155 if ( isset($_GET['skipped']) && (int) $_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'] ) );
    157         unset($_GET['skipped']);
    158 }
    159 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
    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'] ) );
    161         unset($_GET['locked']);
    162 }
    163 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
    164         printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
    165         unset($_GET['deleted']);
    166 }
    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'] );
    178 ?>
    179 </p></div>
    180 <?php } ?>
    181 
    182 <?php if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
    183 <div id="message" class="updated"><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>
    184 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    185 endif; ?>
    186 
    187 <form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get">
    188 <ul class="subsubsub">
    189 <?php
    190 
    191 $avail_post_stati = get_available_post_statuses('page');
    192 if ( empty($locked_post_status) ) :
    193 $status_links = array();
    194 $num_posts = wp_count_posts('page', 'readable');
    195 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
    196 $class = empty($_GET['post_status']) ? ' class="current"' : '';
    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>';
    198 foreach ( $post_stati as $status => $label ) {
    199         $class = '';
    200 
    201         if ( !in_array($status, $avail_post_stati) || $num_posts->$status <= 0 )
    202                 continue;
    203 
    204         if ( isset( $_GET['post_status'] ) && $status == $_GET['post_status'] )
    205                 $class = ' class="current"';
    206 
    207         $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>';
    208 }
    209 echo implode( " |</li>\n", $status_links ) . '</li>';
    210 unset($status_links);
    211 endif;
    212 ?>
    213 </ul>
    214 
    215 <p class="search-box">
    216         <label class="screen-reader-text" for="page-search-input"><?php _e( 'Search Pages' ); ?>:</label>
    217         <input type="text" id="page-search-input" name="s" value="<?php _admin_search_query(); ?>" />
    218         <input type="submit" value="<?php esc_attr_e( 'Search Pages' ); ?>" class="button" />
    219 </p>
    220 
    221 <input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
    222 
    223 <?php if ($posts) { ?>
    224 
    225 <div class="tablenav">
    226 
    227 <?php
    228 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
    229 if ( empty($pagenum) )
    230         $pagenum = 1;
    231 $per_page = (int) get_user_option( 'edit_pages_per_page' );
    232 if ( empty( $per_page ) || $per_page < 1 )
    233         $per_page = 20;
    234 $per_page = apply_filters( 'edit_pages_per_page', $per_page );
    235 
    236 $num_pages = ceil($wp_query->post_count / $per_page);
    237 $page_links = paginate_links( array(
    238         'base' => add_query_arg( 'pagenum', '%#%' ),
    239         'format' => '',
    240         'prev_text' => __('&laquo;'),
    241         'next_text' => __('&raquo;'),
    242         'total' => $num_pages,
    243         'current' => $pagenum
    244 ));
    245 
    246 $is_trash = isset($_GET['post_status']) && $_GET['post_status'] == 'trash';
    247 
    248 if ( $page_links ) : ?>
    249 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
    250         number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
    251         number_format_i18n( min( $pagenum * $per_page, $wp_query->post_count ) ),
    252         number_format_i18n( $wp_query->post_count ),
    253         $page_links
    254 ); echo $page_links_text; ?></div>
    255 <?php endif; ?>
    256 
    257 <div class="alignleft actions">
    258 <select name="action">
    259 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    260 <?php if ( $is_trash ) { ?>
    261 <option value="untrash"><?php _e('Restore'); ?></option>
    262 <?php } else { ?>
    263 <option value="edit"><?php _e('Edit'); ?></option>
    264 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
    265 <option value="delete"><?php _e('Delete Permanently'); ?></option>
    266 <?php } else { ?>
    267 <option value="trash"><?php _e('Move to Trash'); ?></option>
    268 <?php } ?>
    269 </select>
    270 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
    271 <?php wp_nonce_field('bulk-pages'); ?>
    272 <?php if ( $is_trash ) { ?>
    273 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    274 <?php } ?>
    275 </div>
    276 
    277 <br class="clear" />
    278 </div>
    279 
    280 <div class="clear"></div>
    281 
    282 <table class="widefat page fixed" cellspacing="0">
    283   <thead>
    284   <tr>
    285 <?php print_column_headers('edit-pages'); ?>
    286   </tr>
    287   </thead>
    288 
    289   <tfoot>
    290   <tr>
    291 <?php print_column_headers('edit-pages', false); ?>
    292   </tr>
    293   </tfoot>
    294 
    295   <tbody>
    296   <?php page_rows($posts, $pagenum, $per_page); ?>
    297   </tbody>
    298 </table>
    299 
    300 <div class="tablenav">
    301 <?php
    302 if ( $page_links )
    303         echo "<div class='tablenav-pages'>$page_links_text</div>";
    304 ?>
    305 
    306 <div class="alignleft actions">
    307 <select name="action2">
    308 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    309 <?php if ( $is_trash ) { ?>
    310 <option value="untrash"><?php _e('Restore'); ?></option>
    311 <?php } else { ?>
    312 <option value="edit"><?php _e('Edit'); ?></option>
    313 <?php } if ( $is_trash || !EMPTY_TRASH_DAYS ) { ?>
    314 <option value="delete"><?php _e('Delete Permanently'); ?></option>
    315 <?php } else { ?>
    316 <option value="trash"><?php _e('Move to Trash'); ?></option>
    317 <?php } ?>
    318 </select>
    319 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    320 <?php if ( $is_trash ) { ?>
    321 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    322 <?php } ?>
    323 </div>
    324 
    325 <br class="clear" />
    326 </div>
    327 
    328 <?php } else { ?>
    329 <div class="clear"></div>
    330 <p><?php _e('No pages found.') ?></p>
    331 <?php
    332 } // end if ($posts)
    333 ?>
    334 
    335 </form>
    336 
    337 <?php inline_edit_row( 'page' ) ?>
    338 
    339 <div id="ajax-response"></div>
    340 
    341 
    342 <?php
    343 
    344 if ( 1 == count($posts) && is_singular() ) :
    345 
    346         $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
    347         if ( $comments ) :
    348                 // Make sure comments, post, and post_author are cached
    349                 update_comment_cache($comments);
    350                 $post = get_post($id);
    351                 $authordata = get_userdata($post->post_author);
    352         ?>
    353 
    354 <br class="clear" />
    355 
    356 <table class="widefat" cellspacing="0">
    357 <thead>
    358   <tr>
    359     <th scope="col" class="column-comment">
    360                 <?php  /* translators: column name */ echo _x('Comment', 'column name') ?>
    361         </th>
    362     <th scope="col" class="column-author"><?php _e('Author') ?></th>
    363     <th scope="col" class="column-date"><?php _e('Submitted') ?></th>
    364   </tr>
    365 </thead>
    366 <tbody id="the-comment-list" class="list:comment">
    367 <?php
    368         foreach ($comments as $comment)
    369                 _wp_comment_row( $comment->comment_ID, 'single', false, false );
    370 ?>
    371 </tbody>
    372 </table>
    373 
    374 <?php
    375 wp_comment_reply();
    376 endif; // comments
    377 endif; // posts;
    378 
    379 ?>
    380 
    381 </div>
    382 
    383 <?php
    384 include('admin-footer.php');
  • wp-admin/themes.php

     
    6161        $help .= '<p>' . __('Once a theme is uploaded, you should see it on this page.') . '</p>' ;
    6262}
    6363
    64 add_contextual_help('themes', $help);
     64add_contextual_help($current_screen, $help);
    6565
    6666add_thickbox();
    6767wp_enqueue_script( 'theme-preview' );