| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 /** 11 * Fetches an instance of a WP_List_Table class. 12 * 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 { 19 * Optional. Arguments to pass to the class. 20 * 21 * @type string $plural Plural value used for labels and the objects being listed. 22 * This affects things such as CSS class-names and nonces used 23 * in the list table, e.g. 'posts'. Default empty. 24 * @type string $singular Singular label for an object being listed, e.g. 'post'. 25 * Default empty. 26 * @type bool $ajax Whether the list table supports Ajax. This includes loading 27 * and sorting data, for example. If true, the class will call 28 * the _js_vars() method in the footer to provide variables 29 * to any scripts handling Ajax events. Default false. 30 * @type string|WP_Screen|null $screen String containing the hook name used to determine the current 31 * screen, or a `WP_Screen` instance. If left null, the current 32 * screen will be automatically set. Default null. 33 * } 34 * @return WP_List_Table|false List table object of the type given in `$class_name` 35 * on success, false if the class does not exist. 36 * 37 * @phpstan-template T of WP_List_Table 38 * @phpstan-param class-string<T> $class_name 39 * @phpstan-return T|false 40 */ 41 function _get_list_table( $class_name, $args = array() ) { 42 $core_classes = array( 43 // Site Admin. 44 'WP_Posts_List_Table' => 'posts', 45 'WP_Media_List_Table' => 'media', 46 'WP_Terms_List_Table' => 'terms', 47 'WP_Users_List_Table' => 'users', 48 'WP_Comments_List_Table' => 'comments', 49 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ), 50 'WP_Links_List_Table' => 'links', 51 'WP_Plugin_Install_List_Table' => 'plugin-install', 52 'WP_Themes_List_Table' => 'themes', 53 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), 54 'WP_Plugins_List_Table' => 'plugins', 55 'WP_Application_Passwords_List_Table' => 'application-passwords', 56 57 // Network Admin. 58 'WP_MS_Sites_List_Table' => 'ms-sites', 59 'WP_MS_Users_List_Table' => 'ms-users', 60 'WP_MS_Themes_List_Table' => 'ms-themes', 61 62 // Privacy requests tables. 63 'WP_Privacy_Data_Export_Requests_List_Table' => 'privacy-data-export-requests', 64 'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests', 65 ); 66 67 if ( isset( $core_classes[ $class_name ] ) ) { 68 foreach ( (array) $core_classes[ $class_name ] as $required ) { 69 require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php'; 70 } 71 72 if ( isset( $args['screen'] ) ) { 73 $args['screen'] = convert_to_screen( $args['screen'] ); 74 } elseif ( isset( $GLOBALS['hook_suffix'] ) ) { 75 $args['screen'] = get_current_screen(); 76 } else { 77 $args['screen'] = null; 78 } 79 80 /** 81 * Filters the list table class to instantiate. 82 * 83 * @since 6.1.0 84 * 85 * @param string $class_name The list table class to use. 86 * @param array $args An array containing _get_list_table() arguments. 87 * 88 * @phpstan-template T of WP_List_Table 89 * @phpstan-param class-string<T> $class_name 90 */ 91 $custom_class_name = apply_filters( 'wp_list_table_class_name', $class_name, $args ); 92 93 if ( is_string( $custom_class_name ) && class_exists( $custom_class_name ) ) { 94 $class_name = $custom_class_name; 95 } 96 97 return new $class_name( $args ); 98 } 99 100 return false; 101 } 102 103 /** 104 * Register column headers for a particular screen. 105 * 106 * @see get_column_headers(), print_column_headers(), get_hidden_columns() 107 * 108 * @since 2.7.0 109 * 110 * @param string $screen The handle for the screen to register column headers for. This is 111 * usually the hook name returned by the `add_*_page()` functions. 112 * @param string[] $columns An array of columns with column IDs as the keys and translated 113 * column names as the values. 114 */ 115 function register_column_headers( $screen, $columns ) { 116 new _WP_List_Table_Compat( $screen, $columns ); 117 } 118 119 /** 120 * Prints column headers for a particular screen. 121 * 122 * @since 2.7.0 123 * 124 * @param string|WP_Screen $screen The screen hook name or screen object. 125 * @param bool $with_id Whether to set the ID attribute or not. 126 */ 127 function print_column_headers( $screen, $with_id = true ) { 128 $wp_list_table = new _WP_List_Table_Compat( $screen ); 129 130 $wp_list_table->print_column_headers( $with_id ); 131 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Thu Sep 24 08:20:34 2026 | Cross-referenced by PHPXref |