Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#17906 closed enhancement (maybelater)

Refactor submit box code

Reported by: scribu's profile scribu Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: 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 13 years ago.
first pass
17906.2.diff (6.1 KB) - added by scribu 13 years ago.

Download all attachments as: .zip

Change History (15)

@scribu
13 years ago

first pass

#1 @scribu
13 years ago

  • Keywords has-patch 3.3-early added

#2 @GaryJ
13 years ago

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.)

@scribu
13 years ago

#3 @scribu
13 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>

#4 @GaryJ
13 years ago

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?

#5 @scribu
13 years ago

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

#6 @scribu
13 years ago

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.

#7 @GaryJ
13 years ago

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.

#8 @scribu
13 years ago

Related: #12706

#9 @scribu
13 years ago

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

#10 @scribu
13 years ago

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.

#11 in reply to: ↑ description @c3mdigital
11 years ago

  • Keywords 3.3-early removed
  • Resolution set to maybelater
  • Status changed from new to closed

Replying to scribu:

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.

I agree this is a mess but while there are logic improvements this is mostly refactoring for coding standards and readability and there has been no activity in 2 years. See: http://make.wordpress.org/core/2011/03/23/code-refactoring/

#12 @nacin
11 years ago

I do like the gist of 17906.2.diff but this no longer applies cleanly and likely needs some other tweaks.

#13 @SergeyBiryukov
11 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.