class-wp-list-table-compat.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Helper functions for displaying a list of items in an ajaxified HTML table.
  4. *
  5. * @package WordPress
  6. * @subpackage List_Table
  7. * @since 4.7.0
  8. */
  9. /**
  10. * Helper class to be used only by back compat functions
  11. *
  12. * @since 3.1.0
  13. */
  14. class _WP_List_Table_Compat extends WP_List_Table {
  15. public $_screen;
  16. public $_columns;
  17. public function __construct( $screen, $columns = array() ) {
  18. if ( is_string( $screen ) ) {
  19. $screen = convert_to_screen( $screen );
  20. }
  21. $this->_screen = $screen;
  22. if ( ! empty( $columns ) ) {
  23. $this->_columns = $columns;
  24. add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
  25. }
  26. }
  27. /**
  28. * @return array
  29. */
  30. protected function get_column_info() {
  31. $columns = get_column_headers( $this->_screen );
  32. $hidden = get_hidden_columns( $this->_screen );
  33. $sortable = array();
  34. $primary = $this->get_default_primary_column_name();
  35. return array( $columns, $hidden, $sortable, $primary );
  36. }
  37. /**
  38. * @return array
  39. */
  40. public function get_columns() {
  41. return $this->_columns;
  42. }
  43. }