Make WordPress Core


Ignore:
Timestamp:
11/27/2016 03:04:35 AM (10 years ago)
Author:
westonruter
Message:

Customize: Fix logic for previewing the URL for nav_menu_item settings for terms and post type archives.

Fixes typo in args passed to get_term_link() which caused a fatal error due to this call returning a WP_Error which was set to url. Also fixes never-satisfiable condition for obtaining post type archive URL. Also ensures that WP_Error never leaks through as url by setting it to an empty string. Adds missing unit tests.

Amends [38991].
See #38114.
Fixes #38945.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    r39345 r39365  
    605605
    606606                // Ensure nav menu item URL is set according to linked object.
    607                 if ( ! empty( $post->object_id ) ) {
    608                         if ( 'post_type' === $post->type ) {
    609                                 $post->url = get_permalink( $post->object_id );
    610                         } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
    611                                 $post->url = get_post_type_archive_link( $post->object );
    612                         } elseif ( 'taxonomy' == $post->type && ! empty( $post->object ) ) {
    613                                 $post->url = get_term_link( (int) $post->object, $post->object );
    614                         }
     607                if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) {
     608                        $post->url = get_permalink( $post->object_id );
     609                } elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) {
     610                        $post->url = get_term_link( (int) $post->object_id, $post->object );
     611                } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
     612                        $post->url = get_post_type_archive_link( $post->object );
     613                }
     614                if ( is_wp_error( $post->url ) ) {
     615                        $post->url = '';
    615616                }
    616617
Note: See TracChangeset for help on using the changeset viewer.