wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_media_states › WordPress Function

Seit3.2.0
Veraltetn/v
_media_states ( $post, $display = true )
Parameter: (2)
  • (WP_Post) $post The attachment post to retrieve states for.
    Erforderlich: Ja
  • (bool) $display Optional. Whether to display the post states as an HTML string. Default true.
    Erforderlich: Nein
    Standard: true
Gibt zurück:
  • (string) Media states string.
Definiert in:
Codex:
Changelog:
  • 5.6.0

Outputs the attachment media states as HTML.



Quellcode

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 .= ' — ';

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