Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom validation by allowing bypass of the Publish/Update button saving process #49811

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/editor/src/components/post-publish-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from '@wordpress/components';
import { Component, createRef } from '@wordpress/element';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { applyFilters } from '@wordpress/hooks';

/**
* Internal dependencies
Expand Down Expand Up @@ -157,9 +158,15 @@ export class PostPublishButton extends Component {
}

const onClickButton = () => {
// Allow for overriding saving for custom validations.
if ( ! applyFilters( 'editor.PostPublishButton.shouldSubmit', true, this.props, publishStatus ) ) {
return;
}

if ( isButtonDisabled ) {
return;
}

onSubmit();
savePostStatus( publishStatus );
};
Expand Down
Loading