wpseek.com
A WordPress-centric search engine for devs and theme authors
heartbeat_autosave › WordPress Function
Since3.9.0
Deprecatedn/a
› heartbeat_autosave ( $response, $data )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Performs autosave with heartbeat.
Related Functions: wp_create_post_autosave, wp_get_post_autosave, wp_heartbeat_settings, wp_autosave, get_author_name
Source
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://www.php.net/manual/datetime.format.php */ $draft_saved_date_format = __( 'g:i:s a' ); $response['wp_autosave'] = array( 'success' => true, /* translators: %s: Date and time. */ 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ), ); } } return $response; }