Ticket #21742: 21742.5.diff
File 21742.5.diff, 38.1 KB (added by , 12 years ago) |
---|
-
class-wp-ms-sites-list-table.php
9 9 */ 10 10 class WP_MS_Sites_List_Table extends WP_List_Table { 11 11 12 function __construct( ) {12 function __construct( $args = array() ) { 13 13 parent::__construct( array( 14 14 'plural' => 'sites', 15 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 15 16 ) ); 16 17 } 17 18 -
class-wp-posts-list-table.php
45 45 */ 46 46 var $sticky_posts_count = 0; 47 47 48 function __construct( ) {48 function __construct( $args = array() ) { 49 49 global $post_type_object, $wpdb; 50 50 51 $post_type = get_current_screen()->post_type; 51 parent::construct( array( 52 'plural' => 'posts', 53 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 54 ) ); 55 56 $post_type = $this->screen->post_type; 52 57 $post_type_object = get_post_type_object( $post_type ); 53 58 54 59 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { … … 66 71 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); 67 72 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) ); 68 73 } 69 70 parent::__construct( array(71 'plural' => 'posts',72 ) );73 74 } 74 75 75 76 function ajax_user_can() { 76 global $post_type_object; 77 78 return current_user_can( $post_type_object->cap->edit_posts ); 77 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); 79 78 } 80 79 81 80 function prepare_items() { 82 global $ post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;81 global $avail_post_stati, $wp_query, $per_page, $mode; 83 82 84 83 $avail_post_stati = wp_edit_posts_query(); 85 84 86 $this->hierarchical_display = ( $post_type_object->hierarchical&& 'menu_order title' == $wp_query->query['orderby'] );85 $this->hierarchical_display = ( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] ); 87 86 88 87 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; 89 88 90 $post_type = $ post_type_object->name;89 $post_type = $this->screen->post_type; 91 90 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); 92 91 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); 93 92 … … 112 111 } 113 112 114 113 function no_items() { 115 global $post_type_object;116 117 114 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) 118 echo $post_type_object->labels->not_found_in_trash;115 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; 119 116 else 120 echo $post_type_object->labels->not_found;117 echo get_post_type_object( $this->screen->post_type )->labels->not_found; 121 118 } 122 119 123 120 function get_views() { 124 global $ post_type_object, $locked_post_status, $avail_post_stati;121 global $locked_post_status, $avail_post_stati; 125 122 126 $post_type = $ post_type_object->name;123 $post_type = $this->screen->post_type; 127 124 128 125 if ( !empty($locked_post_status) ) 129 126 return array(); … … 198 195 } 199 196 200 197 function extra_tablenav( $which ) { 201 global $ post_type_object, $cat;198 global $cat; 202 199 ?> 203 200 <div class="alignleft actions"> 204 201 <?php 205 202 if ( 'top' == $which && !is_singular() ) { 206 203 207 $this->months_dropdown( $ post_type_object->name );204 $this->months_dropdown( $this->screen->post_type ); 208 205 209 if ( is_object_in_taxonomy( $ post_type_object->name, 'category' ) ) {206 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { 210 207 $dropdown_options = array( 211 208 'show_option_all' => __( 'View all categories' ), 212 209 'hide_empty' => 0, … … 221 218 submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) ); 222 219 } 223 220 224 if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) {221 if ( $this->is_trash && current_user_can( get_post_type_object( $post_type )->cap->edit_others_posts ) ) { 225 222 submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false ); 226 223 } 227 224 ?> … … 237 234 } 238 235 239 236 function pagination( $which ) { 240 global $ post_type_object, $mode;237 global $mode; 241 238 242 239 parent::pagination( $which ); 243 240 244 if ( 'top' == $which && ! $post_type_object->hierarchical)241 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) 245 242 $this->view_switcher( $mode ); 246 243 } 247 244 248 245 function get_table_classes() { 249 global $post_type_object; 250 251 return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' ); 246 return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); 252 247 } 253 248 254 249 function get_columns() { 255 $ screen = get_current_screen();250 $post_type = $this->screen->post_type; 256 251 257 if ( empty( $screen ) )258 $post_type = 'post';259 else260 $post_type = $screen->post_type;261 262 252 $posts_columns = array(); 263 253 264 254 $posts_columns['cb'] = '<input type="checkbox" />'; … … 301 291 } 302 292 303 293 function display_rows( $posts = array(), $level = 0 ) { 304 global $wp_query, $p ost_type_object, $per_page;294 global $wp_query, $per_page; 305 295 306 296 if ( empty( $posts ) ) 307 297 $posts = $wp_query->posts; … … 529 519 } 530 520 else { 531 521 $attributes = 'class="post-title page-title column-title"' . $style; 532 522 533 523 $pad = str_repeat( '— ', $level ); 534 524 ?> 535 525 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong> … … 695 685 function inline_edit() { 696 686 global $mode; 697 687 698 $screen = get_current_screen(); 688 $post = get_default_post_to_edit( $this->screen->post_type ); 689 $post_type_object = get_post_type_object( $this->screen->post_type ); 699 690 700 $post = get_default_post_to_edit( $screen->post_type ); 701 $post_type_object = get_post_type_object( $screen->post_type ); 702 703 $taxonomy_names = get_object_taxonomies( $screen->post_type ); 691 $taxonomy_names = get_object_taxonomies( $this->screen->post_type ); 704 692 $hierarchical_taxonomies = array(); 705 693 $flat_taxonomies = array(); 706 694 foreach ( $taxonomy_names as $taxonomy_name ) { … … 727 715 $bulk = 0; 728 716 while ( $bulk < 2 ) { ?> 729 717 730 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$ screen->post_type ";731 echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$ screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";718 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$this->screen->post_type "; 719 echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$this->screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$this->screen->post_type"; 732 720 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> 733 721 734 722 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> 735 723 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> 736 724 <?php 737 725 738 if ( post_type_supports( $ screen->post_type, 'title' ) ) :726 if ( post_type_supports( $this->screen->post_type, 'title' ) ) : 739 727 if ( $bulk ) : ?> 740 728 <div id="bulk-title-div"> 741 729 <div id="bulk-titles"></div> … … 764 752 <br class="clear" /> 765 753 <?php endif; // $bulk 766 754 767 if ( post_type_supports( $ screen->post_type, 'author' ) ) :755 if ( post_type_supports( $this->screen->post_type, 'author' ) ) : 768 756 $authors_dropdown = ''; 769 757 770 758 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : … … 840 828 <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> 841 829 842 830 <?php 843 if ( post_type_supports( $ screen->post_type, 'author' ) && $bulk )831 if ( post_type_supports( $this->screen->post_type, 'author' ) && $bulk ) 844 832 echo $authors_dropdown; 845 833 846 if ( post_type_supports( $ screen->post_type, 'page-attributes' ) ) :834 if ( post_type_supports( $this->screen->post_type, 'page-attributes' ) ) : 847 835 848 836 if ( $post_type_object->hierarchical ) : 849 837 ?> … … 878 866 879 867 <?php endif; // !$bulk 880 868 881 if ( 'page' == $ screen->post_type ) :869 if ( 'page' == $this->screen->post_type ) : 882 870 ?> 883 871 884 872 <label> … … 911 899 912 900 <?php endif; // count( $flat_taxonomies ) && !$bulk ?> 913 901 914 <?php if ( post_type_supports( $ screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :902 <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) || post_type_supports( $this->screen->post_type, 'trackbacks' ) ) : 915 903 if ( $bulk ) : ?> 916 904 917 905 <div class="inline-edit-group"> 918 <?php if ( post_type_supports( $ screen->post_type, 'comments' ) ) : ?>906 <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) ) : ?> 919 907 <label class="alignleft"> 920 908 <span class="title"><?php _e( 'Comments' ); ?></span> 921 909 <select name="comment_status"> … … 924 912 <option value="closed"><?php _e( 'Do not allow' ); ?></option> 925 913 </select> 926 914 </label> 927 <?php endif; if ( post_type_supports( $ screen->post_type, 'trackbacks' ) ) : ?>915 <?php endif; if ( post_type_supports( $this->screen->post_type, 'trackbacks' ) ) : ?> 928 916 <label class="alignright"> 929 917 <span class="title"><?php _e( 'Pings' ); ?></span> 930 918 <select name="ping_status"> … … 939 927 <?php else : // $bulk ?> 940 928 941 929 <div class="inline-edit-group"> 942 <?php if ( post_type_supports( $ screen->post_type, 'comments' ) ) : ?>930 <?php if ( post_type_supports( $this->screen->post_type, 'comments' ) ) : ?> 943 931 <label class="alignleft"> 944 932 <input type="checkbox" name="comment_status" value="open" /> 945 933 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> 946 934 </label> 947 <?php endif; if ( post_type_supports( $ screen->post_type, 'trackbacks' ) ) : ?>935 <?php endif; if ( post_type_supports( $this->screen->post_type, 'trackbacks' ) ) : ?> 948 936 <label class="alignleft"> 949 937 <input type="checkbox" name="ping_status" value="open" /> 950 938 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> … … 974 962 </select> 975 963 </label> 976 964 977 <?php if ( 'post' == $ screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>965 <?php if ( 'post' == $this->screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> 978 966 979 967 <?php if ( $bulk ) : ?> 980 968 … … 1000 988 1001 989 </div> 1002 990 1003 <?php if ( post_type_supports( $ screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :991 <?php if ( post_type_supports( $this->screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) : 1004 992 $post_formats = get_theme_support( 'post-formats' ); 1005 993 if ( isset( $post_formats[0] ) && is_array( $post_formats[0] ) ) : 1006 994 $all_post_formats = get_post_format_strings(); … … 1033 1021 foreach ( $columns as $column_name => $column_display_name ) { 1034 1022 if ( isset( $core_columns[$column_name] ) ) 1035 1023 continue; 1036 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $ screen->post_type );1024 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $this->screen->post_type ); 1037 1025 } 1038 1026 ?> 1039 1027 <p class="submit inline-edit-save"> … … 1048 1036 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) ); 1049 1037 } ?> 1050 1038 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> 1051 <input type="hidden" name="screen" value="<?php echo esc_attr( $ screen->id ); ?>" />1039 <input type="hidden" name="screen" value="<?php echo esc_attr( $this->screen->id ); ?>" /> 1052 1040 <span class="error" style="display:none"></span> 1053 1041 <br class="clear" /> 1054 1042 </p> -
list-table.php
14 14 * @since 3.1.0 15 15 * 16 16 * @param string $class The type of the list table, which is the class name. 17 * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. 17 18 * @return object|bool Object on success, false if the class does not exist. 18 19 */ 19 function _get_list_table( $class ) {20 function _get_list_table( $class, $args = array() ) { 20 21 $core_classes = array( 21 22 //Site Admin 22 23 'WP_Posts_List_Table' => 'posts', … … 39 40 if ( isset( $core_classes[ $class ] ) ) { 40 41 foreach ( (array) $core_classes[ $class ] as $required ) 41 42 require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' ); 42 return new $class; 43 44 if ( isset( $args['screen'] ) ) 45 $args['screen'] = convert_to_screen( $args['screen'] ); 46 else 47 $args['screen'] = get_current_screen(); 48 49 return new $class( $args ); 43 50 } 44 51 45 52 return false; -
class-wp-media-list-table.php
9 9 */ 10 10 class WP_Media_List_Table extends WP_List_Table { 11 11 12 function __construct( ) {12 function __construct( $args = array() ) { 13 13 $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] ); 14 14 15 15 parent::__construct( array( 16 'plural' => 'media' 16 'plural' => 'media', 17 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 17 18 ) ); 18 19 } 19 20 -
class-wp-links-list-table.php
9 9 */ 10 10 class WP_Links_List_Table extends WP_List_Table { 11 11 12 function __construct( ) {12 function __construct( $args = array() ) { 13 13 parent::__construct( array( 14 14 'plural' => 'bookmarks', 15 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 15 16 ) ); 16 17 } 17 18 -
class-wp-terms-list-table.php
11 11 12 12 var $callback_args; 13 13 14 function __construct( ) {15 global $post_type, $taxonomy, $ tax;14 function __construct( $args = array() ) { 15 global $post_type, $taxonomy, $action, $tax; 16 16 17 wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) ); 17 parent::__construct( array( 18 'plural' => 'tags', 19 'singular' => 'tag', 20 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 21 ) ); 18 22 23 $action = $this->screen->action; 24 $post_type = $this->screen->post_type; 25 $taxonomy = $this->screen->taxonomy; 26 27 // @todo Still needed? Not sure if WP_Screen allows 'taxonomy' to be empty. 19 28 if ( empty( $taxonomy ) ) 20 29 $taxonomy = 'post_tag'; 21 30 22 if ( !taxonomy_exists( $taxonomy ) ) 31 // @todo Still needed? Not sure if WP_Screen allows for 'taxonomy' to be invalid. 32 if ( ! taxonomy_exists( $taxonomy ) ) 23 33 wp_die( __( 'Invalid taxonomy' ) ); 24 34 25 35 $tax = get_taxonomy( $taxonomy ); 26 36 37 // @todo Still needed? Maybe just the show_ui part. 27 38 if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) 28 39 $post_type = 'post'; 29 40 30 parent::__construct( array(31 'plural' => 'tags',32 'singular' => 'tag',33 ) );34 41 } 35 42 36 43 function ajax_user_can() { 37 global $tax; 38 39 return current_user_can( $tax->cap->manage_terms ); 44 return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); 40 45 } 41 46 42 47 function prepare_items() { 43 global $taxonomy;48 $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); 44 49 45 $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' ); 46 47 if ( 'post_tag' == $taxonomy ) { 50 if ( 'post_tag' == $this->screen->taxonomy ) { 48 51 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 49 52 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 50 } elseif ( 'category' == $t axonomy ) {53 } elseif ( 'category' == $this->screen->taxonomy ) { 51 54 $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter 52 55 } 53 56 … … 68 71 $this->callback_args = $args; 69 72 70 73 $this->set_pagination_args( array( 71 'total_items' => wp_count_terms( $t axonomy, compact( 'search' ) ),74 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), 72 75 'per_page' => $tags_per_page, 73 76 ) ); 74 77 } … … 93 96 } 94 97 95 98 function get_columns() { 96 global $taxonomy, $post_type;97 98 99 $columns = array( 99 100 'cb' => '<input type="checkbox" />', 100 101 'name' => _x( 'Name', 'term name' ), … … 102 103 'slug' => __( 'Slug' ), 103 104 ); 104 105 105 if ( 'link_category' == $t axonomy ) {106 if ( 'link_category' == $this->screen->taxonomy ) { 106 107 $columns['links'] = __( 'Links' ); 107 108 } else { 108 $post_type_object = get_post_type_object( $ post_type );109 $post_type_object = get_post_type_object( $this->screen->post_type ); 109 110 $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' ); 110 111 } 111 112 … … 123 124 } 124 125 125 126 function display_rows_or_placeholder() { 126 global $taxonomy;127 $taxonomy = $this->screen->taxonomy; 127 128 128 129 $args = wp_parse_args( $this->callback_args, array( 129 130 'page' => 1, … … 231 232 } 232 233 233 234 function column_cb( $tag ) { 234 global $taxonomy, $tax;235 $default_term = get_option( 'default_' . $this->screen->taxonomy ); 235 236 236 $default_term = get_option( 'default_' . $taxonomy ); 237 238 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) 237 if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) 239 238 return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' 240 239 . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; 241 240 … … 243 242 } 244 243 245 244 function column_name( $tag ) { 246 global $taxonomy, $tax, $post_type; 245 $taxonomy = $this->screen->taxonomy; 246 $tax = get_taxonomy( $taxonomy ); 247 247 248 248 $default_term = get_option( 'default_' . $taxonomy ); 249 249 250 250 $pad = str_repeat( '— ', max( 0, $this->level ) ); 251 251 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); 252 252 $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); 253 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $ post_type ) );253 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); 254 254 255 255 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $name ) ) . '">' . $name . '</a></strong><br />'; 256 256 … … 284 284 } 285 285 286 286 function column_posts( $tag ) { 287 global $taxonomy, $post_type;288 289 287 $count = number_format_i18n( $tag->count ); 290 288 291 $tax = get_taxonomy( $t axonomy );289 $tax = get_taxonomy( $this->screen->taxonomy ); 292 290 293 $ptype_object = get_post_type_object( $ post_type );291 $ptype_object = get_post_type_object( $this->screen->post_type ); 294 292 if ( ! $ptype_object->show_ui ) 295 293 return $count; 296 294 … … 300 298 $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); 301 299 } 302 300 303 if ( 'post' != $ post_type )304 $args['post_type'] = $ post_type;301 if ( 'post' != $this->screen->post_type ) 302 $args['post_type'] = $this->screen->post_type; 305 303 306 304 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; 307 305 } … … 314 312 } 315 313 316 314 function column_default( $tag, $column_name ) { 317 $screen = get_current_screen(); 318 319 return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); 315 return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); 320 316 } 321 317 322 318 /** … … 325 321 * @since 3.1.0 326 322 */ 327 323 function inline_edit() { 328 global $post_type, $tax;324 $tax = get_taxonomy( $this->screen->taxonomy ); 329 325 330 326 if ( ! current_user_can( $tax->cap->edit_terms ) ) 331 327 return; … … 358 354 if ( isset( $core_columns[$column_name] ) ) 359 355 continue; 360 356 361 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $t ax->name);357 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); 362 358 } 363 359 364 360 ?> … … 370 366 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 371 367 <span class="error" style="display:none;"></span> 372 368 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> 373 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $t ax->name); ?>" />374 <input type="hidden" name="post_type" value="<?php echo esc_attr( $ post_type ); ?>" />369 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> 370 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> 375 371 <br class="clear" /> 376 372 </p> 377 373 </td></tr> -
ajax-actions.php
29 29 * GET-based Ajax handlers. 30 30 */ 31 31 function wp_ajax_fetch_list() { 32 global $ current_screen, $wp_list_table;32 global $wp_list_table; 33 33 34 34 $list_class = $_GET['list_args']['class']; 35 35 check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' ); 36 36 37 $current_screen = convert_to_screen( $_GET['list_args']['screen']['id'] ); 38 39 define( 'WP_NETWORK_ADMIN', $current_screen->is_network ); 40 define( 'WP_USER_ADMIN', $current_screen->is_user ); 41 42 $wp_list_table = _get_list_table( $list_class ); 37 $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) ); 43 38 if ( ! $wp_list_table ) 44 39 wp_die( 0 ); 45 40 … … 615 610 $x->send(); 616 611 } 617 612 618 set_current_screen( $_POST['screen']);613 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) ); 619 614 620 $wp_list_table = _get_list_table('WP_Terms_List_Table');621 622 615 $level = 0; 623 616 if ( is_taxonomy_hierarchical($taxonomy) ) { 624 617 $level = count( get_ancestors( $tag->term_id, $taxonomy ) ); … … 686 679 687 680 check_ajax_referer( $action ); 688 681 689 set_current_screen( 'edit-comments');682 $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); 690 683 691 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');692 693 684 if ( !current_user_can( 'edit_post', $post_id ) ) 694 685 wp_die( -1 ); 695 686 … … 723 714 724 715 check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); 725 716 726 set_current_screen( 'edit-comments' );727 728 717 $comment_post_ID = (int) $_POST['comment_post_ID']; 729 718 if ( !current_user_can( 'edit_post', $comment_post_ID ) ) 730 719 wp_die( -1 ); … … 782 771 _wp_dashboard_recent_comments_row( $comment ); 783 772 } else { 784 773 if ( 'single' == $_REQUEST['mode'] ) { 785 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table' );774 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); 786 775 } else { 787 $wp_list_table = _get_list_table('WP_Comments_List_Table' );776 $wp_list_table = _get_list_table('WP_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); 788 777 } 789 778 $wp_list_table->single_row( $comment ); 790 779 } … … 811 800 812 801 check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ); 813 802 814 set_current_screen( 'edit-comments' );815 816 803 $comment_id = (int) $_POST['comment_ID']; 817 804 if ( ! current_user_can( 'edit_comment', $comment_id ) ) 818 805 wp_die( -1 ); … … 827 814 $comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : ''; 828 815 829 816 $checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0; 830 $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' );817 $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); 831 818 832 819 $comment = get_comment( $comment_id ); 833 820 … … 1328 1315 wp_die( __( 'You are not allowed to edit this post.' ) ); 1329 1316 } 1330 1317 1331 set_current_screen( $_POST['screen'] );1332 1333 1318 if ( $last = wp_check_post_lock( $post_ID ) ) { 1334 1319 $last_user = get_userdata( $last ); 1335 1320 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); … … 1365 1350 // update the post 1366 1351 edit_post(); 1367 1352 1368 $wp_list_table = _get_list_table( 'WP_Posts_List_Table');1353 $wp_list_table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $_POST['screen'] ) ); 1369 1354 1370 1355 $mode = $_POST['post_view']; 1371 1356 … … 1397 1382 if ( ! current_user_can( $tax->cap->edit_terms ) ) 1398 1383 wp_die( -1 ); 1399 1384 1400 set_current_screen( 'edit-' . $taxonomy);1385 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); 1401 1386 1402 $wp_list_table = _get_list_table('WP_Terms_List_Table');1403 1404 1387 if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) 1405 1388 wp_die( -1 ); 1406 1389 -
class-wp-users-list-table.php
12 12 var $site_id; 13 13 var $is_site_users; 14 14 15 function __construct() { 16 $screen = get_current_screen(); 17 $this->is_site_users = 'site-users-network' == $screen->id; 15 function __construct( $args = array() ) { 16 parent::__construct( array( 17 'singular' => 'user', 18 'plural' => 'users', 19 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 20 ) ); 18 21 22 $this->is_site_users = 'site-users-network' == $this->screen->id; 23 19 24 if ( $this->is_site_users ) 20 25 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 21 22 parent::__construct( array(23 'singular' => 'user',24 'plural' => 'users'25 ) );26 26 } 27 27 28 28 function ajax_user_can() { -
class-wp-list-table.php
81 81 $args = wp_parse_args( $args, array( 82 82 'plural' => '', 83 83 'singular' => '', 84 'ajax' => false 84 'ajax' => false, 85 'screen' => null, 85 86 ) ); 86 87 87 $ screen = get_current_screen();88 $this->screen = convert_to_screen( $args['screen'] ); 88 89 89 add_filter( "manage_{$ screen->id}_columns", array( &$this, 'get_columns' ), 0 );90 add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 ); 90 91 91 92 if ( !$args['plural'] ) 92 $args['plural'] = $ screen->base;93 $args['plural'] = $this->screen->base; 93 94 94 95 $args['plural'] = sanitize_key( $args['plural'] ); 95 96 $args['singular'] = sanitize_key( $args['singular'] ); … … 238 239 * @access public 239 240 */ 240 241 function views() { 241 $screen = get_current_screen();242 243 242 $views = $this->get_views(); 244 $views = apply_filters( 'views_' . $ screen->id, $views );243 $views = apply_filters( 'views_' . $this->screen->id, $views ); 245 244 246 245 if ( empty( $views ) ) 247 246 return; … … 274 273 * @access public 275 274 */ 276 275 function bulk_actions() { 277 $screen = get_current_screen();278 279 276 if ( is_null( $this->_actions ) ) { 280 277 $no_new_actions = $this->_actions = $this->get_bulk_actions(); 281 278 // This filter can currently only be used to remove actions. 282 $this->_actions = apply_filters( 'bulk_actions-' . $ screen->id, $this->_actions );279 $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions ); 283 280 $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); 284 281 $two = ''; 285 282 } else { … … 600 597 if ( isset( $this->_column_headers ) ) 601 598 return $this->_column_headers; 602 599 603 $screen = get_current_screen(); 600 $columns = get_column_headers( $this->screen ); 601 $hidden = get_hidden_columns( $this->screen ); 604 602 605 $columns = get_column_headers( $screen ); 606 $hidden = get_hidden_columns( $screen ); 603 $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() ); 607 604 608 $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );609 610 605 $sortable = array(); 611 606 foreach ( $_sortable as $id => $data ) { 612 607 if ( empty( $data ) ) … … 647 642 * @param bool $with_id Whether to set the id attribute or not 648 643 */ 649 644 function print_column_headers( $with_id = true ) { 650 $screen = get_current_screen();651 652 645 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 653 646 654 647 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); … … 910 903 * @access private 911 904 */ 912 905 function _js_vars() { 913 $current_screen = get_current_screen();914 915 906 $args = array( 916 907 'class' => get_class( $this ), 917 908 'screen' => array( 918 'id' => $ current_screen->id,919 'base' => $ current_screen->base,909 'id' => $this->screen->id, 910 'base' => $this->screen->base, 920 911 ) 921 912 ); 922 913 -
class-wp-ms-themes-list-table.php
12 12 var $site_id; 13 13 var $is_site_themes; 14 14 15 function __construct( ) {15 function __construct( $args = array() ) { 16 16 global $status, $page; 17 17 18 parent::__construct( array( 19 'plural' => 'themes', 20 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 21 ) ); 22 18 23 $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; 19 24 if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) 20 25 $status = 'all'; 21 26 22 27 $page = $this->get_pagenum(); 23 28 24 $screen = get_current_screen(); 25 $this->is_site_themes = ( 'site-themes-network' == $screen->id ) ? true : false; 29 $this->is_site_themes = ( 'site-themes-network' == $this->screen->id ) ? true : false; 26 30 27 31 if ( $this->is_site_themes ) 28 32 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 29 30 parent::__construct( array(31 'plural' => 'themes'32 ) );33 33 } 34 34 35 35 function get_table_classes() { -
class-wp-plugins-list-table.php
9 9 */ 10 10 class WP_Plugins_List_Table extends WP_List_Table { 11 11 12 function __construct( ) {12 function __construct( $args = array() ) { 13 13 global $status, $page; 14 14 15 parent::__construct( array( 16 'plural' => 'plugins', 17 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 18 ) ); 19 15 20 $status = 'all'; 16 21 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) 17 22 $status = $_REQUEST['plugin_status']; … … 20 25 $_SERVER['REQUEST_URI'] = add_query_arg('s', stripslashes($_REQUEST['s']) ); 21 26 22 27 $page = $this->get_pagenum(); 23 24 parent::__construct( array(25 'plural' => 'plugins',26 ) );27 28 } 28 29 29 30 function get_table_classes() { … … 50 51 'dropins' => array() 51 52 ); 52 53 53 $screen = get_current_screen(); 54 55 if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) { 54 if ( ! is_multisite() || ( $this->screen->is_network && current_user_can('manage_network_plugins') ) ) { 56 55 if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) 57 56 $plugins['mustuse'] = get_mu_plugins(); 58 57 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) … … 71 70 72 71 set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 ); 73 72 74 if ( ! $ screen->is_network ) {73 if ( ! $this->screen->is_network ) { 75 74 $recently_activated = get_option( 'recently_activated', array() ); 76 75 77 76 $one_week = 7*24*60*60; … … 83 82 84 83 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { 85 84 // Filter into individual sections 86 if ( ! $ screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {85 if ( ! $this->screen->is_network && is_plugin_active_for_network( $plugin_file ) ) { 87 86 unset( $plugins['all'][ $plugin_file ] ); 88 } elseif ( ( ! $ screen->is_network && is_plugin_active( $plugin_file ) )89 || ( $ screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {87 } elseif ( ( ! $this->screen->is_network && is_plugin_active( $plugin_file ) ) 88 || ( $this->screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) { 90 89 $plugins['active'][ $plugin_file ] = $plugin_data; 91 90 } else { 92 if ( !$ screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?91 if ( !$this->screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated? 93 92 $plugins['recently_activated'][ $plugin_file ] = $plugin_data; 94 93 $plugins['inactive'][ $plugin_file ] = $plugin_data; 95 94 } … … 122 121 uasort( $this->items, array( &$this, '_order_callback' ) ); 123 122 } 124 123 125 $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $ screen->id . '_per_page' ), 999 );124 $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $this->screen->id . '_per_page' ), 999 ); 126 125 127 126 $start = ( $page - 1 ) * $plugins_per_page; 128 127 … … 234 233 235 234 $actions = array(); 236 235 237 $screen = get_current_screen();238 239 236 if ( 'active' != $status ) 240 $actions['activate-selected'] = $ screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );237 $actions['activate-selected'] = $this->screen->is_network ? __( 'Network Activate' ) : __( 'Activate' ); 241 238 242 239 if ( 'inactive' != $status && 'recent' != $status ) 243 $actions['deactivate-selected'] = $ screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );240 $actions['deactivate-selected'] = $this->screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' ); 244 241 245 if ( !is_multisite() || $ screen->is_network ) {242 if ( !is_multisite() || $this->screen->is_network ) { 246 243 if ( current_user_can( 'update_plugins' ) ) 247 244 $actions['update-selected'] = __( 'Update' ); 248 245 if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) … … 269 266 270 267 echo '<div class="alignleft actions">'; 271 268 272 $screen = get_current_screen(); 273 274 if ( ! $screen->is_network && 'recently_activated' == $status ) 269 if ( ! $this->screen->is_network && 'recently_activated' == $status ) 275 270 submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false ); 276 271 elseif ( 'top' == $which && 'mustuse' == $status ) 277 272 echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>'; … … 291 286 function display_rows() { 292 287 global $status; 293 288 294 $screen = get_current_screen(); 295 296 if ( is_multisite() && !$screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) ) 289 if ( is_multisite() && ! $this->screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) ) 297 290 return; 298 291 299 292 foreach ( $this->items as $plugin_file => $plugin_data ) … … 305 298 306 299 $context = $status; 307 300 308 $screen = get_current_screen();309 310 301 // preorder 311 302 $actions = array( 312 303 'deactivate' => '', … … 335 326 if ( $plugin_data['Description'] ) 336 327 $description .= '<p>' . $plugin_data['Description'] . '</p>'; 337 328 } else { 338 if ( $ screen->is_network )329 if ( $this->screen->is_network ) 339 330 $is_active = is_plugin_active_for_network( $plugin_file ); 340 331 else 341 332 $is_active = is_plugin_active( $plugin_file ); 342 333 343 if ( $ screen->is_network ) {334 if ( $this->screen->is_network ) { 344 335 if ( $is_active ) { 345 336 if ( current_user_can( 'manage_network_plugins' ) ) 346 337 $actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>'; … … 359 350 if ( ! is_multisite() && current_user_can('delete_plugins') ) 360 351 $actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>'; 361 352 } // end if $is_active 362 } // end if $ screen->is_network353 } // end if $this->screen->is_network 363 354 364 if ( ( ! is_multisite() || $ screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )355 if ( ( ! is_multisite() || $this->screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) ) 365 356 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>'; 366 357 } // end if $context 367 358 368 $prefix = $ screen->is_network ? 'network_admin_' : '';359 $prefix = $this->screen->is_network ? 'network_admin_' : ''; 369 360 $actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context ); 370 361 $actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context ); 371 362 -
class-wp-themes-list-table.php
12 12 protected $search_terms = array(); 13 13 var $features = array(); 14 14 15 function __construct( ) {15 function __construct( $args = array() ) { 16 16 parent::__construct( array( 17 17 'ajax' => true, 18 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 18 19 ) ); 19 20 } 20 21