A WordPress-centric search engine for devs and theme authors



_media_states ›

Since3.2.0
Deprecatedn/a
_media_states ( $post, $echo = true )
Parameters: (2)
  • (WP_Post) $post The attachment post to retrieve states for.
    Required: Yes
  • (bool) $echo Optional. Whether to echo the post states as an HTML string. Default true.
    Required: No
    Default: true
Returns:
  • (string) Media states string.
Defined at:
Codex:
Change Log:
  • 5.6.0

Outputs the attachment media states as HTML.



Source

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;
}