Changeset 62953
- Timestamp:
- 07/31/2026 08:41:49 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/general-template.php (modified) (1 diff)
-
tests/phpunit/tests/general/template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/general-template.php
r62816 r62953 1183 1183 $attachment_url = wp_get_attachment_image_url( $site_icon_id, $size_data ); 1184 1184 if ( $attachment_url ) { 1185 $url = $attachment_url;1185 $url = is_ssl() ? set_url_scheme( $attachment_url, 'https' ) : $attachment_url; 1186 1186 } 1187 1187 } -
trunk/tests/phpunit/tests/general/template.php
r62521 r62953 140 140 141 141 /** 142 * Ensures the site icon URL scheme is upgraded for the current request, but never downgraded. 143 * 144 * The site icon is display chrome that also renders in wp-admin and on the 145 * login screen, where wp_get_attachment_image_url() does not correct the scheme. 146 * 147 * On an HTTPS request with an http:// siteurl the icon must still be served 148 * over HTTPS to avoid a broken, mixed-content image. 149 * 150 * @ticket 65696 151 * 152 * @group site_icon 153 * 154 * @covers ::get_site_icon_url 155 * 156 * @requires function imagejpeg 157 */ 158 public function test_get_site_icon_url_scheme() { 159 $this->set_site_icon(); 160 161 set_current_screen( 'dashboard' ); 162 $this->assertTrue( is_admin(), 'Test should run in the admin context.' ); 163 $this->assertFalse( is_ssl(), 'Baseline request should not be detected as SSL.' ); 164 $this->assertStringStartsWith( 'http://', get_site_icon_url(), 'Baseline icon URL should use the HTTP scheme.' ); 165 166 $_SERVER['HTTPS'] = 'on'; 167 $this->assertTrue( is_ssl(), 'Request should now be detected as SSL.' ); 168 $this->assertStringStartsWith( 'https://', get_site_icon_url(), 'Site icon URL should use the HTTPS scheme on an SSL admin request.' ); 169 170 add_filter( 171 'upload_dir', 172 static function ( $uploads ) { 173 $uploads['url'] = set_url_scheme( $uploads['url'], 'https' ); 174 $uploads['baseurl'] = set_url_scheme( $uploads['baseurl'], 'https' ); 175 return $uploads; 176 } 177 ); 178 179 unset( $_SERVER['HTTPS'] ); 180 $this->assertFalse( is_ssl(), 'Request should no longer be detected as SSL.' ); 181 $this->assertStringStartsWith( 'https://', get_site_icon_url(), 'Site icon URL should preserve the HTTPS scheme on a non-SSL request.' ); 182 } 183 184 /** 142 185 * @group site_icon 143 186 * @covers ::site_icon_url
Note:
See TracChangeset
for help on using the changeset viewer.