WP_Media_List_Table::column_cb() WordPress Method

This method is responsible for generating the checkbox column for each row of the media list table. The checkbox column is used for bulk actions on the media items.

WP_Media_List_Table::column_cb( WP_Post $item ) #

Handles the checkbox column output.


Parameters

$item

(WP_Post)(Required)The current WP_Post object.


Top ↑

Source

File: wp-admin/includes/class-wp-media-list-table.php

	public function column_cb( $item ) {
		// Restores the more descriptive, specific name for use within this method.
		$post = $item;

		if ( current_user_can( 'edit_post', $post->ID ) ) {
			?>
			<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>">
				<?php
				/* translators: %s: Attachment title. */
				printf( __( 'Select %s' ), _draft_or_post_title() );
				?>
			</label>
			<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
			<?php
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Renamed $post to $item to match parent class for PHP 8 named parameter support.
4.3.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.