返回介绍

page_attributes_meta_box()

发布于 2017-09-11 09:52:46 字数 5182 浏览 1039 评论 0 收藏 0

page_attributes_meta_box( object $post )

Display page attributes form fields.


description


参数

$post

(object) (Required)


源代码

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

function page_attributes_meta_box($post) {
	if ( is_post_type_hierarchical( $post->post_type ) ) :
		$dropdown_args = array(
			'post_type'        => $post->post_type,
			'exclude_tree'     => $post->ID,
			'selected'         => $post->post_parent,
			'name'             => 'parent_id',
			'show_option_none' => __('(no parent)'),
			'sort_column'      => 'menu_order, post_title',
			'echo'             => 0,
		);

		/**
		 * Filters the arguments used to generate a Pages drop-down element.
		 *
		 * @since 3.3.0
		 *
		 * @see wp_dropdown_pages()
		 *
		 * @param array   $dropdown_args Array of arguments used to generate the pages drop-down.
		 * @param WP_Post $post          The current WP_Post object.
		 */
		$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
		$pages = wp_dropdown_pages( $dropdown_args );
		if ( ! empty($pages) ) :
?>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="parent_id"><?php _e( 'Parent' ); ?></label></p>
<?php echo $pages; ?>
<?php
		endif; // end empty pages check
	endif;  // end hierarchical check.

	if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
		$template = ! empty( $post->page_template ) ? $post->page_template : false;
		?>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label><?php
	/**
	 * Fires immediately after the label inside the 'Template' section
	 * of the 'Page Attributes' meta box.
	 *
	 * @since 4.4.0
	 *
	 * @param string  $template The template used for the current post.
	 * @param WP_Post $post     The current post.
	 */
	do_action( 'page_attributes_meta_box_template', $template, $post );
?></p>
<select name="page_template" id="page_template">
<?php
/**
 * Filters the title of the default page template displayed in the drop-down.
 *
 * @since 4.1.0
 *
 * @param string $label   The display value for the default page template title.
 * @param string $context Where the option label is displayed. Possible values
 *                        include 'meta-box' or 'quick-edit'.
 */
$default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'meta-box' );
?>
<option value="default"><?php echo esc_html( $default_title ); ?></option>
<?php page_template_dropdown( $template, $post->post_type ); ?>
</select>
<?php endif; ?>
<?php if ( post_type_supports( $post->post_type, 'page-attributes' ) ) : ?>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="menu_order"><?php _e( 'Order' ); ?></label></p>
<input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" />
<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
<p><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p>
<?php endif;
	endif;
}

更新日志

Versiondescription
2.7.0Introduced.

相关函数

Uses

  • wp-admin/includes/meta-boxes.php: page_attributes_meta_box_template
  • wp-admin/includes/meta-boxes.php: default_page_template_title
  • wp-admin/includes/theme.php: get_page_templates()
  • wp-admin/includes/class-wp-screen.php: WP_Screen::get_help_tabs()
  • wp-admin/includes/screen.php: get_current_screen()
  • wp-admin/includes/template.php: page_template_dropdown()
  • wp-admin/includes/meta-boxes.php: page_attributes_dropdown_pages_args
  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: _e()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/formatting.php: esc_attr()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/plugin.php: do_action()
  • wp-includes/option.php: get_option()
  • wp-includes/post-template.php: wp_dropdown_pages()
  • wp-includes/post.php: post_type_supports()
  • wp-includes/post.php: is_post_type_hierarchical()
  • Show 12 more uses Hide more uses

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文