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

Allow resetting the permalink by saving it as empty #6615

Merged
merged 2 commits into from
May 8, 2018

Conversation

pento
Copy link
Member

@pento pento commented May 7, 2018

Description

#6603 reports a permalink workflow from the classic editor that doesn't work in the block editor:

  • Create a post, save it.
  • Change the permalink, save it again.
  • Edit the permalink to be empty, and save it again.

The permalink should be reset to the auto-generated permalink: this should work for both draft and published posts.

This PR makes a few change to support this flow:

  • On post responses from the REST API, rename the draft_slug property to generated_slug, and make it available on all posts, not just drafts.
  • Ensure generated_slug is the generated slug, rather than defaulting to the slug, when that's set.
  • Allow the PostPermalinkEditor to be saved with an empty permalink.

How has this been tested?

To test, run through the workflow with a few variations:

  • With draft and published posts.
  • With hierarchical and non-hierarchical post types (eg, pages and posts).
  • With CPTs.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@pento pento added [Type] Bug An existing feature does not function as intended Core REST API Task Task for Core REST API efforts labels May 7, 2018
@pento pento added this to the 2.9 milestone May 7, 2018
@pento pento self-assigned this May 7, 2018
@pento pento requested a review from a team May 7, 2018 07:09
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and totally works 👍


$response->data['permalink_template'] = $sample_permalink[0];

if ( 'draft' === $post->post_status && ! $post->post_name ) {
$response->data['draft_slug'] = $sample_permalink[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Removing this is technically a breaking change. Since it was added recently and isn't documented, though, my feeling is that it's fine to leave as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, it's only in Gutenberg: there's not even a ticket for adding it to Core yet.

@pento pento merged commit 3d93ac6 into master May 8, 2018
@pento pento deleted the fix/6603-handle-empty-permalinks branch May 8, 2018 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants