Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21655 closed defect (bug) (fixed)

Incorrect URL For Theme Options With Custom Post Type

Reported by: jarretc's profile jarretc Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Themes Keywords: has-patch needs-testing commit
Focuses: Cc:


Steps to reproduce:

  1. Register a custom post type or any other item that gets added to the Options menu under Appearance->Themes(themes.php)
  2. Set CPT show_in_menu value to themes.php or require capability edit_theme_options
  3. View link in Appearance->Themes(themes.php) under the Options row for current active theme

Patch adds a check to see if edit_theme_options is used and if not, then remove the themes.php?page= that gets added to the URL.

Attachments (3)

edit_theme_options-check.patch (651 bytes) - added by jarretc 12 years ago.
theme-options-section.png (8.8 KB) - added by JarretC 12 years ago.
21655.patch (754 bytes) - added by SergeyBiryukov 12 years ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
12 years ago

Couldn't reproduce on a clean install with Twenty Twelve.

My steps:

  1. Created the post type:
    register_post_type( 'test', array(
    	'label' => 'Test',
    	'public' => true, 
    	'show_in_menu' => 'themes.php',
    	'capability_type' => 'post',
    ) );
  2. The URL under Appearance → Test is correct:
  3. Twenty Twelve's Theme Options URL is also correct:

If I set capability_type to 'edit_theme_options', Appearance → Test item doesn't appear at all, Twenty Twelve's Theme Options URL is still correct.

Is there anything I'm missing? Could you paste the code that causes the issue?

#2 @mordauk
12 years ago

  • Cc pippin@… added

#3 @JarretC
12 years ago

This doesn't have anything to do with the Appearance->Test URL. It has to do with the URL on the Appearance->Themes page.

See attached screenshot for the area I'm referring to.

This is the exact code that I have in Twentytwelve functions.php...

function jarret_test() {
register_post_type( 'test', array(
	'label' => 'Test',
	'public' => true,
	'show_in_menu' => 'themes.php',
	) );
add_action('init', 'jarret_test');

#4 @SergeyBiryukov
12 years ago

Ah, I see. Another option (implemented in 21655.patch) would probably be to check if the parent file exists, like we already do in several places in menu-header.php:

#5 @JarretC
12 years ago

Ok, well you know way more than I do so I'm sure that your patch will/does cover a lot more cases than mine.

#6 @SergeyBiryukov
12 years ago

  • Component changed from Administration to Themes
  • Milestone changed from Awaiting Review to 3.5

#7 @nacin
12 years ago

  • Keywords commit added

21655.patch appears good.

#8 @nacin
12 years ago

  • Owner set to ryan
  • Status changed from new to assigned

#9 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In [21969]:

Fix CPT links in Theme Options list. Props SergeyBiryukov, JarretC. fixes #21655

Note: See TracTickets for help on using tickets.