Changeset 36859
- Timestamp:
- 03/05/2016 10:56:31 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r36709 r36859 768 768 769 769 $menu_item->type_label = __( 'Post Type Archive' ); 770 $menu_item->description = ''; 770 $post_content = wp_trim_words( $menu_item->post_content, 200 ); 771 $post_type_description = '' == $post_content ? $object->description : $post_content; 771 772 $menu_item->url = get_post_type_archive_link( $menu_item->object ); 772 773 } elseif ( 'taxonomy' == $menu_item->type ) { -
trunk/tests/phpunit/tests/post/nav-menu.php
r35736 r36859 181 181 $this->assertEquals( $nav_menus_names, $expected_nav_menus_names ); 182 182 } 183 184 /** 185 * @ticket 35324 186 */ 187 function test_wp_setup_nav_menu_item_for_post_type_archive() { 188 189 $post_type_slug = rand_str( 12 ); 190 $post_type_description = rand_str(); 191 register_post_type( $post_type_slug ,array( 192 'public' => true, 193 'has_archive' => true, 194 'description' => $post_type_description, 195 'label' => $post_type_slug 196 )); 197 198 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 199 'menu-item-type' => 'post_type_archive', 200 'menu-item-object' => $post_type_slug, 201 'menu-item-description' => $post_type_description, 202 'menu-item-status' => 'publish' 203 ) ); 204 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 205 206 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 207 $this->assertEquals( $post_type_description , $post_type_archive_item->description ); 208 } 209 210 /** 211 * @ticket 35324 212 */ 213 function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() { 214 215 $post_type_slug = rand_str( 12 ); 216 $post_type_description = ''; 217 register_post_type( $post_type_slug ,array( 218 'public' => true, 219 'has_archive' => true, 220 'label' => $post_type_slug 221 )); 222 223 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 224 'menu-item-type' => 'post_type_archive', 225 'menu-item-object' => $post_type_slug, 226 'menu-item-status' => 'publish' 227 ) ); 228 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 229 230 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 231 $this->assertEquals( $post_type_description , $post_type_archive_item->description ); //fail!!! 232 } 233 234 /** 235 * @ticket 35324 236 */ 237 function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() { 238 239 $post_type_slug = rand_str( 12 ); 240 $post_type_description = rand_str(); 241 register_post_type( $post_type_slug ,array( 242 'public' => true, 243 'has_archive' => true, 244 'description' => $post_type_description, 245 'label' => $post_type_slug 246 )); 247 248 $menu_item_description = rand_str(); 249 250 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 251 'menu-item-type' => 'post_type_archive', 252 'menu-item-object' => $post_type_slug, 253 'menu-item-description' => $menu_item_description, 254 'menu-item-status' => 'publish' 255 ) ); 256 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 257 258 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 259 $this->assertEquals( $menu_item_description , $post_type_archive_item->description ); 260 } 183 261 }
Note: See TracChangeset
for help on using the changeset viewer.