WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 18 months 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 Owned by: 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 3 years ago.
18323.2.patch (459 bytes) - added by SergeyBiryukov 19 months ago.

Download all attachments as: .zip

Change History (12)

SergeyBiryukov3 years ago

comment:1 SergeyBiryukov3 years ago

  • Keywords has-patch added

comment:2 danielbachhuber3 years ago

  • Cc wordpress@… added

comment:4 cgrymala2 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.

comment:5 ericlewis2 years ago

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

comment:6 nacin19 months 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 19 months ago by nacin (previous) (diff)

comment:7 nacin19 months ago

#18559 was marked as a duplicate.

SergeyBiryukov19 months ago

comment:8 SergeyBiryukov19 months ago

18323.2.patch uses sanitize_key().

comment:9 lkraav18 months ago

  • Cc leho@… added

comment:10 ryan18 months 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.