選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

85 行
2.6 KiB

  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. * Fetch 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 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 object|bool Object on success, false if the class does not exist.
  20. */
  21. function _get_list_table( $class, $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. // Network Admin
  36. 'WP_MS_Sites_List_Table' => 'ms-sites',
  37. 'WP_MS_Users_List_Table' => 'ms-users',
  38. 'WP_MS_Themes_List_Table' => 'ms-themes',
  39. );
  40. if ( isset( $core_classes[ $class ] ) ) {
  41. foreach ( (array) $core_classes[ $class ] as $required )
  42. require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );
  43. if ( isset( $args['screen'] ) )
  44. $args['screen'] = convert_to_screen( $args['screen'] );
  45. elseif ( isset( $GLOBALS['hook_suffix'] ) )
  46. $args['screen'] = get_current_screen();
  47. else
  48. $args['screen'] = null;
  49. return new $class( $args );
  50. }
  51. return false;
  52. }
  53. /**
  54. * Register column headers for a particular screen.
  55. *
  56. * @since 2.7.0
  57. *
  58. * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
  59. * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
  60. * @see get_column_headers(), print_column_headers(), get_hidden_columns()
  61. */
  62. function register_column_headers($screen, $columns) {
  63. new _WP_List_Table_Compat( $screen, $columns );
  64. }
  65. /**
  66. * Prints column headers for a particular screen.
  67. *
  68. * @since 2.7.0
  69. *
  70. * @param string|WP_Screen $screen The screen hook name or screen object.
  71. * @param bool $with_id Whether to set the id attribute or not.
  72. */
  73. function print_column_headers( $screen, $with_id = true ) {
  74. $wp_list_table = new _WP_List_Table_Compat($screen);
  75. $wp_list_table->print_column_headers( $with_id );
  76. }