Ticket #15386: 15386.diff
| File 15386.diff, 2.9 KB (added by , 7 years ago) |
|---|
-
src/wp-admin/includes/screen.php
diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index 42a19ec91e..1770ca9963 100644
a b 10 10 * Get the column headers for a screen 11 11 * 12 12 * @since 2.7.0 13 * 14 * @staticvar array $column_headers13 * @since 5.5.0 Removed a static var that made it difficult to instantiate list 14 * tables after the page header had been rendered. 15 15 * 16 16 * @param string|WP_Screen $screen The screen you want the headers for 17 17 * @return string[] The column header labels keyed by column ID. … … function get_column_headers( $screen ) { 21 21 $screen = convert_to_screen( $screen ); 22 22 } 23 23 24 static $column_headers = array(); 25 26 if ( ! isset( $column_headers[ $screen->id ] ) ) { 27 /** 28 * Filters the column headers for a list table on a specific screen. 29 * 30 * The dynamic portion of the hook name, `$screen->id`, refers to the 31 * ID of a specific screen. For example, the screen ID for the Posts 32 * list table is edit-post, so the filter for that screen would be 33 * manage_edit-post_columns. 34 * 35 * @since 3.0.0 36 * 37 * @param string[] $columns The column header labels keyed by column ID. 38 */ 39 $column_headers[ $screen->id ] = apply_filters( "manage_{$screen->id}_columns", array() ); 40 } 41 42 return $column_headers[ $screen->id ]; 24 /** 25 * Filters the column headers for a list table on a specific screen. 26 * 27 * The dynamic portion of the hook name, `$screen->id`, refers to the 28 * ID of a specific screen. For example, the screen ID for the Posts 29 * list table is edit-post, so the filter for that screen would be 30 * manage_edit-post_columns. 31 * 32 * @since 3.0.0 33 * 34 * @param string[] $columns The column header labels keyed by column ID. 35 */ 36 return apply_filters( "manage_{$screen->id}_columns", array() ); 43 37 } 44 38 45 39 /** -
tests/phpunit/tests/admin/includesListTable.php
diff --git a/tests/phpunit/tests/admin/includesListTable.php b/tests/phpunit/tests/admin/includesListTable.php index 9edbea1793..bc22e1b7f0 100644
a b public function test_empty_trash_button_should_not_be_shown_if_there_are_no_comm 293 293 294 294 $this->assertNotContains( 'id="delete_all"', $output ); 295 295 } 296 297 /** 298 * Test that can a list can display with no dependency on core screen context. 299 * 300 * @ticket 15386 301 */ 302 public function test_table_list_renders() { 303 $table = _get_list_table( 'WP_Comments_List_Table', array( 'screen' => 'my-plugin-page' ) ); 304 305 // At least one comment needed. 306 $this->factory->comment->create_many( 10 ); 307 308 ob_start(); 309 310 $table->views(); 311 $table->prepare_items(); 312 $table->display(); 313 $output = ob_get_clean(); 314 315 // CSS class only exists if the table has at least one comment. 316 $this->assertContains( 'class="submitted-on"', $output ); 317 } 296 318 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)