Changeset 15496 for trunk/wp-admin/includes/default-list-tables.php
- Timestamp:
- 08/12/2010 11:21:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/default-list-tables.php
r15491 r15496 23 23 var $_hierarchical_display; 24 24 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; 27 27 28 28 if ( !isset( $_REQUEST['post_type'] ) ) … … 36 36 $post_type_object = get_post_type_object( $post_type ); 37 37 38 if ( !current_user_can( $post_type_object->cap->edit_posts ) )39 wp_die( __( 'Cheatin’ uh?' ) );40 41 38 parent::WP_List_Table( array( 42 39 'screen' => $current_screen, 43 40 'plural' => 'posts', 44 41 ) ); 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; 48 53 49 54 $avail_post_stati = wp_edit_posts_query(); … … 1073 1078 class WP_Media_Table extends WP_List_Table { 1074 1079 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'] ); 1095 1084 1096 1085 parent::WP_List_Table( array( … … 1098 1087 'plural' => 'media' 1099 1088 ) ); 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; 1103 1098 1104 1099 $q = $_REQUEST; … … 1358 1353 } else { 1359 1354 ?> 1360 <td <?php echo $attributes ?>><?php _e( '( Unattached)' ); ?><br />1355 <td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br /> 1361 1356 <a class="hide-if-no-js" onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' );return false;" href="#the-list"><?php _e( 'Attach' ); ?></a></td> 1362 1357 <?php … … 1503 1498 var $callback_args; 1504 1499 1505 function WP_Terms_Table( $context = 'normal') {1500 function WP_Terms_Table() { 1506 1501 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 ); 1507 1518 1508 1519 parent::WP_List_Table( array( … … 1511 1522 'singular' => 'tag', 1512 1523 ) ); 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 ) ) 1528 1532 wp_die( __( 'Cheatin’ 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; 1532 1537 1533 1538 $tags_per_page = (int) get_user_option( 'edit_' . $taxonomy . '_per_page' ); … … 1852 1857 class WP_Users_Table extends WP_List_Table { 1853 1858 1854 function WP_Users_Table( $context = 'normal') {1859 function WP_Users_Table() { 1855 1860 global $role, $usersearch; 1856 1861 … … 1859 1864 'plural' => 'users' 1860 1865 ) ); 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’ uh?')); 1871 } 1872 1873 function prepare_items() { 1865 1874 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 1866 1875 … … 2090 2099 class WP_Comments_Table extends WP_List_Table { 2091 2100 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() { 2097 2102 parent::WP_List_Table( array( 2098 2103 'screen' => 'edit-comments', 2099 2104 'plural' => 'comments' 2100 2105 ) ); 2101 2102 if ( 'normal' != $context ) 2103 return; 2106 } 2107 2108 function check_permissions() { 2109 if ( !current_user_can('edit_posts') ) 2110 wp_die(__('Cheatin’ uh?')); 2111 } 2112 2113 function prepare_items() { 2114 global $comments, $extra_comments, $total_comments, $post_id, $comment_status, $mode; 2104 2115 2105 2116 $post_id = isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : 0; 2117 2118 $mode = ( empty( $_REQUEST['mode'] ) ) ? 'detail' : $_REQUEST['mode']; 2106 2119 2107 2120 $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; … … 2509 2522 2510 2523 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() { 2511 2536 global $cat_id, $s, $orderby, $order; 2512 2537 … … 2525 2550 2526 2551 $this->items = get_bookmarks( $args ); 2527 2528 parent::WP_List_Table( array( 2529 'screen' => 'link-manager', 2530 'plural' => 'bookmarks', 2531 ) ); 2532 } 2552 } 2533 2553 2534 2554 function no_items() { … … 2691 2711 2692 2712 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() { 2693 2725 global $s, $mode, $wpdb; 2694 2726 2695 2727 $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; 2696 2697 parent::WP_List_Table( array(2698 'callback' => 'site_rows',2699 'screen' => 'ms-sites',2700 ) );2701 2728 2702 2729 $pagenum = $this->get_pagenum(); … … 2979 3006 2980 3007 function WP_MS_Users_Table() { 2981 global $s, $mode, $wpdb;2982 2983 $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];2984 2985 3008 parent::WP_List_Table( array( 2986 3009 'screen' => 'ms-users', 2987 3010 ) ); 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']; 2988 3025 2989 3026 $pagenum = $this->get_pagenum(); … … 3202 3239 3203 3240 function WP_Plugins_Table() { 3204 global $status, $plugins, $totals, $page, $orderby, $order, $s;3205 3206 3241 parent::WP_List_Table( array( 3207 3242 'screen' => 'plugins', 3208 3243 'plural' => 'plugins', 3209 3244 ) ); 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’ 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; 3210 3263 3211 3264 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 );3221 3265 3222 3266 $page = $this->get_pagenum(); … … 3539 3583 3540 3584 function WP_Plugin_Install_Table() { 3541 include( ABSPATH . 'wp-admin/includes/plugin-install.php' );3542 3543 global $tabs, $tab, $paged, $type, $term;3544 3545 3585 parent::WP_List_Table( array( 3546 3586 'screen' => 'plugin-install', 3547 3587 ) ); 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; 3548 3599 3549 3600 wp_reset_vars( array( 'tab' ) ); … … 3744 3795 3745 3796 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’ uh?' ) ); 3805 } 3806 3807 function prepare_items() { 3746 3808 global $ct; 3747 3809 … … 3758 3820 3759 3821 $this->items = array_slice( $themes, $start, $per_page ); 3760 3761 parent::__construct( array(3762 'screen' => 'themes',3763 ) );3764 3822 3765 3823 $this->set_pagination_args( array( … … 3886 3944 3887 3945 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 3892 3946 parent::WP_List_Table( array( 3893 3947 'screen' => 'theme-install', 3894 3948 ) ); 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 3896 3961 wp_reset_vars( array( 'tab' ) ); 3897 3962
Note: See TracChangeset
for help on using the changeset viewer.