_media_states( WP_Post $post, bool $echo = true )

Outputs the attachment media states as HTML.


Parameters Parameters

$post

(WP_Post) (Required) The attachment post to retrieve states for.

$echo

(bool) (Optional) Whether to echo the post states as an HTML string.

Default value: true


Top ↑

Return Return

(string) Media states string.


Top ↑

Source Source

File: wp-admin/includes/template.php

function _media_states( $post, $echo = true ) {
	$media_states        = get_media_states( $post );
	$media_states_string = '';

	if ( ! empty( $media_states ) ) {
		$state_count = count( $media_states );
		$i           = 0;

		$media_states_string .= ' — ';

		foreach ( $media_states as $state ) {
			$sep = ( ++$i === $state_count ) ? '' : ', ';

			$media_states_string .= "<span class='post-state'>$state$sep</span>";
		}
	}

	if ( $echo ) {
		echo $media_states_string;
	}

	return $media_states_string;
}


Top ↑

Changelog Changelog

Changelog
Version Description
5.6.0 Added the $echo parameter and a return value.
3.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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