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 for 4.7. Built from https://develop.svn.wordpress.org/branches/4.7@39366 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
acd9d9fad3
commit
a8ef25ce7b
|
@ -604,14 +604,15 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
}
|
||||
|
||||
// Ensure nav menu item URL is set according to linked object.
|
||||
if ( ! empty( $post->object_id ) ) {
|
||||
if ( 'post_type' === $post->type ) {
|
||||
$post->url = get_permalink( $post->object_id );
|
||||
} elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
|
||||
$post->url = get_post_type_archive_link( $post->object );
|
||||
} elseif ( 'taxonomy' == $post->type && ! empty( $post->object ) ) {
|
||||
$post->url = get_term_link( (int) $post->object, $post->object );
|
||||
}
|
||||
if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) {
|
||||
$post->url = get_permalink( $post->object_id );
|
||||
} elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) {
|
||||
$post->url = get_term_link( (int) $post->object_id, $post->object );
|
||||
} elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
|
||||
$post->url = get_post_type_archive_link( $post->object );
|
||||
}
|
||||
if ( is_wp_error( $post->url ) ) {
|
||||
$post->url = '';
|
||||
}
|
||||
|
||||
/** This filter is documented in wp-includes/nav-menu.php */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-RC1-39358';
|
||||
$wp_version = '4.7-RC1-39366';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue