On this page
WP_Screen::render_list_table_columns_preferences()
Renders the list table columns preferences.
Source
File: wp-admin/includes/class-wp-screen.php. View all references
public function render_list_table_columns_preferences() {
$columns = get_column_headers( $this );
$hidden = get_hidden_columns( $this );
if ( ! $columns ) {
return;
}
$legend = ! empty( $columns['_title'] ) ? $columns['_title'] : __( 'Columns' );
?>
<fieldset class="metabox-prefs">
<legend><?php echo $legend; ?></legend>
<?php
$special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special.
if ( in_array( $column, $special, true ) ) {
continue;
}
if ( empty( $title ) ) {
continue;
}
/*
* The Comments column uses HTML in the display name with some screen
* reader text. Make sure to strip tags from the Comments column
* title and any other custom column title plugins might add.
*/
$title = wp_strip_all_tags( $title );
$id = "$column-hide";
echo '<label>';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden, true ), true, false ) . ' />';
echo "$title</label>\n";
}
?>
</fieldset>
<?php
}
Related
Uses
| Uses | Description |
|---|---|
| get_column_headers() wp-admin/includes/screen.php | Get the column headers for a screen |
| get_hidden_columns() wp-admin/includes/screen.php | Get a list of hidden columns. |
| wp_strip_all_tags() wp-includes/formatting.php | Properly strips all HTML tags including script and style |
| checked() wp-includes/general-template.php | Outputs the HTML checked attribute. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
Used By
| Used By | Description |
|---|---|
| WP_Screen::render_screen_options() wp-admin/includes/class-wp-screen.php | Renders the screen options tab. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_screen/render_list_table_columns_preferences