Opened 2 years ago

Last modified 2 years ago

#17906 new enhancement

Refactor submit box code

Reported by: scribu Owned by:
Priority: normal Milestone: Future Release
Component: Administration Version:
Severity: normal Keywords: has-patch 3.3-early
Cc:

Description

The code for the post submit metabox is a mess. It should be cleaned up, so that changes such as #17028 can be done more easily.

Will post a patch shortly.

Attachments (2)

17906.diff (6.0 KB) - added by scribu 2 years ago.
first pass
17906.2.diff (6.1 KB) - added by scribu 2 years ago.

Download all attachments as: .zip

Change History (12)

scribu2 years ago

first pass

  • Keywords has-patch 3.3-early added

In your patch, the posts_status dropdown option value for future gets changed from future to publish.

(Some code standards whitespace missing in the first two green blocks too.)

scribu2 years ago

A very good catch. See 17906.2.diff.

I noticed a similar bug in the current code, where private posts get the status 'publish':

<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>

I noticed that too, but assumed that privately published or publicly published posts still had the same post_status (I was only checking your patch, not the wider code).

Thinking slightly wider (may be out of scope for this ticket), as the $status_labels are likely used elsewhere (Quick Edit for instance), could the array be wrapped in a function and placed somewhere suitable so all instances of post status labels could access it?

Actually, I was thinking of moving them to their respective post status object label array.

After grepping through the source code, these strings seem to be specific to the submit box. The only other place where the 'Privately Published' string appears, for example, is in wp-includes/script-loader.php.

wp-admin/includes/class-wp-posts-list-table.php includes similar strings for the Quick Edit - the question to ask might be why is there an inconsistent use of "Private" in one place and "Privately Published" in another, which makes code un-DRY and makes more work for translators.

Related: #12706

There's still a bug in my patch, related to setting a password for a post. It reverts to private.

One way to simplify the logic would be to completely separate visibility from status.

So, you would have statuses, related to editorial flow:

  • draft
  • pending
  • published
  • scheduled

And visibility:

  • public
  • private
  • password protected

Thus, you could have private drafts etc.

Note: See TracTickets for help on using tickets.