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

返回介绍

heartbeat_autosave()

发布于 2017-09-11 字数1903 浏览 884 评论 0

heartbeat_autosave( array $response,  array $data )

Autosave with heartbeat


描述


参数

$response

(array)
(Required)
The Heartbeat response.

$data

(array)
(Required)
The $_POST data sent.


返回值

(array) The Heartbeat response.


源代码

File: wp-admin/includes/misc.php

function heartbeat_autosave( $response, $data ) {
	if ( ! empty( $data['wp_autosave'] ) ) {
		$saved = wp_autosave( $data['wp_autosave'] );

		if ( is_wp_error( $saved ) ) {
			$response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() );
		} elseif ( empty( $saved ) ) {
			$response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) );
		} else {
			/* translators: draft saved date format, see https://secure.php.net/date */
			$draft_saved_date_format = __( 'g:i:s a' );
			/* translators: %s: date and time */
			$response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) );
		}
	}

	return $response;
}

更新日志

Version 描述
3.9.0 Introduced.

相关函数

Uses

  • wp-admin/includes/post.php:
    wp_autosave()
  • wp-includes/l10n.php:
    __()
  • wp-includes/functions.php:
    date_i18n()
  • wp-includes/load.php:
    is_wp_error()

User Contributed Notes

上一篇:header_textcolor()

下一篇:hello_dolly()

发布评论

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

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