Make WordPress Core

Opened 13 years ago

Closed 11 years ago

#18323 closed defect (bug) (fixed)

Screen Options "Show on Screen [n] Posts" for custom post type containing digits in its name does not work

Reported by: vtowel's profile vtowel Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.2.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

  1. In a plugin, write the code to register a custom post type called "all_in_1_event", or any other name that contains a digit.
  2. On the manage screen for that custom post type, reveal the Screen Options.
  3. Enter a new value for the "Show on Screen [n] Posts" field, something other than the default value of 20.
  4. Click "Apply".
  5. Reveal the Screen Options again.
  6. The new value has not been saved.

It seems to be that this is because of a check that occurs in the set_screen_options() function (misc.php, line 331). The option name is not allowed to contain digits - only letters, dashes and underscores - and I don't understand why. Our custom post type does contain a digit, and it has never been a problem for us before - except for saving the Screen Options.

Attachments (2)

18323.patch (485 bytes) - added by SergeyBiryukov 13 years ago.
18323.2.patch (459 bytes) - added by SergeyBiryukov 11 years ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
13 years ago

  • Keywords has-patch added

#2 @danielbachhuber
13 years ago

  • Cc wordpress@… added

#4 @cgrymala
12 years ago

I am using a custom post type named 'class-notes' (notice there are no digits in that label; just letters and a dash), and am experiencing the same issue in WordPress 3.2.1 and the latest nightly build of WordPress 3.3.

#5 @ericlewis
12 years ago

the glitch is confirmed here too, post type 'feed-posts', perhaps it happens for any post type with a dash in it?

#6 @nacin
11 years ago

  • Component changed from Validation to Post Types
  • Milestone changed from Awaiting Review to 3.5

See [21322] #18958 for more history. Looks like we should allow whatever sanitize_key() allows here.

Last edited 11 years ago by nacin (previous) (diff)

#7 @nacin
11 years ago

#18559 was marked as a duplicate.

#8 @SergeyBiryukov
11 years ago

18323.2.patch uses sanitize_key().

#9 @lkraav
11 years ago

  • Cc leho@… added

#10 @ryan
11 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [22253]:

Allow numbers in screen option IDs. Fixes setting posts per page for custom post types containing 0-9. Props SergeyBiryukov. fixes #18323

Note: See TracTickets for help on using tickets.