_media_states( WP_Post $post, bool $display = true ): string

In this article

Outputs the attachment media states as HTML.

Parameters

$postWP_Postrequired
The attachment post to retrieve states for.
$displaybooloptional
Whether to display the post states as an HTML string.

Default:true

Return

string Media states string.

Source

function _media_states( $post, $display = true ) {	$media_states = get_media_states( $post );	$media_states_string = '';	if ( ! empty( $media_states ) ) {	$state_count = count( $media_states );	$i = 0;	$media_states_string .= ' &mdash; ';	foreach ( $media_states as $state ) {	++$i;	$separator = ( $i < $state_count ) ? ', ' : '';	$media_states_string .= "<span class='post-state'>{$state}{$separator}</span>";	}	}	if ( $display ) {	echo $media_states_string;	}	return $media_states_string; } 

Changelog

VersionDescription
5.6.0Added the $display parameter and a return value.
3.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.