_media_states

函数
_media_states ( $post, $display = true )
参数
  • (WP_Post) $post The attachment post to retrieve states for.
    Required:
  • (bool) $display Optional. Whether to display the post states as an HTML string. Default true.
    Required:
    Default: true
返回值
  • (string) Media states string.
定义位置
相关方法
get_media_statesget_media_items_media_buttonmedia_buttonsadd_media_page
引入
3.2.0
弃用
-

_media_states: 这个钩子用来为WordPress媒体编辑器中的媒体项目添加状态。

将附件的媒体状态作为HTML输出。

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

常见问题

FAQs
查看更多 >