WordPress.org

Make WordPress Core

Changeset 15496


Ignore:
Timestamp:
08/12/2010 11:21:05 PM (9 years ago)
Author:
scribu
Message:

Introduce WP_List_Table::check_permissions() and WP_List_Table::prepare_items(). Fixes #14596; See #14579

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r15493 r15496  
    559559
    560560    require_once( './includes/default-list-tables.php' );
    561     $table = new WP_Terms_Table( 'ajax' );
     561    $table = new WP_Terms_Table();
    562562
    563563    $level = 0;
     
    627627
    628628    require_once( './includes/default-list-tables.php' );
    629     $table = new WP_Comments_Table( 'ajax' );
     629    $table = new WP_Comments_Table();
    630630
    631631    global $comments;
     
    660660
    661661    require_once( './includes/default-list-tables.php' );
    662     $table = new WP_Comments_Table( 'ajax' );
     662    $table = new WP_Comments_Table();
    663663
    664664    global $comments;
     
    686686
    687687    require_once( './includes/default-list-tables.php' );
    688     $table = new WP_Comments_Table( 'ajax' );
     688    $table = new WP_Comments_Table();
    689689
    690690    $comment_post_ID = (int) $_POST['comment_post_ID'];
     
    777777
    778778    require_once( './includes/default-list-tables.php' );
    779     $table = new WP_Comments_Table( 'ajax' );
     779    $table = new WP_Comments_Table();
    780780
    781781    ob_start();
     
    926926
    927927    require_once( './includes/default-list-tables.php' );
    928     $table = new WP_Users_Table( 'ajax' );
     928    $table = new WP_Users_Table();
    929929
    930930    $x = new WP_Ajax_Response( array(
     
    12191219
    12201220    require_once( './includes/default-list-tables.php' );
    1221     $table = new WP_Posts_Table( 'ajax' );
     1221    $table = new WP_Posts_Table();
    12221222
    12231223    $mode = $_POST['post_view'];
     
    12291229    check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
    12301230
    1231     $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : false;
    1232     if ( ! $taxonomy )
    1233         die( __('Cheatin’ uh?') );
    1234     $tax = get_taxonomy($taxonomy);
    1235 
    1236     if ( ! current_user_can( $tax->cap->edit_terms ) )
    1237         die( __('Cheatin’ uh?') );
     1231    require_once( './includes/default-list-tables.php' );
     1232    $table = new WP_Terms_Table();
     1233
     1234    $table->check_permissions('edit');
    12381235
    12391236    if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
    12401237        die(-1);
    1241 
    1242     $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
    12431238
    12441239    $tag = get_term( $id, $taxonomy );
     
    12531248            die( __('Item not updated.') );
    12541249        }
    1255 
    1256         set_current_screen( 'edit-' . $taxonomy );
    1257 
    1258         require_once( './includes/default-list-tables.php' );
    1259         $table = new WP_Terms_Table( 'ajax' );
    12601250
    12611251        echo $table->single_row( $tag, 0, $taxonomy );
  • trunk/wp-admin/edit-comments.php

    r15491 r15496  
    1010require_once('./admin.php');
    1111
    12 if ( !current_user_can('edit_posts') )
    13     wp_die(__('Cheatin’ uh?'));
     12require_once( './includes/default-list-tables.php' );
     13
     14$table = new WP_Comments_Table;
     15$table->check_permissions();
    1416
    1517if ( isset( $_REQUEST['doaction'] ) ||  isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
     
    9698}
    9799
    98 require_once( './includes/default-list-tables.php' );
    99 
    100 $table = new WP_Comments_Table;
     100$table->prepare_items();
    101101
    102102wp_enqueue_script('admin-comments');
  • trunk/wp-admin/edit-tags.php

    r15491 r15496  
    1313
    1414$table = new WP_Terms_Table;
     15$table->check_permissions();
    1516
    1617$title = $tax->labels->name;
     
    151152     exit;
    152153}
     154
     155$table->prepare_items();
    153156
    154157wp_enqueue_script('admin-tags');
  • trunk/wp-admin/edit.php

    r15491 r15496  
    1313
    1414$table = new WP_Posts_Table;
     15$table->check_permissions();
    1516
    1617// Back-compat for viewing comments of an entry
     
    118119    $post_new_file = 'post-new.php';
    119120}
     121
     122$table->prepare_items();
    120123
    121124wp_enqueue_script('inline-edit-post');
  • trunk/wp-admin/includes/default-list-tables.php

    r15491 r15496  
    2323    var $_hierarchical_display;
    2424
    25     function WP_Posts_Table( $context = 'normal' ) {
    26         global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode, $current_screen;
     25    function WP_Posts_Table() {
     26        global $post_type_object, $post_type, $current_screen;
    2727
    2828        if ( !isset( $_REQUEST['post_type'] ) )
     
    3636        $post_type_object = get_post_type_object( $post_type );
    3737
    38         if ( !current_user_can( $post_type_object->cap->edit_posts ) )
    39             wp_die( __( 'Cheatin’ uh?' ) );
    40 
    4138        parent::WP_List_Table( array(
    4239            'screen' => $current_screen,
    4340            'plural' => 'posts',
    4441        ) );
    45 
    46         if ( 'normal' != $context )
    47             return;
     42    }
     43
     44    function check_permissions() {
     45        global $post_type_object;
     46
     47        if ( !current_user_can( $post_type_object->cap->edit_posts ) )
     48            wp_die( __( 'Cheatin’ uh?' ) );
     49    }
     50
     51    function prepare_items() {
     52        global $post_type_object, $post_type, $avail_post_stati, $wp_query, $per_page, $mode;
    4853
    4954        $avail_post_stati = wp_edit_posts_query();
     
    10731078class WP_Media_Table extends WP_List_Table {
    10741079
    1075     function WP_Media_Table( $context = 'normal' ) {
    1076         global $wpdb, $wp_query, $detached, $post_mime_types, $avail_post_mime_types;
    1077 
    1078         if ( isset( $_REQUEST['find_detached'] ) ) {
    1079             if ( !current_user_can( 'edit_posts' ) )
    1080                 wp_die( __( 'You are not allowed to scan for lost attachments.' ) );
    1081 
    1082             $lost = $wpdb->get_col( "
    1083                 SELECT ID FROM $wpdb->posts
    1084                 WHERE post_type = 'attachment' AND post_parent > '0'
    1085                 AND post_parent NOT IN (
    1086                     SELECT ID FROM $wpdb->posts
    1087                     WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )
    1088                 )
    1089             " );
    1090 
    1091             $_REQUEST['detached'] = 1;
    1092         }
    1093 
    1094         $detached = isset( $_REQUEST['detached'] );
     1080    function WP_Media_Table() {
     1081        global $detached;
     1082
     1083        $detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
    10951084
    10961085        parent::WP_List_Table( array(
     
    10981087            'plural' => 'media'
    10991088        ) );
    1100 
    1101         if ( 'normal' != $context )
    1102             return;
     1089    }
     1090
     1091    function check_permissions() {
     1092        if ( !current_user_can('upload_files') )
     1093            wp_die( __( 'You do not have permission to upload files.' ) );
     1094    }       
     1095
     1096    function prepare_items() {
     1097        global $lost, $wpdb, $wp_query, $post_mime_types, $avail_post_mime_types;
    11031098
    11041099        $q = $_REQUEST;
     
    13581353        } else {
    13591354?>
    1360             <td <?php echo $attributes ?>><?php _e( '( Unattached )' ); ?><br />
     1355            <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
    13611356            <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td>
    13621357<?php
     
    15031498    var $callback_args;
    15041499
    1505     function WP_Terms_Table( $context = 'normal' ) {
     1500    function WP_Terms_Table() {
    15061501        global $post_type, $taxonomy, $tax, $current_screen;
     1502
     1503        wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
     1504
     1505        if ( empty( $taxonomy ) )
     1506            $taxonomy = 'post_tag';
     1507
     1508        if ( !taxonomy_exists( $taxonomy ) )
     1509            wp_die( __( 'Invalid taxonomy' ) );
     1510
     1511        $tax = get_taxonomy( $taxonomy );
     1512
     1513        if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
     1514            $post_type = 'post';
     1515
     1516        if ( !isset( $current_screen ) )
     1517            set_current_screen( 'edit-' . $taxonomy );
    15071518
    15081519        parent::WP_List_Table( array(
     
    15111522            'singular' => 'tag',
    15121523        ) );
    1513 
    1514         if ( 'normal' != $context )
    1515             return;
    1516 
    1517         wp_reset_vars( array( 'action', 'tag', 'taxonomy', 'post_type' ) );
    1518 
    1519         if ( empty( $taxonomy ) )
    1520             $taxonomy = 'post_tag';
    1521 
    1522         if ( !taxonomy_exists( $taxonomy ) )
    1523             wp_die( __( 'Invalid taxonomy' ) );
    1524 
    1525         $tax = get_taxonomy( $taxonomy );
    1526 
    1527         if ( ! current_user_can( $tax->cap->manage_terms ) )
     1524    }
     1525
     1526    function check_permissions( $type = 'manage' ) {
     1527        global $tax;
     1528
     1529        $cap = 'manage' == $type ? $tax->cap->manage_terms : $tax->cap->edit_terms;
     1530
     1531        if ( !current_user_can( $tax->cap->manage_terms ) )
    15281532            wp_die( __( 'Cheatin&#8217; uh?' ) );
    1529 
    1530         if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'public' => true ) ) ) )
    1531             $post_type = 'post';
     1533    }
     1534
     1535    function prepare_items() {
     1536        global $taxonomy;
    15321537
    15331538        $tags_per_page = (int) get_user_option( 'edit_' .  $taxonomy . '_per_page' );
     
    18521857class WP_Users_Table extends WP_List_Table {
    18531858
    1854     function WP_Users_Table( $context = 'normal' ) {
     1859    function WP_Users_Table() {
    18551860        global $role, $usersearch;
    18561861
     
    18591864            'plural' => 'users'
    18601865        ) );
    1861 
    1862         if ( 'normal' != $context )
    1863             return;
    1864 
     1866    }
     1867
     1868    function check_permissions() {
     1869        if ( !current_user_can('list_users') )
     1870            wp_die(__('Cheatin&#8217; uh?'));
     1871    }
     1872
     1873    function prepare_items() {
    18651874        $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
    18661875
     
    20902099class WP_Comments_Table extends WP_List_Table {
    20912100
    2092     function WP_Comments_Table( $context = 'normal' ) {
    2093         global $comments, $extra_comments, $total_comments, $post_id, $comment_status, $mode;
    2094 
    2095         $mode = ( empty( $_REQUEST['mode'] ) ) ? 'detail' : $_REQUEST['mode'];
    2096 
     2101    function WP_Comments_Table() {
    20972102        parent::WP_List_Table( array(
    20982103            'screen' => 'edit-comments',
    20992104            'plural' => 'comments'
    21002105        ) );
    2101 
    2102         if ( 'normal' != $context )
    2103             return;
     2106    }
     2107
     2108    function check_permissions() {
     2109        if ( !current_user_can('edit_posts') )
     2110            wp_die(__('Cheatin&#8217; uh?'));
     2111    }
     2112
     2113    function prepare_items() {
     2114        global $comments, $extra_comments, $total_comments, $post_id, $comment_status, $mode;
    21042115
    21052116        $post_id = isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : 0;
     2117
     2118        $mode = ( empty( $_REQUEST['mode'] ) ) ? 'detail' : $_REQUEST['mode'];
    21062119
    21072120        $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
     
    25092522
    25102523    function WP_Links_Table() {
     2524        parent::WP_List_Table( array(
     2525            'screen' => 'link-manager',
     2526            'plural' => 'bookmarks',
     2527        ) );
     2528    }
     2529
     2530    function check_permissions() {
     2531        if ( ! current_user_can( 'manage_links' ) )
     2532            wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
     2533    }
     2534
     2535    function prepare_items() {
    25112536        global $cat_id, $s, $orderby, $order;
    25122537
     
    25252550
    25262551        $this->items = get_bookmarks( $args );
    2527 
    2528         parent::WP_List_Table( array(
    2529             'screen' => 'link-manager',
    2530             'plural' => 'bookmarks',
    2531         ) );
    2532     }
     2552    }       
    25332553
    25342554    function no_items() {
     
    26912711
    26922712    function WP_Sites_Table() {
     2713        parent::WP_List_Table( array(
     2714            'screen' => 'ms-sites',
     2715            'plural' => 'sites',
     2716        ) );
     2717    }
     2718
     2719    function check_permissions() {     
     2720        if ( ! current_user_can( 'manage_sites' ) )
     2721            wp_die( __( 'You do not have permission to access this page.' ) );
     2722    }
     2723
     2724    function prepare_items() {
    26932725        global $s, $mode, $wpdb;
    26942726
    26952727        $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
    2696 
    2697         parent::WP_List_Table( array(
    2698             'callback' => 'site_rows',
    2699             'screen' => 'ms-sites',
    2700         ) );
    27012728
    27022729        $pagenum = $this->get_pagenum();
     
    29793006
    29803007    function WP_MS_Users_Table() {
    2981         global $s, $mode, $wpdb;
    2982 
    2983         $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
    2984 
    29853008        parent::WP_List_Table( array(
    29863009            'screen' => 'ms-users',
    29873010        ) );
     3011    }
     3012
     3013    function check_permissions() {         
     3014        if ( !is_multisite() )
     3015            wp_die( __( 'Multisite support is not enabled.' ) );
     3016   
     3017        if ( ! current_user_can( 'manage_network_users' ) )
     3018            wp_die( __( 'You do not have permission to access this page.' ) );
     3019    }
     3020
     3021    function prepare_items() {
     3022        global $s, $mode, $wpdb;
     3023
     3024        $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
    29883025
    29893026        $pagenum = $this->get_pagenum();
     
    32023239
    32033240    function WP_Plugins_Table() {
    3204         global $status, $plugins, $totals, $page, $orderby, $order, $s;
    3205 
    32063241        parent::WP_List_Table( array(
    32073242            'screen' => 'plugins',
    32083243            'plural' => 'plugins',
    32093244        ) );
     3245    }
     3246
     3247    function check_permissions() {
     3248        if ( is_multisite() ) {
     3249            $menu_perms = get_site_option( 'menu_items', array() );
     3250
     3251            if ( empty( $menu_perms['plugins'] ) ) {
     3252                if ( !is_super_admin() )
     3253                    wp_die( __( 'Cheatin&#8217; uh?' ) );
     3254            }
     3255        }
     3256
     3257        if ( !current_user_can('activate_plugins') )
     3258            wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
     3259    }
     3260
     3261    function prepare_items() {
     3262        global $status, $plugins, $totals, $page, $orderby, $order, $s;
    32103263
    32113264        wp_reset_vars( array( 'orderby', 'order', 's' ) );
    3212 
    3213         $default_status = get_user_option( 'plugins_last_view' );
    3214         if ( empty( $default_status ) )
    3215             $default_status = 'all';
    3216         $status = isset( $_REQUEST['plugin_status'] ) ? $_REQUEST['plugin_status'] : $default_status;
    3217         if ( !in_array( $status, array( 'all', 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
    3218             $status = 'all';
    3219         if ( $status != $default_status && 'search' != $status )
    3220             update_user_meta( get_current_user_id(), 'plugins_last_view', $status );
    32213265
    32223266        $page = $this->get_pagenum();
     
    35393583
    35403584    function WP_Plugin_Install_Table() {
    3541         include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
    3542 
    3543         global $tabs, $tab, $paged, $type, $term;
    3544 
    35453585        parent::WP_List_Table( array(
    35463586            'screen' => 'plugin-install',
    35473587        ) );
     3588    }
     3589
     3590    function check_permissions() {
     3591        if ( ! current_user_can('install_plugins') )
     3592            wp_die(__('You do not have sufficient permissions to install plugins on this site.'));     
     3593    }
     3594
     3595    function prepare_items() {
     3596        include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
     3597
     3598        global $tabs, $tab, $paged, $type, $term;
    35483599
    35493600        wp_reset_vars( array( 'tab' ) );
     
    37443795
    37453796    function WP_Themes_Table() {
     3797        parent::__construct( array(
     3798            'screen' => 'themes',
     3799        ) );
     3800    }
     3801
     3802    function check_permissions() {
     3803        if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
     3804            wp_die( __( 'Cheatin&#8217; uh?' ) );
     3805    }
     3806   
     3807    function prepare_items() {
    37463808        global $ct;
    37473809
     
    37583820
    37593821        $this->items = array_slice( $themes, $start, $per_page );
    3760 
    3761         parent::__construct( array(
    3762             'screen' => 'themes',
    3763         ) );
    37643822
    37653823        $this->set_pagination_args( array(
     
    38863944
    38873945    function WP_Theme_Install_Table() {
    3888         include( ABSPATH . 'wp-admin/includes/theme-install.php' );
    3889 
    3890         global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
    3891 
    38923946        parent::WP_List_Table( array(
    38933947            'screen' => 'theme-install',
    38943948        ) );
    3895 
     3949    }
     3950
     3951    function check_permissions() {
     3952        if ( ! current_user_can('install_themes') )
     3953            wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
     3954    }
     3955
     3956    function prepare_items() {
     3957        include( ABSPATH . 'wp-admin/includes/theme-install.php' );
     3958
     3959        global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;       
     3960       
    38963961        wp_reset_vars( array( 'tab' ) );
    38973962
  • trunk/wp-admin/includes/list-table.php

    r15491 r15496  
    9292            add_action( 'admin_footer', array( $this, '_js_vars' ) );
    9393        }
     94    }
     95
     96    /**
     97     * Checks the current user's permissions
     98     * @uses wp_die()
     99     *
     100     * @since 3.1.0
     101     * @access public
     102     */
     103    function check_permissions() {
     104        die( 'function WP_List_Table::check_permissions() must be over-ridden in a sub-class.' );
     105    }
     106
     107    /**
     108     * Prepares the list of items for displaying.
     109     * @uses WP_List_Table::set_pagination_args()
     110     *
     111     * @since 3.1.0
     112     * @access public
     113     */
     114    function prepare_items() {
     115        die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
    94116    }
    95117
     
    569591     */
    570592    function ajax_response() {
     593        $this->check_permissions();
     594        $this->prepare_items();
     595
    571596        extract( $this->_args );
    572597        extract( $this->_pagination_args );
  • trunk/wp-admin/link-manager.php

    r15491 r15496  
    1010require_once ('admin.php');
    1111
     12require_once( './includes/default-list-tables.php' );
     13
     14$table = new WP_Links_Table;
     15$table->check_permissions();
     16
    1217// Handle bulk deletes
    1318if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
     
    1520
    1621    $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
    17 
    18     if ( ! current_user_can( 'manage_links' ) )
    19         wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
    2022
    2123    if ( 'delete' == $doaction ) {
     
    3436}
    3537
    36 require_once( './includes/default-list-tables.php' );
    37 
    38 $table = new WP_Links_Table;
     38$table->prepare_items();
    3939
    4040$title = __('Links');
  • trunk/wp-admin/network/sites.php

    r15494 r15496  
    1313    wp_die( __( 'Multisite support is not enabled.' ) );
    1414
    15 if ( ! current_user_can( 'manage_sites' ) )
    16     wp_die( __( 'You do not have permission to access this page.' ) );
     15require_once( '../includes/default-list-tables.php' );
     16
     17$table = new WP_Sites_Table;
     18$table->check_permissions();
    1719
    1820$title = __( 'Sites' );
     
    349351    case 'list':
    350352    default:
    351         require_once( '../includes/default-list-tables.php' );
    352 
    353         $table = new WP_Sites_Table;
     353        $table->prepare_items();
    354354
    355355        require_once( '../admin-header.php' );
  • trunk/wp-admin/network/users.php

    r15494 r15496  
    1010require_once( './admin.php' );
    1111
    12 if ( !is_multisite() )
    13     wp_die( __( 'Multisite support is not enabled.' ) );
     12require_once( '../includes/default-list-tables.php' );
    1413
    15 if ( ! current_user_can( 'manage_network_users' ) )
    16     wp_die( __( 'You do not have permission to access this page.' ) );
     14$table = new WP_MS_Users_Table;
     15$table->check_permissions();
     16$table->prepare_items();
    1717
    1818$title = __( 'Users' );
     
    3232    '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    3333);
    34 
    35 require_once( '../includes/default-list-tables.php' );
    36 
    37 $table = new WP_MS_Users_Table;
    3834
    3935require_once( '../admin-header.php' );
  • trunk/wp-admin/plugin-install.php

    r15491 r15496  
    1010require_once('./admin.php');
    1111
    12 if ( ! current_user_can('install_plugins') )
    13     wp_die(__('You do not have sufficient permissions to install plugins on this site.'));
    14 
    1512require_once( './includes/default-list-tables.php' );
    1613
    1714$table = new WP_Plugin_Install_Table;
     15$table->check_permissions();
     16$table->prepare_items();
    1817
    1918$title = __('Install Plugins');
  • trunk/wp-admin/plugins.php

    r15492 r15496  
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    11 if ( is_multisite() ) {
    12     $menu_perms = get_site_option( 'menu_items', array() );
    13        
    14     if ( empty( $menu_perms['plugins'] ) ) {
    15         if ( ! is_super_admin() )
    16             wp_die( __( 'Cheatin&#8217; uh?' ) );
    17     }
    18 }
    19 
    20 if ( ! current_user_can( 'activate_plugins' ) )
    21     wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
     11
     12require_once( ABSPATH . 'wp-admin/includes/default-list-tables.php' );
     13
     14$table = new WP_Plugins_Table;
     15$table->check_permissions();
    2216
    2317if ( isset($_POST['clear-recent-list']) )
     
    300294}
    301295
    302 require_once( ABSPATH . 'wp-admin/includes/default-list-tables.php' );
    303 
    304 $table = new WP_Plugins_Table;
     296$default_status = get_user_option( 'plugins_last_view' );
     297if ( empty( $default_status ) )
     298    $default_status = 'all';
     299$status = isset( $_REQUEST['plugin_status'] ) ? $_REQUEST['plugin_status'] : $default_status;
     300if ( !in_array( $status, array( 'all', 'active', 'inactive', 'recently_activated', 'upgrade', 'network', 'mustuse', 'dropins', 'search' ) ) )
     301    $status = 'all';
     302if ( $status != $default_status && 'search' != $status )
     303    update_user_meta( get_current_user_id(), 'plugins_last_view', $status );
     304
     305$table->prepare_items();
    305306
    306307wp_enqueue_script('plugin-install');
  • trunk/wp-admin/theme-install.php

    r15491 r15496  
    1010require_once('./admin.php');
    1111
    12 if ( ! current_user_can('install_themes') )
    13     wp_die(__('You do not have sufficient permissions to install themes on this site.'));
    14 
    1512require_once( './includes/default-list-tables.php' );
    1613
    1714$table = new WP_Theme_Install_Table;
     15$table->check_permissions();
     16$table->prepare_items();
    1817
    1918$title = __('Install Themes');
  • trunk/wp-admin/themes.php

    r15491 r15496  
    1010require_once('./admin.php');
    1111
    12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
    13     wp_die( __( 'Cheatin&#8217; uh?' ) );
     12require_once( './includes/default-list-tables.php' );
     13
     14$table = new WP_Themes_Table;
     15$table->check_permissions();
    1416
    1517if ( current_user_can('switch_themes') && isset($_GET['action']) ) {
     
    2931}
    3032
    31 require_once( './includes/default-list-tables.php' );
    32 
    33 $table = new WP_Themes_Table;
     33$table->prepare_items();
    3434
    3535$title = __('Manage Themes');
  • trunk/wp-admin/upload.php

    r15491 r15496  
    1010require_once( './admin.php' );
    1111
    12 if ( !current_user_can('upload_files') )
    13     wp_die(__('You do not have permission to upload files.'));
     12require_once( './includes/default-list-tables.php' );
     13
     14$table = new WP_Media_Table;
     15$table->check_permissions();
    1416
    1517// Handle bulk actions
    16 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
     18if ( isset($_REQUEST['find_detached']) ) {
     19    check_admin_referer('bulk-media');
     20
     21    if ( !current_user_can('edit_posts') )
     22        wp_die( __('You are not allowed to scan for lost attachments.') );
     23
     24    $lost = $wpdb->get_col( "
     25        SELECT ID FROM $wpdb->posts
     26        WHERE post_type = 'attachment' AND post_parent > '0'
     27        AND post_parent NOT IN (
     28            SELECT ID FROM $wpdb->posts
     29            WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )
     30        )
     31    " );
     32
     33    $_REQUEST['detached'] = 1;
     34
     35} elseif ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
    1736    check_admin_referer( 'bulk-media' );
    1837
     
    112131}
    113132
    114 require_once( './includes/default-list-tables.php' );
    115 
    116 $table = new WP_Media_Table;
     133$table->prepare_items();
    117134
    118135$title = __('Media Library');
  • trunk/wp-admin/users.php

    r15491 r15496  
    1313require_once( ABSPATH . WPINC . '/registration.php');
    1414
    15 if ( !current_user_can('list_users') )
    16     wp_die(__('Cheatin&#8217; uh?'));
     15require_once( './includes/default-list-tables.php' );
     16
     17$table = new WP_Users_Table;
     18$table->check_permissions();
    1719
    1820$title = __('Users');
     
    307309    }
    308310
    309     require_once( './includes/default-list-tables.php' );
    310 
    311     $table = new WP_Users_Table;
     311    $table->prepare_items();
    312312
    313313    include('./admin-header.php');
  • trunk/wp-includes/functions.php

    r15491 r15496  
    26572657 */
    26582658function wp_die( $message, $title = '', $args = array() ) {
     2659    if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
     2660        die('-1');
     2661
    26592662    if ( function_exists( 'apply_filters' ) ) {
    26602663        $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler');
    2661     }else {
     2664    } else {
    26622665        $function = '_default_wp_die_handler';
    26632666    }
Note: See TracChangeset for help on using the changeset viewer.