Skip to content

Commit

Permalink
Trigger an editor.beforeAutosave before autosaving
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed Jan 5, 2018
1 parent 87c6aad commit 58a498f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions editor/utils/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import {
toggleAutosave,
} from '../store/actions';

/**
* WordPress dependencies
*/
import { doAction } from '@wordpress/hooks';


export function setupHeartbeat() {
const $document = jQuery( document );
/**
Expand Down Expand Up @@ -97,6 +103,8 @@ export function setupHeartbeat() {
$document.trigger( 'wpcountwords', [ postData.content ] )
.trigger( 'before-autosave', [ postData ] );

// Trigger a hook action.
doAction( 'editor.beforeAutosave', postData );

// Add the nonce to validate the request.
postData._wpnonce = jQuery( '#_wpnonce' ).val() || '';
Expand Down

0 comments on commit 58a498f

Please sign in to comment.