Skip to content

Commit

Permalink
Check if a job is being published
Browse files Browse the repository at this point in the history
  • Loading branch information
renatho committed Jul 17, 2023
1 parent 89b8bb5 commit 44add0b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions assets/js/admin/job-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* WordPress dependencies
*/
import { select } from '@wordpress/data';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
*/
import editorLifecycle from './editor-lifecycle';

const coreEditorSelector = select( editorStore );

editorLifecycle( {
onSaveStart: () => {
// Check if status is being changed to publish.
if ( 'publish' === coreEditorSelector.getEditedPostAttribute( 'status' ) && 'publish' !== coreEditorSelector.getCurrentPostAttribute( 'status' ) ) {
const jobId = coreEditorSelector.getCurrentPostId();

console.log( jobId );
}
}
} );

0 comments on commit 44add0b

Please sign in to comment.