Açıklama Yok

list-table.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 3.1.0
  8. */
  9. /**
  10. * Fetches an instance of a WP_List_Table class.
  11. *
  12. * @access private
  13. * @since 3.1.0
  14. *
  15. * @global string $hook_suffix
  16. *
  17. * @param string $class_name The type of the list table, which is the class name.
  18. * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'.
  19. * @return WP_List_Table|false List table object on success, false if the class does not exist.
  20. */
  21. function _get_list_table( $class_name, $args = array() ) {
  22. $core_classes = array(
  23. // Site Admin.
  24. 'WP_Posts_List_Table' => 'posts',
  25. 'WP_Media_List_Table' => 'media',
  26. 'WP_Terms_List_Table' => 'terms',
  27. 'WP_Users_List_Table' => 'users',
  28. 'WP_Comments_List_Table' => 'comments',
  29. 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ),
  30. 'WP_Links_List_Table' => 'links',
  31. 'WP_Plugin_Install_List_Table' => 'plugin-install',
  32. 'WP_Themes_List_Table' => 'themes',
  33. 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
  34. 'WP_Plugins_List_Table' => 'plugins',
  35. 'WP_Application_Passwords_List_Table' => 'application-passwords',
  36. // Network Admin.
  37. 'WP_MS_Sites_List_Table' => 'ms-sites',
  38. 'WP_MS_Users_List_Table' => 'ms-users',
  39. 'WP_MS_Themes_List_Table' => 'ms-themes',
  40. // Privacy requests tables.
  41. 'WP_Privacy_Data_Export_Requests_List_Table' => 'privacy-data-export-requests',
  42. 'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests',
  43. );
  44. if ( isset( $core_classes[ $class_name ] ) ) {
  45. foreach ( (array) $core_classes[ $class_name ] as $required ) {
  46. require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php';
  47. }
  48. if ( isset( $args['screen'] ) ) {
  49. $args['screen'] = convert_to_screen( $args['screen'] );
  50. } elseif ( isset( $GLOBALS['hook_suffix'] ) ) {
  51. $args['screen'] = get_current_screen();
  52. } else {
  53. $args['screen'] = null;
  54. }
  55. return new $class_name( $args );
  56. }
  57. return false;
  58. }
  59. /**
  60. * Register column headers for a particular screen.
  61. *
  62. * @see get_column_headers(), print_column_headers(), get_hidden_columns()
  63. *
  64. * @since 2.7.0
  65. *
  66. * @param string $screen The handle for the screen to register column headers for. This is
  67. * usually the hook name returned by the `add_*_page()` functions.
  68. * @param string[] $columns An array of columns with column IDs as the keys and translated
  69. * column names as the values.
  70. */
  71. function register_column_headers( $screen, $columns ) {
  72. new _WP_List_Table_Compat( $screen, $columns );
  73. }
  74. /**
  75. * Prints column headers for a particular screen.
  76. *
  77. * @since 2.7.0
  78. *
  79. * @param string|WP_Screen $screen The screen hook name or screen object.
  80. * @param bool $with_id Whether to set the ID attribute or not.
  81. */
  82. function print_column_headers( $screen, $with_id = true ) {
  83. $wp_list_table = new _WP_List_Table_Compat( $screen );
  84. $wp_list_table->print_column_headers( $with_id );
  85. }