Customizer: Ensure that a newly-added nav menu item gets the Original link populated in its control.
Props valendesigns. Fixes #32858. git-svn-id: https://develop.svn.wordpress.org/trunk@33089 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0f7208a1ee
commit
1b02636793
@ -120,7 +120,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'post_type',
|
||||
'type_label' => get_post_type_object( $post->post_type )->labels->singular_name,
|
||||
'object' => $post->post_type,
|
||||
'object_id' => (int) $post->ID,
|
||||
'object_id' => intval( $post->ID ),
|
||||
'url' => get_permalink( intval( $post->ID ) ),
|
||||
);
|
||||
}
|
||||
} elseif ( 'taxonomy' === $obj_type ) {
|
||||
@ -147,7 +148,8 @@ final class WP_Customize_Nav_Menus {
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
|
||||
'object' => $term->taxonomy,
|
||||
'object_id' => $term->term_id,
|
||||
'object_id' => intval( $term->term_id ),
|
||||
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -228,11 +230,12 @@ final class WP_Customize_Nav_Menus {
|
||||
}
|
||||
$results[] = array(
|
||||
'id' => 'post-' . $post->ID,
|
||||
'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
|
||||
'type' => 'post_type',
|
||||
'type_label' => $post_type_objects[ $post->post_type ]->labels->singular_name,
|
||||
'object' => $post->post_type,
|
||||
'object_id' => intval( $post->ID ),
|
||||
'title' => html_entity_decode( $post_title, ENT_QUOTES, get_bloginfo( 'charset' ) ),
|
||||
'url' => get_permalink( intval( $post->ID ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -250,11 +253,12 @@ final class WP_Customize_Nav_Menus {
|
||||
foreach ( $terms as $term ) {
|
||||
$results[] = array(
|
||||
'id' => 'term-' . $term->term_id,
|
||||
'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( $term->taxonomy )->labels->singular_name,
|
||||
'object' => $term->taxonomy,
|
||||
'object_id' => intval( $term->term_id ),
|
||||
'title' => html_entity_decode( $term->name, ENT_QUOTES, get_bloginfo( 'charset' ) ),
|
||||
'url' => get_term_link( intval( $term->term_id ), $term->taxonomy ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,12 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
$expected = array(
|
||||
'id' => 'post-' . $post_id,
|
||||
'title' => html_entity_decode( get_the_title( $post_id ) ),
|
||||
'type' => 'post_type',
|
||||
'type_label' => get_post_type_object( 'post' )->labels->singular_name,
|
||||
'object' => 'post',
|
||||
'object_id' => intval( $post_id ),
|
||||
'title' => html_entity_decode( get_the_title( $post_id ) ),
|
||||
'url' => get_permalink( intval( $post_id ) ),
|
||||
);
|
||||
wp_set_object_terms( $post_id, $term_ids, 'category' );
|
||||
$search = $post_id === $post_ids[0] ? 'test & search' : 'other title';
|
||||
@ -115,11 +116,12 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
|
||||
$term = get_term_by( 'id', $term_id, 'category' );
|
||||
$expected = array(
|
||||
'id' => 'term-' . $term_id,
|
||||
'title' => $term->name,
|
||||
'type' => 'taxonomy',
|
||||
'type_label' => get_taxonomy( 'category' )->labels->singular_name,
|
||||
'object' => 'category',
|
||||
'object_id' => intval( $term_id ),
|
||||
'title' => $term->name,
|
||||
'url' => get_term_link( intval( $term_id ), 'category' ),
|
||||
);
|
||||
$s = sanitize_text_field( wp_unslash( $term->name ) );
|
||||
$results = $menus->search_available_items_query( array( 'pagenum' => 1, 's' => $s ) );
|
||||
|
Loading…
Reference in New Issue
Block a user