WP_Media_List_Table::column_thumbnail( WP_Post $post )
Handles the thumbnail column output.
Parameters
- $post
-
(Required) The current WP_Post object.
Source
File: wp-admin/includes/class-wp-media-list-table.php
public function column_thumbnail( $post ) {
$user_can_edit = current_user_can( 'edit_post', $post->ID );
// Get all post types except attachments and revisions.
$parent_types = get_post_types();
unset( $parent_types['attachment'] );
unset( $parent_types['revision'] );
// Set output variable.
$output = '';
foreach ( $parent_types as $parent_type ) {
// Get all posts where this attachment is the featured image.
$relationship_ids = cp_get_object_relationship_ids( $post->ID, 'thumbnail', $parent_type );
if ( ! empty( $relationship_ids ) ) {
foreach ( $relationship_ids as $relationship_id ) {
if ( absint( $relationship_id ) !== 0 ) {
$ancestor = get_post( $relationship_id );
$ancestor_type_obj = get_post_type_object( $ancestor->post_type );
$title = _draft_or_post_title( $relationship_id );
if ( $ancestor_type_obj->show_ui && current_user_can( 'edit_post', $relationship_id ) ) {
$output .= '<strong><a href="' . esc_url( get_edit_post_link( $relationship_id ) ) . '">' . esc_html( $title ) . '</a></strong><br>';
} else {
$output .= $title . '<br>';
}
}
}
}
}
return $output;
}
Changelog
Version | Description |
---|---|
CP-2.2.0 | Introduced. CP-2.2.0 |