= site_url(); $siteUrlEscaped = aioseo()->helpers->escapeRegex( $siteUrl ); if ( preg_match( "/^$siteUrlEscaped/i", $path ) ) { $paths[ $path ] = $path; return apply_filters( 'aioseo_normalize_assets_host', $paths[ $path ] ); } // We now know that the path doesn't contain the site_url(). $newPath = $path; $siteUrlParsed = wp_parse_url( $siteUrl ); $host = aioseo()->helpers->escapeRegex( str_replace( 'www.', '', $siteUrlParsed['host'] ) ); $scheme = aioseo()->helpers->escapeRegex( $siteUrlParsed['scheme'] ); $siteUrlHasWww = preg_match( "/^{$scheme}:\/\/www\.$host/", $siteUrl ); $pathHasWww = preg_match( "/^{$scheme}:\/\/www\.$host/", $path ); // Check if the path contains www. if ( $pathHasWww && ! $siteUrlHasWww ) { // If the path contains www., we want to strip it out. $newPath = preg_replace( "/^({$scheme}:\/\/)(www\.)($host)/", '$1$3', $path ); } // Check if the site_url contains www. if ( $siteUrlHasWww && ! $pathHasWww ) { // If the site_url contains www., we want to add it in to the path. $newPath = preg_replace( "/^({$scheme}:\/\/)($host)/", '$1www.$2', $path ); } $paths[ $path ] = $newPath; return apply_filters( 'aioseo_normalize_assets_host', $paths[ $path ] ); } /** * Get all the CSS files which a JS asset depends on. * This won't work properly unless you've run `npm run build` first. * * @since 4.3.1 * * @param string $asset The asset to find the CSS dependencies for. * @return array All the asset's CSS dependencies if any. */ public function getJsAssetCssQueue( $asset ) { $queue = []; foreach ( $this->getCssUrls( $asset ) as $file => $url ) { $queue[] = [ 'handle' => $this->cssHandle( $file ), 'url' => $url ]; } $manifestAsset = $this->getManifestItem( $asset ); if ( ! empty( $manifestAsset['imports'] ) ) { foreach ( $manifestAsset['imports'] as $subAsset ) { foreach ( $this->getCssUrls( $subAsset ) as $file => $url ) { $queue[] = [ 'handle' => $this->cssHandle( $file ), 'url' => $url ]; } } } return $queue; } }