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

Try/custom statuses #16705

Closed
wants to merge 3 commits into from
Closed

Try/custom statuses #16705

wants to merge 3 commits into from

Conversation

imath
Copy link
Contributor

@imath imath commented Jul 22, 2019

Description

This is a suggestion to bring custom statuses into the WordPress block editor and contribute to the #3144 issue.

There are 2 commits into this PR. I really think the first one should be considered to be merged as it stops using hardcoded "visibilities" in favor of a new Core/Data Entity: Statuses thanks to the REST route /wp/v2/statuses?context=edit.

I think this first step is important to be able to bring custom statuses into the block editor.

The second commit is trying to actually manage these custom statuses. For instance, if you use this PHP code:

function custom_statuses_register_members_restricted() {
	register_post_status( 'restricted',
		array(
			'label'                     => _x( 'Restricted to members', 'post status', 'text-domain' ),
			'public'                    => true,
			'label_count'               => _n_noop( 'Restricted to members <span class="count">(%s)</span>', 'Restricted to members <span class="count">(%s)</span>', 'text-domain' ),
			'show_in_admin_all_list'    => true,
			'show_in_admin_status_list' => true,
			/* This part is needed by the Block Editor */
			'visibility'                => (object) array(
				'value' => 'restricted',
				'label' => __( 'Restricted to members', 'text-domain' ),
				'info'  => __( 'Only logged in members can view this post.', 'text-domain' ),
			),
		)
	);
}
add_action( 'init', 'custom_statuses_register_members_restricted' );

Here's how the Editor's Post Visibility component will evolve:

try-custom-statuses

How has this been tested?

I've tested the code in WordPress trunk, Gutenberg master and using npm run test-unit to make sure It has no impact on other areas of the Editor.

Screenshots

See above.

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@TimothyBJacobs TimothyBJacobs added the REST API Interaction Related to REST API label Aug 6, 2019
@talldan talldan added the [Type] Enhancement A suggestion for improvement. label Aug 9, 2019
@imath imath requested a review from spacedmonkey as a code owner October 1, 2020 09:40
Base automatically changed from master to trunk March 1, 2021 15:42
@youknowriad
Copy link
Contributor

Doing some repository cleanup. A lot has changed since this PR was open (sorry we didn't get to review it properly on time) but it seems that at this point, if we ever want to get to it, it will need to be redone entirely. So I think it's just better to close it for now. Thanks for the efforts.

@imath imath deleted the try/custom-statuses branch April 26, 2024 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants