Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19465 closed defect (bug) (duplicate)

'Show on screen' (per_page) options don't save for certain custom taxonomies

Reported by: jolley_small's profile jolley_small Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: Administration Keywords:
Focuses: Cc:


I've identified 2 situations where the screen options don't save (per_page) when administrating custom taxonomies:

1) When a taxonomy's name contains an integer
2) When a taxonomy's name contains a hyphen (-)

The first issue is due to a line in misc.php set_screen_options():

if ( !preg_match( '/^[a-z_-]+$/', $option ) )

This returns (not saving the option) if the taxonomy contains numbers. This preg_match should be expanded to also allow integers.

The second issue is due to this line in the same function:

$option = str_replace('-', '_', $option);

That replaces hyphens with underscores, which would be fine, however, the function in screen.php (render_per_page_options) which loads the options contains this:

$option = $this->get_option( 'per_page', 'option' );
		if ( ! $option )
			$option = str_replace( '-', '_', "{$this->id}_per_page" );

In my test cases $option was loaded by the first part, meaning the hyphen to underscore replacement never occurred, thus the saved per_page option was not loaded and the default value of 20 was used instead.

Change History (3)

#1 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#2 @jolley_small
12 years ago

Just to point out the issue I raised was with the taxonomies and not CPT, and that the preg_match issue in my description is not covered in the other ticket...

#3 @SergeyBiryukov
12 years ago

preg_match() issue is covered in #18323.

Note: See TracTickets for help on using tickets.