Skip to content

Commit 25b3bbd

Browse files
committed
Merge remote-tracking branch 'upstream/trunk' into trunk
2 parents 99f64f3 + cb22425 commit 25b3bbd

4 files changed

Lines changed: 167 additions & 6 deletions

File tree

package-lock.json

Lines changed: 32 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"jquery-form": "4.3.0",
100100
"jquery-hoverintent": "1.10.2",
101101
"jsonlint": "1.6.3",
102-
"lodash": "4.17.23",
102+
"lodash": "4.18.1",
103103
"masonry-layout": "4.2.2",
104104
"moment": "2.30.1",
105105
"objectFitPolyfill": "2.3.5",

src/wp-includes/script-loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function wp_default_packages_vendor( $scripts ) {
111111
'react-jsx-runtime' => '18.3.1',
112112
'regenerator-runtime' => '0.14.1',
113113
'moment' => '2.30.1',
114-
'lodash' => '4.17.23',
114+
'lodash' => '4.18.1',
115115
'wp-polyfill-fetch' => '3.6.20',
116116
'wp-polyfill-formdata' => '4.0.10',
117117
'wp-polyfill-node-contains' => '4.8.0',
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
3+
/**
4+
* @group admin
5+
*
6+
* @covers ::wp_admin_canonical_url
7+
*/
8+
class Tests_Admin_Includes_Misc_WpAdminCanonicalUrl_Test extends WP_UnitTestCase {
9+
10+
/**
11+
* Original `$_SERVER` values.
12+
*
13+
* @var array
14+
*/
15+
private $server_orig;
16+
17+
public function set_up() {
18+
parent::set_up();
19+
20+
$this->server_orig = $_SERVER;
21+
}
22+
23+
public function tear_down() {
24+
$_SERVER = $this->server_orig;
25+
26+
parent::tear_down();
27+
}
28+
29+
/**
30+
* Tests wp_admin_canonical_url().
31+
*
32+
* @ticket 65192
33+
*
34+
* @dataProvider data_wp_admin_canonical_url
35+
*
36+
* @param array $server_vars `$_SERVER` variables to set.
37+
* @param string $expected Expected output substring.
38+
*/
39+
public function test_wp_admin_canonical_url( array $server_vars, $expected ) {
40+
foreach ( $server_vars as $key => $value ) {
41+
$_SERVER[ $key ] = $value;
42+
}
43+
44+
ob_start();
45+
wp_admin_canonical_url();
46+
$output = ob_get_clean();
47+
48+
$this->assertStringContainsString( $expected, $output );
49+
$this->assertStringContainsString( '<script>', $output );
50+
}
51+
52+
/**
53+
* Data provider for test_wp_admin_canonical_url().
54+
*
55+
* @return array<string, array{
56+
* server_vars: array<string, string>,
57+
* expected: string
58+
* }>
59+
*/
60+
public function data_wp_admin_canonical_url(): array {
61+
return array(
62+
'no removable query args' => array(
63+
'server_vars' => array(
64+
'HTTP_HOST' => 'example.org',
65+
'REQUEST_URI' => '/wp-admin/index.php',
66+
),
67+
'expected' => 'href="http://example.org/wp-admin/index.php"',
68+
),
69+
'removable query args' => array(
70+
'server_vars' => array(
71+
'HTTP_HOST' => 'example.org',
72+
'REQUEST_URI' => '/wp-admin/index.php?settings-updated=true&other=arg',
73+
),
74+
'expected' => 'href="http://example.org/wp-admin/index.php?other=arg"',
75+
),
76+
'multiple removable query args' => array(
77+
'server_vars' => array(
78+
'HTTP_HOST' => 'example.org',
79+
'REQUEST_URI' => '/wp-admin/edit.php?trashed=1&locked=1&paged=2',
80+
),
81+
'expected' => 'href="http://example.org/wp-admin/edit.php?paged=2"',
82+
),
83+
'https' => array(
84+
'server_vars' => array(
85+
'HTTP_HOST' => 'example.org',
86+
'REQUEST_URI' => '/wp-admin/index.php',
87+
'HTTPS' => 'on',
88+
),
89+
'expected' => 'href="https://example.org/wp-admin/index.php"',
90+
),
91+
);
92+
}
93+
94+
/**
95+
* Tests wp_admin_canonical_url() when removable query args are filtered to be empty.
96+
*
97+
* @ticket 65192
98+
*/
99+
public function test_wp_admin_canonical_url_with_empty_removable_args() {
100+
add_filter( 'removable_query_args', '__return_empty_array' );
101+
102+
ob_start();
103+
wp_admin_canonical_url();
104+
$output = ob_get_clean();
105+
106+
remove_filter( 'removable_query_args', '__return_empty_array' );
107+
108+
$this->assertEmpty( $output, 'Output should be empty when removable query args are filtered to be empty.' );
109+
}
110+
111+
/**
112+
* Tests the `wp_admin_canonical_url` filter.
113+
*
114+
* @ticket 65192
115+
*/
116+
public function test_wp_admin_canonical_url_filter() {
117+
$_SERVER['HTTP_HOST'] = 'example.org';
118+
$_SERVER['REQUEST_URI'] = '/wp-admin/index.php?settings-updated=true';
119+
120+
add_action(
121+
'wp_admin_canonical_url',
122+
static function () {
123+
return 'https://custom.example.org/canonical';
124+
}
125+
);
126+
127+
ob_start();
128+
wp_admin_canonical_url();
129+
$output = ob_get_clean();
130+
131+
$this->assertStringContainsString( 'href="https://custom.example.org/canonical"', $output );
132+
}
133+
}

0 commit comments

Comments
 (0)