Make WordPress Core


Ignore:
Timestamp:
08/09/2022 12:31:09 AM (2 years ago)
Author:
peterwilsoncc
Message:

Administration: Improve performance of List Tables.

Improve the performance of WP_List_Table::get_column_info() by adding the primary column to the cached header values. This reduces the number of calls to the WP_List_Table::get_primary_column_name() method to once per table in line with the other header getter functions.

Props bobbingwide, chaion07, costdev, mikeschroder, mukesh27, peterwilsoncc, shetheliving, spacedmonkey.
Fixes #34564.

File:
1 edited

Legend:

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

    r53502 r53868  
    11091109    protected function get_column_info() {
    11101110        // $_column_headers is already set / cached.
    1111         if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
     1111        if (
     1112            isset( $this->_column_headers ) &&
     1113            is_array( $this->_column_headers )
     1114        ) {
    11121115            /*
    11131116             * Backward compatibility for `$_column_headers` format prior to WordPress 4.3.
     
    11171120             * in plugins setting the property directly in the three item format.
    11181121             */
     1122            if ( 4 === count( $this->_column_headers ) ) {
     1123                return $this->_column_headers;
     1124            }
     1125
    11191126            $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
    11201127            foreach ( $this->_column_headers as $key => $value ) {
     
    11221129            }
    11231130
    1124             return $column_headers;
     1131            $this->_column_headers = $column_headers;
     1132
     1133            return $this->_column_headers;
    11251134        }
    11261135
Note: See TracChangeset for help on using the changeset viewer.