WP_Posts_List_Table::column_cb() WordPress Method

The WP_Posts_List_Table::column_cb() method is used to generate the checkbox column for the posts list table.

WP_Posts_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-posts-list-table.php

	public function column_cb( $item ) {
		// Restores the more descriptive, specific name for use within this method.
		$post = $item;
		$show = current_user_can( 'edit_post', $post->ID );

		/**
		 * Filters whether to show the bulk edit checkbox for a post in its list table.
		 *
		 * By default the checkbox is only shown if the current user can edit the post.
		 *
		 * @since 5.7.0
		 *
		 * @param bool    $show Whether to show the checkbox.
		 * @param WP_Post $post The current WP_Post object.
		 */
		if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
			?>
			<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
				<?php
					/* translators: %s: Post title. */
					printf( __( 'Select %s' ), _draft_or_post_title() );
				?>
			</label>
			<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
			<div class="locked-indicator">
				<span class="locked-indicator-icon" aria-hidden="true"></span>
				<span class="screen-reader-text">
				<?php
				printf(
					/* translators: %s: Post title. */
					__( '&#8220;%s&#8221; is locked' ),
					_draft_or_post_title()
				);
				?>
				</span>
			</div>
			<?php
		endif;
	}


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.