返回介绍

post_submit_meta_box()

发布于 2017-09-11 09:57:33 字数 5400 浏览 986 评论 0 收藏 0

post_submit_meta_box( WP_Post $post,  array $args = array() )

Displays post submit form fields.


description


参数

$post

(WP_Post) (Required) Current post object.

$args

(array) (Optional) Array of arguments for building the post submit meta box.

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

Default value: array()


源代码

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

function post_submit_meta_box( $post, $args = array() ) {
	global $action;

	$post_type = $post->post_type;
	$post_type_object = get_post_type_object($post_type);
	$can_publish = current_user_can($post_type_object->cap->publish_posts);
?>
<div class="submitbox" id="submitpost">

<div id="minor-publishing">

<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
<div style="display:none;">
<?php submit_button( __( 'Save' ), '', 'save' ); ?>
</div>

<div id="minor-publishing-actions">
<div id="save-action">
<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" class="button" />
<span class="spinner"></span>
<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
<input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" class="button" />
<span class="spinner"></span>
<?php } ?>
</div>
<?php if ( is_post_type_viewable( $post_type_object ) ) : ?>
<div id="preview-action">
<?php
$preview_link = esc_url( get_preview_post_link( $post ) );
if ( 'publish' == $post->post_status ) {
	$preview_button_text = __( 'Preview Changes' );
} else {
	$preview_button_text = __( 'Preview' );
}

$preview_button = sprintf( '%1$s<span class="screen-reader-text"> %2$s</span>',
	$preview_button_text,
	/* translators: accessibility text */
	__( '(opens in a new window)' )
);
?>
<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview-<?php echo (int) $post->ID; ?>" id="post-preview"><?php echo $preview_button; ?></a>
<input type="hidden" name="wp-preview" id="wp-preview" value="" />
</div>
<?php endif; // public post type ?>
<?php
/**
 * Fires before the post time/date setting in the Publish meta box.
 *
 * @since 4.4.0
 *
 * @param WP_Post $post WP_Post object for the current post.
 */
do_action( 'post_submitbox_minor_actions', $post );
?>
<div class="clear"></div>
</div><!--

更新日志

Versiondescription
2.7.0Introduced.

相关函数

Uses

  • wp-includes/link-template.php: get_preview_post_link()
  • wp-includes/post.php: is_post_type_viewable()
  • wp-admin/includes/meta-boxes.php: post_submitbox_minor_actions
  • wp-admin/includes/template.php: submit_button()
  • wp-admin/includes/template.php: touch_time()
  • wp-admin/includes/meta-boxes.php: post_submitbox_misc_actions
  • wp-admin/includes/meta-boxes.php: post_submitbox_start
  • wp-includes/capabilities.php: current_user_can()
  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: esc_attr_e()
  • wp-includes/l10n.php: _e()
  • wp-includes/l10n.php: _ex()
  • wp-includes/formatting.php: esc_url()
  • wp-includes/formatting.php: esc_attr()
  • wp-includes/formatting.php: esc_html()
  • wp-includes/general-template.php: selected()
  • wp-includes/general-template.php: checked()
  • wp-includes/functions.php: date_i18n()
  • wp-includes/functions.php: number_format_i18n()
  • wp-includes/functions.php: current_time()
  • wp-includes/link-template.php: get_edit_post_link()
  • wp-includes/link-template.php: get_delete_post_link()
  • wp-includes/plugin.php: do_action()
  • wp-includes/post.php: is_sticky()
  • wp-includes/post.php: get_post_type_object()
  • Show 20 more uses Hide more uses

User Contributed Notes

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

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

发布评论

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