Skip to content

Commit

Permalink
generalize CDN list
Browse files Browse the repository at this point in the history
Some search patterns were too specific to catch all the cases.

Output as Required, since it is, but leave the return value as okay since it could have false positives.
  • Loading branch information
joyously committed May 18, 2019
1 parent da79a6f commit eec60da
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions checks/cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@ function check( $php_files, $css_files, $other_files) {
checkcount();

$cdn_list = array(
'bootstrap-maxcdn' => 'maxcdn.bootstrapcdn.com/bootstrap',
'bootstrap-netdna' => 'netdna.bootstrapcdn.com/bootstrap',
'bootswatch-maxcdn' => 'maxcdn.bootstrapcdn.com/bootswatch',
'bootswatch-netdna' => 'netdna.bootstrapcdn.com/bootswatch',
'font-awesome-maxcdn' => 'maxcdn.bootstrapcdn.com/font-awesome',
'font-awesome-netdna' => 'netdna.bootstrapcdn.com/font-awesome',
'html5shiv-google' => 'html5shiv.googlecode.com/svn/trunk/html5.js',
'html5shiv-maxcdn' => 'oss.maxcdn.com/libs/html5shiv',
'bootstrap-maxcdn' => 'maxcdn.bootstrapcdn.com',
'bootstrap-netdna' => 'netdna.bootstrapcdn.com',
'bootstrap-stackpath' => 'stackpath.bootstrapcdn.com',
'googlecode' => 'googlecode.com/svn/',
'oss.maxcdn' => 'oss.maxcdn.com',
'jquery' => 'code.jquery.com/jquery-',
'respond-js' => 'oss.maxcdn.com/libs/respond.js',
'aspnetcdn' => 'aspnetcdn.com',
'cloudflare' => 'cloudflare.com',
'keycdn' => 'keycdn.com',
'pxgcdn' => 'pxgcdn.com',
'vimeocdn' => 'vimeocdn.com', //usually in JS files
);

foreach( $cdn_list as $cdn_slug => $cdn_url ) {
if ( false !== strpos( $all_code, $cdn_url ) ) {
$this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED','theme-check') . '</span>: ' . sprintf( __( 'Found the URL of a CDN in the code: %s. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.', 'theme-check' ), '<code>' . esc_html( $cdn_url ) . '</code>' );
$this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED','theme-check') . '</span>: ' . sprintf( __( 'Found the URL of a CDN in the code: %s. You should not load CSS or Javascript resources from a CDN, please bundle them with the theme.', 'theme-check' ), '<code>' . esc_html( $cdn_url ) . '</code>' );
//$ret = false;
}
}
Expand Down

0 comments on commit eec60da

Please sign in to comment.