Opened 9 years ago
Closed 9 years ago
#35324 closed defect (bug) (fixed)
Post Type Archives support in Nav Menus cannot read description
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Menus | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Saved description data for post type archive nav menu items will be overwritten by empty.
This has been happend since #16075
Attachments (9)
Change History (24)
#4
@
9 years ago
To the description, post type description should be input by default.
<?php class SampleTest extends WP_UnitTestCase { /** * @var int */ public $menu_id; function setUp() { parent::setUp(); $this->menu_id = wp_create_nav_menu( rand_str() ); } function test_wp_setup_nav_menu_item_for_post_type_archive() { $post_type_slug = rand_str( 12 ); $post_type_description = rand_str(); register_post_type( $post_type_slug ,array( 'public' => true, 'has_archive' => true, 'description' => $post_type_description, 'label' => $post_type_slug )); $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 'menu-item-type' => 'post_type_archive', 'menu-item-object' => $post_type_slug, 'menu-item-status' => 'publish' ) ); $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); $this->assertEquals( $post_type_description , $post_type_archive_item->description ); //fail!!! } }
Add new patch and Detailed test.
#7
@
9 years ago
Thanks Toro_Unit for unit test!
I like your approach, but if CPT has own description, your function will overwrite menu item description even though I want to leave it empty.
Can we fix a bug this time and discuss it at new ticket?
#10
@
9 years ago
For anyone who is faced with this bug:
I made a plugin to fix this bug. Try this until the patch is merged.
https://gist.github.com/mayukojpn/6ef62c39dcf48c17ed96
#13
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
36859 throws a notice when an archive menu item exists for a post type that is no longer registered. 35324.7.diff prevents the notice and adds a test for unregistered post types.
#14
@
9 years ago
35324.7.diff looks good, thanks @bradyvercher.
The words I added here and saved cannot read.