Un motore di ricerca WordPress per sviluppatori e autori di temi



_post_states ›

Da2.7.0
Deprecaton/a
_post_states ( $post, $echo = true )
Parametri: (2)
  • (WP_Post) $post The post to retrieve states for.
    Richiesto:
  • (bool) $echo Optional. Whether to echo the post states as an HTML string. Default true.
    Richiesto: No
    Default: true
Vedi:
Ritorna:
  • (string) Post states string.
Definito a:
Codex:
ChangeLog:
  • 5.3.0

Function to echo or return the post states as HTML.



Sorgenti

function _post_states( $post, $echo = true ) {
	$post_states        = get_post_states( $post );
	$post_states_string = '';

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

		$post_states_string .= ' — ';
		foreach ( $post_states as $state ) {
			++$i;
			( $i == $state_count ) ? $sep = '' : $sep = ', ';
			$post_states_string          .= "<span class='post-state'>$state$sep</span>";
		}
	}

	if ( $echo ) {
		echo $post_states_string;
	}

	return $post_states_string;
}