On this page
WP_Media_List_Table::column_title( WP_Post $post )
Handles the title column output.
Parameters
Source
File: wp-admin/includes/class-wp-media-list-table.php. View all references
public function column_title( $post ) {
list( $mime ) = explode( '/', $post->post_mime_type );
$title = _draft_or_post_title();
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
$link_start = '';
$link_end = '';
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
$link_start = sprintf(
'<a href="%s" aria-label="%s">',
get_edit_post_link( $post->ID ),
/* translators: %s: Attachment title. */
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) )
);
$link_end = '</a>';
}
$class = $thumb ? ' class="has-media-icon"' : '';
?>
<strong<?php echo $class; ?>>
<?php
echo $link_start;
if ( $thumb ) :
?>
<span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
<?php
endif;
echo $title . $link_end;
_media_states( $post );
?>
</strong>
<p class="filename">
<span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span>
<?php
$file = get_attached_file( $post->ID );
echo esc_html( wp_basename( $file ) );
?>
</p>
<?php
}
Related
Uses
| Uses | Description |
|---|---|
| _draft_or_post_title() wp-admin/includes/template.php | Gets the post title. |
| _media_states() wp-admin/includes/template.php | Outputs the attachment media states as HTML. |
| sanitize_html_class() wp-includes/formatting.php | Sanitizes an HTML classname to ensure it only contains valid characters. |
| get_edit_post_link() wp-includes/link-template.php | Retrieves the edit post link for post. |
| wp_get_attachment_image() wp-includes/media.php | Gets an HTML img element representing an image attachment. |
| get_attached_file() wp-includes/post.php | Retrieves attached file path based on attachment ID. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| _e() wp-includes/l10n.php | Displays translated text. |
| wp_basename() wp-includes/formatting.php | i18n-friendly version of basename(). |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| esc_html() wp-includes/formatting.php | Escaping for HTML blocks. |
Changelog
| Version | Description |
|---|---|
| 4.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_media_list_table/column_title