diff options
Diffstat (limited to 'plugins/jetpack/modules/photon-cdn.php')
-rw-r--r-- | plugins/jetpack/modules/photon-cdn.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/plugins/jetpack/modules/photon-cdn.php b/plugins/jetpack/modules/photon-cdn.php index f4e70e6a..232a1c8d 100644 --- a/plugins/jetpack/modules/photon-cdn.php +++ b/plugins/jetpack/modules/photon-cdn.php @@ -1,4 +1,4 @@ -<?php +<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName /** * Module Name: Asset CDN * Module Description: Jetpack’s Site Accelerator loads your site faster by optimizing your images and serving your images and static files from our global network of servers. @@ -10,14 +10,19 @@ * Module Tags: Photos and Videos, Appearance, Recommended * Feature: Recommended, Appearance * Additional Search Queries: site accelerator, accelerate, static, assets, javascript, css, files, performance, cdn, bandwidth, content delivery network, pagespeed, combine js, optimize css + * + * @package automattic/jetpack */ use Automattic\Jetpack\Assets; -$GLOBALS['concatenate_scripts'] = false; +$GLOBALS['concatenate_scripts'] = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited Assets::add_resource_hint( '//c0.wp.com', 'dns-prefetch' ); +/** + * Asset CDN module main class file. + */ class Jetpack_Photon_Static_Assets_CDN { const CDN = 'https://c0.wp.com/'; @@ -61,7 +66,7 @@ class Jetpack_Photon_Static_Assets_CDN { * * @param array $values array( $version = core assets version, i.e. 4.9.8, $locale = desired locale ) */ - list( $version, $locale ) = apply_filters( + list( $version, $locale ) = apply_filters( // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable 'jetpack_cdn_core_version_and_locale', array( $wp_version, get_locale() ) ); @@ -73,7 +78,7 @@ class Jetpack_Photon_Static_Assets_CDN { continue; } $src = ltrim( str_replace( $site_url, '', $thing->src ), '/' ); - if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ) ) ) { + if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ), true ) ) { $wp_scripts->registered[ $handle ]->src = sprintf( self::CDN . 'c/%1$s/%2$s', $version, $src ); $wp_scripts->registered[ $handle ]->ver = null; } @@ -83,7 +88,7 @@ class Jetpack_Photon_Static_Assets_CDN { continue; } $src = ltrim( str_replace( $site_url, '', $thing->src ), '/' ); - if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ) ) ) { + if ( self::is_js_or_css_file( $src ) && in_array( substr( $src, 0, 9 ), array( 'wp-admin/', 'wp-includ' ), true ) ) { $wp_styles->registered[ $handle ]->src = sprintf( self::CDN . 'c/%1$s/%2$s', $version, $src ); $wp_styles->registered[ $handle ]->ver = null; } @@ -135,7 +140,7 @@ class Jetpack_Photon_Static_Assets_CDN { * * @return string The transformed local languages path. */ - public static function fix_local_script_translation_path( $file, $handle, $domain ) { + public static function fix_local_script_translation_path( $file, $handle, $domain ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable global $wp_scripts; // This is a rewritten plugin URL, so load the language file from the plugins path. @@ -237,7 +242,7 @@ class Jetpack_Photon_Static_Assets_CDN { * @param array $assets The assets array for the plugin. * @param string $version The version of the plugin being requested. */ - $assets = apply_filters( "jetpack_cdn_plugin_assets-{$plugin}", null, $version ); + $assets = apply_filters( "jetpack_cdn_plugin_assets-{$plugin}", null, $version ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores if ( is_array( $assets ) ) { return $assets; } @@ -301,13 +306,13 @@ class Jetpack_Photon_Static_Assets_CDN { */ public static function is_public_version( $version, $include_beta_and_rc = false ) { if ( preg_match( '/^\d+(\.\d+)+$/', $version ) ) { - // matches `1` `1.2` `1.2.3`. + /** Example matches: `1`, `1.2`, `1.2.3`. */ return true; } elseif ( $include_beta_and_rc && preg_match( '/^\d+(\.\d+)+(-(beta|rc|pressable)\d?)$/i', $version ) ) { - // matches `1.2.3` `1.2.3-beta` `1.2.3-pressable` `1.2.3-beta1` `1.2.3-rc` `1.2.3-rc2`. + /** Example matches: `1.2.3`, `1.2.3-beta`, `1.2.3-pressable`, `1.2.3-beta1`, `1.2.3-rc`, `1.2.3-rc2`. */ return true; } - // unrecognized version. + // Unrecognized version. return false; } } |