WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#21655 closed defect (bug) (fixed)

Incorrect URL For Theme Options With Custom Post Type

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

Description

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 7 years ago.
theme-options-section.png (8.8 KB) - added by JarretC 7 years ago.
21655.patch (754 bytes) - added by SergeyBiryukov 7 years ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
7 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:
    http://trunk.wordpress/wp-admin/edit.php?post_type=test
    
  3. Twenty Twelve's Theme Options URL is also correct:
    http://trunk.wordpress/wp-admin/themes.php?page=theme_options
    

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
7 years ago

  • Cc pippin@… added

#3 @JarretC
7 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
7 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:
http://core.trac.wordpress.org/browser/tags/3.4.1/wp-admin/menu-header.php#L96

#5 @JarretC
7 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
7 years ago

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

#7 @nacin
7 years ago

  • Keywords commit added

21655.patch appears good.

#8 @nacin
7 years ago

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

#9 @ryan
7 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.