Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1563,17 +1563,13 @@
* @return string|WP_Error Stylesheet string on success, or WP_Error on failure.
*/
private function get_stylesheet_from_url( $stylesheet_url ) {
$stylesheet = false;
$css_file_path = $this->get_validated_url_file_path( $stylesheet_url, [ 'css', 'less', 'scss', 'sass' ] );
if ( ! is_wp_error( $css_file_path ) ) {
$stylesheet = file_get_contents( $css_file_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
if ( is_wp_error( $css_file_path ) ) {
return $css_file_path;
}
if ( is_string( $stylesheet ) ) {
return $stylesheet;
}

// Fall back to doing an HTTP request for the stylesheet is not accessible directly from the filesystem.
return $this->fetch_external_stylesheet( $stylesheet_url );

$stylesheet = file_get_contents( $css_file_path ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- It's a local filesystem path not a remote request.
return $stylesheet;
}

/**
Expand All @@ -1582,7 +1578,7 @@
* @param string $url External stylesheet URL.
* @return string|WP_Error Stylesheet contents or WP_Error.
*/
private function fetch_external_stylesheet( $url ) {

Check failure on line 1581 in includes/sanitizers/class-amp-style-sanitizer.php

View workflow job for this annotation

GitHub Actions / Static Analysis: PHP

Method AMP_Style_Sanitizer::fetch_external_stylesheet() is unused.

// Prepend schemeless stylesheet URL with the same URL scheme as the current site.
if ( '//' === substr( $url, 0, 2 ) ) {
Expand Down
Loading