Make WordPress Core

Changeset 28493


Ignore:
Timestamp:
05/19/2014 01:16:16 AM (12 years ago)
Author:
wonderboymusic
Message:

Add access modifiers to methods and members of list table classes:

  • WP_List_Table is the base class that implements __get() and __call() for BC
  • Adds unit tests to confirm that subclasses properly inherit magic methods
  • Add modifiers to subclasses: WP_Links_List_Table, WP_Media_List_Table, WP_MS_Sites_List_Table, WP_MS_Themes_List_Table, WP_MS_Users_List_Table, WP_Plugin_Install_List_Table, WP_Plugins_List_Table, WP_Posts_List_Table, WP_Terms_List_Table, WP_Theme_Install_List_Table, WP_Themes_List_Table

See #27881, #22234.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r27029 r28493  
    1010class WP_Links_List_Table extends WP_List_Table {
    1111
    12         function __construct( $args = array() ) {
     12        public function __construct( $args = array() ) {
    1313                parent::__construct( array(
    1414                        'plural' => 'bookmarks',
    … …  
    1717        }
    1818
    19         function ajax_user_can() {
     19        public function ajax_user_can() {
    2020                return current_user_can( 'manage_links' );
    2121        }
    2222
    23         function prepare_items() {
     23        public function prepare_items() {
    2424                global $cat_id, $s, $orderby, $order;
    2525
    … …  
    4040        }
    4141
    42         function no_items() {
     42        public function no_items() {
    4343                _e( 'No links found.' );
    4444        }
    4545
    46         function get_bulk_actions() {
     46        protected function get_bulk_actions() {
    4747                $actions = array();
    4848                $actions['delete'] = __( 'Delete' );
    … …  
    5151        }
    5252
    53         function extra_tablenav( $which ) {
     53        protected function extra_tablenav( $which ) {
    5454                global $cat_id;
    5555
    … …  
    7676        }
    7777
    78         function get_columns() {
     78        protected function get_columns() {
    7979                return array(
    8080                        'cb'         => '<input type="checkbox" />',
    … …  
    8888        }
    8989
    90         function get_sortable_columns() {
     90        protected function get_sortable_columns() {
    9191                return array(
    9292                        'name'    => 'name',
    … …  
    9797        }
    9898
    99         function display_rows() {
     99        protected function display_rows() {
    100100                global $cat_id;
    101101
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r28389 r28493  
    1717         * @access protected
    1818         */
    19         var $items;
     19        protected $items;
    2020
    2121        /**
    … …  
    2626         * @access private
    2727         */
    28         var $_args;
     28        private $_args;
    2929
    3030        /**
    … …  
    3535         * @access private
    3636         */
    37         var $_pagination_args = array();
     37        private $_pagination_args = array();
    3838
    3939        /**
    … …  
    4444         * @access protected
    4545         */
    46         var $screen;
     46        protected $screen;
    4747
    4848        /**
    … …  
    5353         * @access private
    5454         */
    55         var $_actions;
     55        private $_actions;
    5656
    5757        /**
    … …  
    6262         * @access private
    6363         */
    64         var $_pagination;
     64        private $_pagination;
    6565
    6666        /**
    … …  
    7070         * @access protected
    7171         */
    72         function __construct( $args = array() ) {
     72        public function __construct( $args = array() ) {
    7373                $args = wp_parse_args( $args, array(
    7474                        'plural' => '',
    … …  
    9797
    9898        /**
     99         * Make private properties readable for backwards compatibility
     100         *
     101         * @since 4.0.0
     102         * @param string $name
     103         * @return mixed
     104         */
     105        public function __get( $name ) {
     106                return $this->$name;
     107        }
     108
     109        /**
     110         * Make private/protected methods readable for backwards compatibility
     111         *
     112         * @since 4.0.0
     113         * @param string $name
     114         * @param array $arguments
     115         * @return mixed
     116         */
     117        public function __call( $name, $arguments ) {
     118                return call_user_func_array( array( $this, $name ), $arguments );
     119        }
     120
     121        /**
    99122         * Checks the current user's permissions
    100123         * @uses wp_die()
    … …  
    104127         * @abstract
    105128         */
    106         function ajax_user_can() {
     129        public function ajax_user_can() {
    107130                die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
    108131        }
    … …  
    116139         * @abstract
    117140         */
    118         function prepare_items() {
     141        public function prepare_items() {
    119142                die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
    120143        }
    … …  
    126149         * @access protected
    127150         */
    128         function set_pagination_args( $args ) {
     151        protected function set_pagination_args( $args ) {
    129152                $args = wp_parse_args( $args, array(
    130153                        'total_items' => 0,
    … …  
    154177         * @return array
    155178         */
    156         function get_pagination_arg( $key ) {
     179        public function get_pagination_arg( $key ) {
    157180                if ( 'page' == $key )
    158181                        return $this->get_pagenum();
    … …  
    170193         * @return bool
    171194         */
    172         function has_items() {
     195        public function has_items() {
    173196                return !empty( $this->items );
    174197        }
    … …  
    180203         * @access public
    181204         */
    182         function no_items() {
     205        public function no_items() {
    183206                _e( 'No items found.' );
    184207        }
    … …  
    193216         * @param string $input_id The search input id
    194217         */
    195         function search_box( $text, $input_id ) {
     218        public function search_box( $text, $input_id ) {
    196219                if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
    197220                        return;
    … …  
    225248         * @return array
    226249         */
    227         function get_views() {
     250        protected function get_views() {
    228251                return array();
    229252        }
    … …  
    235258         * @access public
    236259         */
    237         function views() {
     260        public function views() {
    238261                $views = $this->get_views();
    239262                /**
    … …  
    269292         * @return array
    270293         */
    271         function get_bulk_actions() {
     294        protected function get_bulk_actions() {
    272295                return array();
    273296        }
    … …  
    279302         * @access public
    280303         */
    281         function bulk_actions() {
     304        public function bulk_actions() {
    282305                if ( is_null( $this->_actions ) ) {
    283306                        $no_new_actions = $this->_actions = $this->get_bulk_actions();
    … …  
    327350         * @return string|bool The action name or False if no action was selected
    328351         */
    329         function current_action() {
     352        public function current_action() {
    330353                if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
    331354                        return $_REQUEST['action'];
    … …  
    347370         * @return string
    348371         */
    349         function row_actions( $actions, $always_visible = false ) {
     372        protected function row_actions( $actions, $always_visible = false ) {
    350373                $action_count = count( $actions );
    351374                $i = 0;
    … …  
    371394         * @access protected
    372395         */
    373         function months_dropdown( $post_type ) {
     396        protected function months_dropdown( $post_type ) {
    374397                global $wpdb, $wp_locale;
    375398
    … …  
    426449         * @access protected
    427450         */
    428         function view_switcher( $current_mode ) {
     451        protected function view_switcher( $current_mode ) {
    429452                $modes = array(
    430453                        'list'    => __( 'List View' ),
    … …  
    454477         * @param int $pending_comments
    455478         */
    456         function comments_bubble( $post_id, $pending_comments ) {
     479        protected function comments_bubble( $post_id, $pending_comments ) {
    457480                $pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
    458481
    … …  
    474497         * @return int
    475498         */
    476         function get_pagenum() {
     499        protected function get_pagenum() {
    477500                $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
    478501
    … …  
    491514         * @return int
    492515         */
    493         function get_items_per_page( $option, $default = 20 ) {
     516        protected function get_items_per_page( $option, $default = 20 ) {
    494517                $per_page = (int) get_user_option( $option );
    495518                if ( empty( $per_page ) || $per_page < 1 )
    … …  
    517540         * @access protected
    518541         */
    519         function pagination( $which ) {
     542        protected function pagination( $which ) {
    520543                if ( empty( $this->_pagination_args ) ) {
    521544                        return;
    … …  
    612635         * @return array
    613636         */
    614         function get_columns() {
     637        protected function get_columns() {
    615638                die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
    616639        }
    … …  
    629652         * @return array
    630653         */
    631         function get_sortable_columns() {
     654        protected function get_sortable_columns() {
    632655                return array();
    633656        }
    … …  
    641664         * @return array
    642665         */
    643         function get_column_info() {
     666        protected function get_column_info() {
    644667                if ( isset( $this->_column_headers ) )
    645668                        return $this->_column_headers;
    … …  
    686709         * @return int
    687710         */
    688         function get_column_count() {
     711        public function get_column_count() {
    689712                list ( $columns, $hidden ) = $this->get_column_info();
    690713                $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
    … …  
    700723         * @param bool $with_id Whether to set the id attribute or not
    701724         */
    702         function print_column_headers( $with_id = true ) {
     725        protected function print_column_headers( $with_id = true ) {
    703726                list( $columns, $hidden, $sortable ) = $this->get_column_info();
    704727
    … …  
    768791         * @access public
    769792         */
    770         function display() {
     793        public function display() {
    771794                $singular = $this->_args['singular'];
    772795
    … …  
    806829         * @return array
    807830         */
    808         function get_table_classes() {
     831        protected function get_table_classes() {
    809832                return array( 'widefat', 'fixed', $this->_args['plural'] );
    810833        }
    … …  
    816839         * @access protected
    817840         */
    818         function display_tablenav( $which ) {
     841        protected function display_tablenav( $which ) {
    819842                if ( 'top' == $which )
    820843                        wp_nonce_field( 'bulk-' . $this->_args['plural'] );
    … …  
    841864         * @access protected
    842865         */
    843         function extra_tablenav( $which ) {}
     866        protected function extra_tablenav( $which ) {}
    844867
    845868        /**
    … …  
    849872         * @access protected
    850873         */
    851         function display_rows_or_placeholder() {
     874        protected function display_rows_or_placeholder() {
    852875                if ( $this->has_items() ) {
    853876                        $this->display_rows();
    … …  
    865888         * @access protected
    866889         */
    867         function display_rows() {
     890        protected function display_rows() {
    868891                foreach ( $this->items as $item )
    869892                        $this->single_row( $item );
    … …  
    878901         * @param object $item The current item
    879902         */
    880         function single_row( $item ) {
     903        protected function single_row( $item ) {
    881904                static $row_class = '';
    882905                $row_class = ( $row_class == '' ? ' class="alternate"' : '' );
    … …  
    895918         * @param object $item The current item
    896919         */
    897         function single_row_columns( $item ) {
     920        protected function single_row_columns( $item ) {
    898921                list( $columns, $hidden ) = $this->get_column_info();
    899922
    … …  
    931954         * @access public
    932955         */
    933         function ajax_response() {
     956        public function ajax_response() {
    934957                $this->prepare_items();
    935958
    … …  
    964987         * @access private
    965988         */
    966         function _js_vars() {
     989        private function _js_vars() {
    967990                $args = array(
    968991                        'class'  => get_class( $this ),
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r28293 r28493  
    1010class WP_Media_List_Table extends WP_List_Table {
    1111
    12         function __construct( $args = array() ) {
     12        public function __construct( $args = array() ) {
    1313                $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
    1414
    … …  
    1919        }
    2020
    21         function ajax_user_can() {
     21        public function ajax_user_can() {
    2222                return current_user_can('upload_files');
    2323        }
    2424
    25         function prepare_items() {
     25        public function prepare_items() {
    2626                global $lost, $wp_query, $post_mime_types, $avail_post_mime_types;
    2727
    … …  
    4242        }
    4343
    44         function get_views() {
     44        protected function get_views() {
    4545                global $wpdb, $post_mime_types, $avail_post_mime_types;
    4646
    … …  
    7575        }
    7676
    77         function get_bulk_actions() {
     77        protected function get_bulk_actions() {
    7878                $actions = array();
    7979                $actions['delete'] = __( 'Delete Permanently' );
    … …  
    8484        }
    8585
    86         function extra_tablenav( $which ) {
     86        protected function extra_tablenav( $which ) {
    8787?>
    8888                <div class="alignleft actions">
    … …  
    105105        }
    106106
    107         function current_action() {
     107        public function current_action() {
    108108                if ( isset( $_REQUEST['find_detached'] ) )
    109109                        return 'find_detached';
    … …  
    118118        }
    119119
    120         function has_items() {
     120        public function has_items() {
    121121                return have_posts();
    122122        }
    123123
    124         function no_items() {
     124        public function no_items() {
    125125                _e( 'No media attachments found.' );
    126126        }
    127127
    128         function get_columns() {
     128        protected function get_columns() {
    129129                $posts_columns = array();
    130130                $posts_columns['cb'] = '<input type="checkbox" />';
    … …  
    181181        }
    182182
    183         function get_sortable_columns() {
     183        protected function get_sortable_columns() {
    184184                return array(
    185185                        'title'    => 'title',
    … …  
    191191        }
    192192
    193         function display_rows() {
     193        protected function display_rows() {
    194194                global $post;
    195195
    … …  
    422422        }
    423423
    424         function _get_row_actions( $post, $att_title ) {
     424        private function _get_row_actions( $post, $att_title ) {
    425425                $actions = array();
    426426
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r27029 r28493  
    1010class WP_MS_Sites_List_Table extends WP_List_Table {
    1111
    12         function __construct( $args = array() ) {
     12        public function __construct( $args = array() ) {
    1313                parent::__construct( array(
    1414                        'plural' => 'sites',
    … …  
    1717        }
    1818
    19         function ajax_user_can() {
     19        public function ajax_user_can() {
    2020                return current_user_can( 'manage_sites' );
    2121        }
    2222
    23         function prepare_items() {
     23        public function prepare_items() {
    2424                global $s, $mode, $wpdb;
    2525
    … …  
    121121        }
    122122
    123         function no_items() {
     123        public function no_items() {
    124124                _e( 'No sites found.' );
    125125        }
    126126
    127         function get_bulk_actions() {
     127        protected function get_bulk_actions() {
    128128                $actions = array();
    129129                if ( current_user_can( 'delete_sites' ) )
    … …  
    135135        }
    136136
    137         function pagination( $which ) {
     137        protected function pagination( $which ) {
    138138                global $mode;
    139139
    … …  
    144144        }
    145145
    146         function get_columns() {
     146        protected function get_columns() {
    147147                $blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
    148148                $sites_columns = array(
    … …  
    170170        }
    171171
    172         function get_sortable_columns() {
     172        protected function get_sortable_columns() {
    173173                return array(
    174174                        'blogname'    => 'blogname',
    … …  
    178178        }
    179179
    180         function display_rows() {
     180        protected function display_rows() {
    181181                global $mode;
    182182
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r27090 r28493  
    1010class WP_MS_Themes_List_Table extends WP_List_Table {
    1111
    12         var $site_id;
    13         var $is_site_themes;
    14 
    15         function __construct( $args = array() ) {
     12        public $site_id;
     13        public $is_site_themes;
     14
     15        public function __construct( $args = array() ) {
    1616                global $status, $page;
    1717
    … …  
    3333        }
    3434
    35         function get_table_classes() {
     35        protected function get_table_classes() {
    3636                return array( 'widefat', 'plugins' );   // todo: remove and add CSS for .themes
    3737        }
    3838
    39         function ajax_user_can() {
     39        public function ajax_user_can() {
    4040                if ( $this->is_site_themes )
    4141                        return current_user_can( 'manage_sites' );
    … …  
    4444        }
    4545
    46         function prepare_items() {
     46        public function prepare_items() {
    4747                global $status, $totals, $page, $orderby, $order, $s;
    4848
    … …  
    132132        }
    133133
    134         function _search_callback( $theme ) {
     134        public function _search_callback( $theme ) {
    135135                static $term;
    136136                if ( is_null( $term ) )
    … …  
    153153
    154154        // Not used by any core columns.
    155         function _order_callback( $theme_a, $theme_b ) {
     155        public function _order_callback( $theme_a, $theme_b ) {
    156156                global $orderby, $order;
    157157
    … …  
    168168        }
    169169
    170         function no_items() {
     170        public function no_items() {
    171171                if ( ! $this->has_items )
    172172                        _e( 'No themes found.' );
    … …  
    175175        }
    176176
    177         function get_columns() {
     177        protected function get_columns() {
    178178                global $status;
    179179
    … …  
    185185        }
    186186
    187         function get_sortable_columns() {
     187        protected function get_sortable_columns() {
    188188                return array(
    189189                        'name'         => 'name',
    … …  
    191191        }
    192192
    193         function get_views() {
     193        protected function get_views() {
    194194                global $totals, $status;
    195195
    … …  
    234234        }
    235235
    236         function get_bulk_actions() {
     236        protected function get_bulk_actions() {
    237237                global $status;
    238238
    … …  
    251251        }
    252252
    253         function display_rows() {
     253        protected function display_rows() {
    254254                foreach ( $this->items as $theme )
    255255                        $this->single_row( $theme );
    256256        }
    257257
    258         function single_row( $theme ) {
     258        protected function single_row( $theme ) {
    259259                global $status, $page, $s, $totals;
    260260
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r28295 r28493  
    1010class WP_MS_Users_List_Table extends WP_List_Table {
    1111
    12         function ajax_user_can() {
     12        public function ajax_user_can() {
    1313                return current_user_can( 'manage_network_users' );
    1414        }
    1515
    16         function prepare_items() {
     16        public function prepare_items() {
    1717                global $usersearch, $role, $wpdb, $mode;
    1818
    … …  
    7070        }
    7171
    72         function get_bulk_actions() {
     72        protected function get_bulk_actions() {
    7373                $actions = array();
    7474                if ( current_user_can( 'delete_users' ) )
    … …  
    8080        }
    8181
    82         function no_items() {
     82        public function no_items() {
    8383                _e( 'No users found.' );
    8484        }
    8585
    86         function get_views() {
     86        protected function get_views() {
    8787                global $role;
    8888
    … …  
    100100        }
    101101
    102         function pagination( $which ) {
     102        protected function pagination( $which ) {
    103103                global $mode;
    104104
    … …  
    109109        }
    110110
    111         function get_columns() {
     111        protected function get_columns() {
    112112                $users_columns = array(
    113113                        'cb'         => '<input type="checkbox" />',
    … …  
    131131        }
    132132
    133         function get_sortable_columns() {
     133        protected function get_sortable_columns() {
    134134                return array(
    135135                        'username'   => 'login',
    … …  
    140140        }
    141141
    142         function display_rows() {
     142        protected function display_rows() {
    143143                global $mode;
    144144
  • trunk/src/wp-admin/includes/class-wp-plugin-install-list-table.php

    r28388 r28493  
    1010class WP_Plugin_Install_List_Table extends WP_List_Table {
    1111
    12         function ajax_user_can() {
     12        public function ajax_user_can() {
    1313                return current_user_can('install_plugins');
    1414        }
    1515
    16         function prepare_items() {
     16        public function prepare_items() {
    1717                include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
    1818
    … …  
    134134        }
    135135
    136         function no_items() {
     136        public function no_items() {
    137137                _e( 'No plugins match your request.' );
    138138        }
    139139
    140         function get_views() {
     140        protected function get_views() {
    141141                global $tabs, $tab;
    142142
    … …  
    151151        }
    152152
    153         function display_tablenav( $which ) {
     153        protected function display_tablenav( $which ) {
    154154                if ( 'top' ==  $which ) { ?>
    155155                        <div class="tablenav top">
    … …  
    175175        }
    176176
    177         function get_table_classes() {
     177        protected function get_table_classes() {
    178178                return array( 'widefat', $this->_args['plural'] );
    179179        }
    180180
    181         function get_columns() {
     181        protected function get_columns() {
    182182                return array(
    183183                        'name'        => _x( 'Name', 'plugin name' ),
    … …  
    188188        }
    189189
    190         function display_rows() {
     190        protected function display_rows() {
    191191                $plugins_allowedtags = array(
    192192                        'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r27507 r28493  
    1010class WP_Plugins_List_Table extends WP_List_Table {
    1111
    12         function __construct( $args = array() ) {
     12        public function __construct( $args = array() ) {
    1313                global $status, $page;
    1414
    … …  
    2828        }
    2929
    30         function get_table_classes() {
     30        protected function get_table_classes() {
    3131                return array( 'widefat', $this->_args['plural'] );
    3232        }
    3333
    34         function ajax_user_can() {
     34        public function ajax_user_can() {
    3535                return current_user_can('activate_plugins');
    3636        }
    3737
    38         function prepare_items() {
     38        public function prepare_items() {
    3939                global $status, $plugins, $totals, $page, $orderby, $order, $s;
    4040
    … …  
    173173        }
    174174
    175         function _search_callback( $plugin ) {
     175        public function _search_callback( $plugin ) {
    176176                static $term;
    177177                if ( is_null( $term ) )
    … …  
    187187        }
    188188
    189         function _order_callback( $plugin_a, $plugin_b ) {
     189        public function _order_callback( $plugin_a, $plugin_b ) {
    190190                global $orderby, $order;
    191191
    … …  
    202202        }
    203203
    204         function no_items() {
     204        public function no_items() {
    205205                global $plugins;
    206206
    … …  
    211211        }
    212212
    213         function get_columns() {
     213        protected function get_columns() {
    214214                global $status;
    215215
    … …  
    221221        }
    222222
    223         function get_sortable_columns() {
     223        protected function get_sortable_columns() {
    224224                return array();
    225225        }
    226226
    227         function get_views() {
     227        protected function get_views() {
    228228                global $totals, $status;
    229229
    … …  
    269269        }
    270270
    271         function get_bulk_actions() {
     271        protected function get_bulk_actions() {
    272272                global $status;
    273273
    … …  
    290290        }
    291291
    292         function bulk_actions() {
     292        public function bulk_actions() {
    293293                global $status;
    294294
    … …  
    299299        }
    300300
    301         function extra_tablenav( $which ) {
     301        protected function extra_tablenav( $which ) {
    302302                global $status;
    303303
    … …  
    317317        }
    318318
    319         function current_action() {
     319        public function current_action() {
    320320                if ( isset($_POST['clear-recent-list']) )
    321321                        return 'clear-recent-list';
    … …  
    324324        }
    325325
    326         function display_rows() {
     326        protected function display_rows() {
    327327                global $status;
    328328
    … …  
    334334        }
    335335
    336         function single_row( $item ) {
     336        protected function single_row( $item ) {
    337337                global $status, $page, $s, $totals;
    338338
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r27964 r28493  
    1717         * @access protected
    1818         */
    19         var $hierarchical_display;
     19        protected $hierarchical_display;
    2020
    2121        /**
    … …  
    2626         * @access protected
    2727         */
    28         var $comment_pending_count;
     28        protected $comment_pending_count;
    2929
    3030        /**
    … …  
    3535         * @access private
    3636         */
    37         var $user_posts_count;
     37        private $user_posts_count;
    3838
    3939        /**
    … …  
    4444         * @access private
    4545         */
    46         var $sticky_posts_count = 0;
    47 
    48         function __construct( $args = array() ) {
     46        private $sticky_posts_count = 0;
     47
     48        public function __construct( $args = array() ) {
    4949                global $post_type_object, $wpdb;
    5050
    … …  
    7575        }
    7676
    77         function ajax_user_can() {
     77        public function ajax_user_can() {
    7878                return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts );
    7979        }
    8080
    81         function prepare_items() {
     81        public function prepare_items() {
    8282                global $avail_post_stati, $wp_query, $per_page, $mode;
    8383
    … …  
    110110        }
    111111
    112         function has_items() {
     112        public function has_items() {
    113113                return have_posts();
    114114        }
    115115
    116         function no_items() {
     116        public function no_items() {
    117117                if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
    118118                        echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
    … …  
    121121        }
    122122
    123         function get_views() {
     123        protected function get_views() {
    124124                global $locked_post_status, $avail_post_stati;
    125125
    … …  
    182182        }
    183183
    184         function get_bulk_actions() {
     184        protected function get_bulk_actions() {
    185185                $actions = array();
    186186
    … …  
    198198        }
    199199
    200         function extra_tablenav( $which ) {
     200        protected function extra_tablenav( $which ) {
    201201                global $cat;
    202202?>
    … …  
    240240        }
    241241
    242         function current_action() {
     242        public function current_action() {
    243243                if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
    244244                        return 'delete_all';
    … …  
    247247        }
    248248
    249         function pagination( $which ) {
     249        protected function pagination( $which ) {
    250250                global $mode;
    251251
    … …  
    256256        }
    257257
    258         function get_table_classes() {
     258        protected function get_table_classes() {
    259259                return array( 'widefat', 'fixed', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
    260260        }
    261261
    262         function get_columns() {
     262        protected function get_columns() {
    263263                $post_type = $this->screen->post_type;
    264264
    … …  
    346346        }
    347347
    348         function get_sortable_columns() {
     348        protected function get_sortable_columns() {
    349349                return array(
    350350                        'title'    => 'title',
    … …  
    355355        }
    356356
    357         function display_rows( $posts = array(), $level = 0 ) {
     357        protected function display_rows( $posts = array(), $level = 0 ) {
    358358                global $wp_query, $per_page;
    359359
    … …  
    370370        }
    371371
    372         function _display_rows( $posts, $level = 0 ) {
     372        private function _display_rows( $posts, $level = 0 ) {
    373373                global $mode;
    374374
    … …  
    385385        }
    386386
    387         function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
     387        private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
    388388                global $wpdb;
    389389
    … …  
    477477         * @param int $per_page
    478478         */
    479         function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
     479        private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
    480480
    481481                if ( ! isset( $children_pages[$parent] ) )
    … …  
    522522        }
    523523
    524         function single_row( $post, $level = 0 ) {
     524        protected function single_row( $post, $level = 0 ) {
    525525                global $mode;
    526526                static $alternate;
    … …  
    880880         * @since 3.1.0
    881881         */
    882         function inline_edit() {
     882        public function inline_edit() {
    883883                global $mode;
    884884
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r28390 r28493  
    1010class WP_Terms_List_Table extends WP_List_Table {
    1111
    12         var $callback_args;
    13 
    14         function __construct( $args = array() ) {
     12        public $callback_args;
     13
     14        public function __construct( $args = array() ) {
    1515                global $post_type, $taxonomy, $action, $tax;
    1616
    … …  
    3939        }
    4040
    41         function ajax_user_can() {
     41        public function ajax_user_can() {
    4242                return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    4343        }
    4444
    45         function prepare_items() {
     45        public function prepare_items() {
    4646                $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );
    4747
    … …  
    9898        }
    9999
    100         function has_items() {
     100        public function has_items() {
    101101                // todo: populate $this->items in prepare_items()
    102102                return true;
    103103        }
    104104
    105         function get_bulk_actions() {
     105        protected function get_bulk_actions() {
    106106                $actions = array();
    107107                $actions['delete'] = __( 'Delete' );
    … …  
    110110        }
    111111
    112         function current_action() {
     112        public function current_action() {
    113113                if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
    114114                        return 'bulk-delete';
    … …  
    117117        }
    118118
    119         function get_columns() {
     119        protected function get_columns() {
    120120                $columns = array(
    121121                        'cb'          => '<input type="checkbox" />',
    … …  
    135135        }
    136136
    137         function get_sortable_columns() {
     137        protected function get_sortable_columns() {
    138138                return array(
    139139                        'name'        => 'name',
    … …  
    145145        }
    146146
    147         function display_rows_or_placeholder() {
     147        protected function display_rows_or_placeholder() {
    148148                $taxonomy = $this->screen->taxonomy;
    149149
    … …  
    194194        }
    195195
    196         function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
     196        private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
    197197
    198198                $end = $start + $per_page;
    … …  
    242242        }
    243243
    244         function single_row( $tag, $level = 0 ) {
     244        protected function single_row( $tag, $level = 0 ) {
    245245                global $taxonomy;
    246246                $tag = sanitize_term( $tag, $taxonomy );
    … …  
    256256        }
    257257
    258         function column_cb( $tag ) {
     258        public function column_cb( $tag ) {
    259259                $default_term = get_option( 'default_' . $this->screen->taxonomy );
    260260
    … …  
    266266        }
    267267
    268         function column_name( $tag ) {
     268        public function column_name( $tag ) {
    269269                $taxonomy = $this->screen->taxonomy;
    270270                $tax = get_taxonomy( $taxonomy );
    … …  
    340340        }
    341341
    342         function column_description( $tag ) {
     342        public function column_description( $tag ) {
    343343                return $tag->description;
    344344        }
    345345
    346         function column_slug( $tag ) {
     346        public function column_slug( $tag ) {
    347347                /** This filter is documented in wp-admin/edit-tag-form.php */
    348348                return apply_filters( 'editable_slug', $tag->slug );
    349349        }
    350350
    351         function column_posts( $tag ) {
     351        public function column_posts( $tag ) {
    352352                $count = number_format_i18n( $tag->count );
    353353
    … …  
    373373        }
    374374
    375         function column_links( $tag ) {
     375        public function column_links( $tag ) {
    376376                $count = number_format_i18n( $tag->count );
    377377                if ( $count )
    … …  
    380380        }
    381381
    382         function column_default( $tag, $column_name ) {
     382        public function column_default( $tag, $column_name ) {
    383383                /**
    384384                 * Filter the displayed columns in the terms list table.
    … …  
    401401         * @since 3.1.0
    402402         */
    403         function inline_edit() {
     403        public function inline_edit() {
    404404                $tax = get_taxonomy( $this->screen->taxonomy );
    405405
  • trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php

    r28287 r28493  
    1010class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
    1111
    12         var $features = array();
    13 
    14         function ajax_user_can() {
     12        public $features = array();
     13
     14        public function ajax_user_can() {
    1515                return current_user_can( 'install_themes' );
    1616        }
    1717
    18         function prepare_items() {
     18        public function prepare_items() {
    1919                include( ABSPATH . 'wp-admin/includes/theme-install.php' );
    2020
    … …  
    141141        }
    142142
    143         function no_items() {
     143        public function no_items() {
    144144                _e( 'No themes match your request.' );
    145145        }
    146146
    147         function get_views() {
     147        protected function get_views() {
    148148                global $tabs, $tab;
    149149
    … …  
    158158        }
    159159
    160         function display() {
     160        public function display() {
    161161                wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
    162162?>
    … …  
    184184        }
    185185
    186         function display_rows() {
     186        protected function display_rows() {
    187187                $themes = $this->items;
    188188                foreach ( $themes as $theme ) {
    … …  
    215215         *     public 'download_link' => string 'http://wordpress.org/themes/download/magazine-basic.1.1.zip'
    216216         */
    217         function single_row( $theme ) {
     217        protected function single_row( $theme ) {
    218218                global $themes_allowedtags;
    219219
    … …  
    295295         * Prints the wrapper for the theme installer.
    296296         */
    297         function theme_installer() {
     297        public function theme_installer() {
    298298                ?>
    299299                <div id="theme-installer" class="wp-full-overlay expanded">
    … …  
    324324         * @param object $theme - A WordPress.org Theme API object.
    325325         */
    326         function theme_installer_single( $theme ) {
     326        public function theme_installer_single( $theme ) {
    327327                ?>
    328328                <div id="theme-installer" class="wp-full-overlay single-theme">
    … …  
    342342         * @param object $theme - A WordPress.org Theme API object.
    343343         */
    344         function install_theme_info( $theme ) {
     344        public function install_theme_info( $theme ) {
    345345                global $themes_allowedtags;
    346346
    … …  
    409409         * @uses $type Global; type of search.
    410410         */
    411         function _js_vars( $extra_args = array() ) {
     411        private function _js_vars( $extra_args = array() ) {
    412412                global $tab, $type;
    413413                parent::_js_vars( compact( 'tab', 'type' ) );
  • trunk/src/wp-admin/includes/class-wp-themes-list-table.php

    r27507 r28493  
    1111
    1212        protected $search_terms = array();
    13         var $features = array();
    14 
    15         function __construct( $args = array() ) {
     13        public $features = array();
     14
     15        public function __construct( $args = array() ) {
    1616                parent::__construct( array(
    1717                        'ajax' => true,
    … …  
    2020        }
    2121
    22         function ajax_user_can() {
     22        public function ajax_user_can() {
    2323                // Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
    2424                return current_user_can( 'switch_themes' );
    2525        }
    2626
    27         function prepare_items() {
     27        public function prepare_items() {
    2828                $themes = wp_get_themes( array( 'allowed' => true ) );
    2929
    … …  
    5858        }
    5959
    60         function no_items() {
     60        public function no_items() {
    6161                if ( $this->search_terms || $this->features ) {
    6262                        _e( 'No items found.' );
    … …  
    8686        }
    8787
    88         function tablenav( $which = 'top' ) {
     88        public function tablenav( $which = 'top' ) {
    8989                if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
    9090                        return;
    … …  
    9898        }
    9999
    100         function display() {
     100        public function display() {
    101101                wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
    102102?>
    … …  
    111111        }
    112112
    113         function get_columns() {
     113        protected function get_columns() {
    114114                return array();
    115115        }
    116116
    117         function display_rows_or_placeholder() {
     117        protected function display_rows_or_placeholder() {
    118118                if ( $this->has_items() ) {
    119119                        $this->display_rows();
    … …  
    125125        }
    126126
    127         function display_rows() {
     127        protected function display_rows() {
    128128                $themes = $this->items;
    129129
    … …  
    209209        }
    210210
    211         function search_theme( $theme ) {
     211        public function search_theme( $theme ) {
    212212                // Search the features
    213213                foreach ( $this->features as $word ) {
    … …  
    250250         * @uses _pagination_args['total_pages']
    251251         */
    252         function _js_vars( $extra_args = array() ) {
     252        private function _js_vars( $extra_args = array() ) {
    253253                $search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
    254254
  • trunk/tests/phpunit/includes/functions.php

    r28480 r28493  
    4646        private $foo = 'bar';
    4747
    48         function __get( $name ) {
     48        public function __get( $name ) {
    4949                return $this->$name;
    5050        }
     51
     52        public function __call( $name, $arguments ) {
     53                return call_user_func_array( array( $this, $name ), $arguments );
     54        }
     55
     56        private function callMe() {
     57                return 'maybe';
     58        }
    5159}
     60
     61class Basic_Subclass extends Basic_Object {}
  • trunk/tests/phpunit/tests/basic.php

    r28480 r28493  
    128128                $this->assertEquals( 'bar', $basic->foo );
    129129        }
     130
     131        function test_subclass_magic_getter() {
     132                $basic = new Basic_Subclass();
     133
     134                $this->assertEquals( 'bar', $basic->foo );
     135        }
     136
     137        function test_call_method() {
     138                $basic = new Basic_Object();
     139
     140                $this->assertEquals( 'maybe', $basic->callMe() );
     141        }
     142
     143        function test_subclass_call_method() {
     144                $basic = new Basic_Subclass();
     145
     146                $this->assertEquals( 'maybe', $basic->callMe() );
     147        }
    130148}
Note: See TracChangeset for help on using the changeset viewer.