WP_Screen::render_list_table_columns_preferences() WordPress Method

The WP_Screen::render_list_table_columns_preferences() method renders the column preferences for a particular list table. The method is called by the get_column_headers() method.

WP_Screen::render_list_table_columns_preferences() #

Render the list table columns preferences.


Source

File: wp-admin/includes/class-wp-screen.php

	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
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.