mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 15:47:05 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@39365 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user