mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Menus: Trim whitespace from custom link URLs.
Props majemedia, SergeyBiryukov. Fixes #47723. git-svn-id: https://develop.svn.wordpress.org/trunk@45655 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -149,7 +149,7 @@ class Test_Nav_Menus extends WP_UnitTestCase {
|
||||
array(
|
||||
'menu-item-type' => 'custom',
|
||||
'menu-item-title' => 'Wordpress.org',
|
||||
'menu-item-link' => 'http://wordpress.org',
|
||||
'menu-item-url' => 'http://wordpress.org',
|
||||
'menu-item-status' => 'publish',
|
||||
)
|
||||
);
|
||||
@@ -926,4 +926,34 @@ class Test_Nav_Menus extends WP_UnitTestCase {
|
||||
$this->assertContains( 'menu-item-privacy-policy', $classes );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 47723
|
||||
* @dataProvider data_trim_url_for_custom_item
|
||||
*/
|
||||
function test_trim_url_for_custom_item( $custom_url, $correct_url ) {
|
||||
$custom_item_id = wp_update_nav_menu_item(
|
||||
$this->menu_id,
|
||||
0,
|
||||
array(
|
||||
'menu-item-type' => 'custom',
|
||||
'menu-item-title' => 'WordPress.org',
|
||||
'menu-item-url' => $custom_url,
|
||||
'menu-item-status' => 'publish',
|
||||
)
|
||||
);
|
||||
|
||||
$custom_item = wp_setup_nav_menu_item( get_post( $custom_item_id ) );
|
||||
$this->assertEquals( $correct_url, $custom_item->url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for test_trim_url_for_custom_item().
|
||||
*/
|
||||
function data_trim_url_for_custom_item() {
|
||||
return array(
|
||||
array( 'https://wordpress.org ', 'https://wordpress.org' ),
|
||||
array( ' https://wordpress.org', 'https://wordpress.org' ),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user