post_format_meta_box() - WordPress 函数参考中文文档

返回介绍

post_format_meta_box()

发布于 2017-09-11 字数3487 浏览 840 评论 0

post_format_meta_box( WP_Post $post,  array $box )

Display post format form elements.


描述


参数

$post

(WP_Post)
(Required)
Post object.

$box

(array)
(Required)
Post formats meta box arguments.

  • ‘id’
    (string) Meta box ‘id’ attribute.
  • ‘title’
    (string) Meta box title.
  • ‘callback’
    (callable) Meta box display callback.
  • ‘args’
    (array) Extra meta box arguments.

源代码

File: wp-admin/includes/meta-boxes.php

function post_format_meta_box( $post, $box ) {
	if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
	$post_formats = get_theme_support( 'post-formats' );

	if ( is_array( $post_formats[0] ) ) :
		$post_format = get_post_format( $post->ID );
		if ( !$post_format )
			$post_format = '0';
		// Add in the current one if it isn't there yet, in case the current theme doesn't support it
		if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
			$post_formats[0][] = $post_format;
	?>
	<div id="post-formats-select">
		<fieldset>
			<legend class="screen-reader-text"><?php _e( 'Post Formats' ); ?></legend>
			<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0" class="post-format-icon post-format-standard"><?php echo get_post_format_string( 'standard' ); ?></label>
			<?php foreach ( $post_formats[0] as $format ) : ?>
			<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>" class="post-format-icon post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
			<?php endforeach; ?>
		</fieldset>
	</div>
	<?php endif; endif;
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/theme.php:
    current_theme_supports()
  • wp-includes/theme.php:
    get_theme_support()
  • wp-includes/l10n.php:
    _e()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/formatting.php:
    esc_html()
  • wp-includes/general-template.php:
    checked()
  • wp-includes/post.php:
    post_type_supports()
  • wp-includes/post-formats.php:
    get_post_format()
  • wp-includes/post-formats.php:
    get_post_format_string()
  • Show 4 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!