Plugin Directory


Ignore:
Timestamp:
10/13/2026 10:00:51 AM (2 weeks ago)
Author:
shiponkarmakar
Message:

Release v1.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • optimazz/trunk/includes/Core/Paths.php

    r3617648 r3743505  
    2525        public static function url_to_path( $url ) {
    2626                $host = wp_parse_url( $url, PHP_URL_HOST );
     27                if ( 'c0.wp.com' === $host ) {
     28                        return self::jetpack_core_path( $url );
     29                }
    2730                if ( $host && $host !== wp_parse_url( home_url(), PHP_URL_HOST ) ) {
    2831                        return '';
    … …  
    4851                return ABSPATH . ltrim( $path, '/' );
    4952        }
     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        }
    5074}
Note: See TracChangeset for help on using the changeset viewer.