Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix setting initial status in Gutenberg #521

Merged
merged 6 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion blocks/dist/custom-status.build.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion blocks/src/custom-status/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './style.scss';
let { __ } = wp.i18n;
let { PluginPostStatusInfo } = wp.editPost;
let { registerPlugin } = wp.plugins;
let { withSelect, withDispatch } = wp.data;
let { subscribe, dispatch, select, withSelect, withDispatch } = wp.data;
let { compose } = wp.compose;
let { SelectControl } = wp.components;

Expand All @@ -24,6 +24,15 @@ let sideEffectL10nManipulation = status => {
}
}

// Set the status to the default custom status.
subscribe(function () {
var status = select('core/editor').getEditedPostAttribute('status');
if ( typeof status !== 'undefined' && status !== 'publish' ) {
sideEffectL10nManipulation( getStatusLabel( status ) );
}
})
dispatch('core/editor').editPost( { status: ef_default_custom_status });

/**
* Custom status component
* @param object props
Expand Down