Changeset 3743505 for optimazz/trunk/includes/Core/Paths.php
- Timestamp:
- 10/13/2026 10:00:51 AM (2 weeks ago)
- File:
-
- 1 edited
-
optimazz/trunk/includes/Core/Paths.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
optimazz/trunk/includes/Core/Paths.php
r3617648 r3743505 25 25 public static function url_to_path( $url ) { 26 26 $host = wp_parse_url( $url, PHP_URL_HOST ); 27 if ( 'c0.wp.com' === $host ) { 28 return self::jetpack_core_path( $url ); 29 } 27 30 if ( $host && $host !== wp_parse_url( home_url(), PHP_URL_HOST ) ) { 28 31 return ''; … … 48 51 return ABSPATH . ltrim( $path, '/' ); 49 52 } 53 54 /** 55 * Jetpack's Site Accelerator serves WordPress core files from 56 * c0.wp.com/c/<version>/wp-includes/… . When that version is the one 57 * installed here, the file is identical to our own copy, so it can be 58 * minified, combined and loaded without blocking like any local file — 59 * otherwise these core stylesheets stay render-blocking on every page. 60 * 61 * @param string $url c0.wp.com URL. 62 * @return string Local path, or '' when it is not a matching core file. 63 */ 64 private static function jetpack_core_path( $url ) { 65 $path = (string) wp_parse_url( strtok( (string) $url, '?' ), PHP_URL_PATH ); 66 if ( false !== strpos( $path, '..' ) || ! preg_match( '#^/c/([^/]+)/((?:wp-includes|wp-admin)/.+)$#', $path, $m ) ) { 67 return ''; 68 } 69 if ( $m[1] !== get_bloginfo( 'version' ) ) { 70 return ''; // A different WordPress version: the files may differ. 71 } 72 return ABSPATH . $m[2]; 73 } 50 74 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)