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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. $this->_screen = $screen;
  21. if ( !empty( $columns ) ) {
  22. $this->_columns = $columns;
  23. add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
  24. }
  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. *
  39. * @return array
  40. */
  41. public function get_columns() {
  42. return $this->_columns;
  43. }
  44. }