WP_Media_List_Table::column_used_in( WP_Post $post )

Handles the used-in column output.


Parameters

$post

(Required) The current WP_Post object.


Source

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

	public function column_used_in( $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 used in the content.
			$parent_ids = cp_get_object_relationship_ids( $post->ID, 'attachment', $parent_type );

			if ( ! empty( $parent_ids ) ) {
				foreach ( $parent_ids as $parent_id ) {
					if ( absint( $parent_id ) !== 0 ) {
						$parent_type_obj = get_post_type_object( $parent_type );
						$title           = _draft_or_post_title( $parent_id );

						if ( $parent_type_obj->show_ui && current_user_can( 'edit_post', $parent_id ) ) {
							$output .= '<strong><a href="' . esc_url( get_edit_post_link( $parent_id ) ) . '">' . esc_html( $title ) . '</a></strong><br>';
						} else {
							$output .= $title . '<br>';
						}
					}
				}
			}
		}
		return $output;
	}


Changelog

Changelog
Version Description
CP-2.2.0 Introduced. CP-2.2.0