Skip to content

Commit

Permalink
Don't deliver unneeded JavaScript if Graphs plugin is enabled
Browse files Browse the repository at this point in the history
Fixes #23446
  • Loading branch information
atrol committed Oct 11, 2017
1 parent 372f08f commit 5df95f5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plugins/MantisGraph/MantisGraph.php
Expand Up @@ -99,7 +99,7 @@ function routes( $p_event_name, $p_event_args ) {
* @return void
*/
function csp_headers() {
if ( config_get_global( 'cdn_enabled' ) == ON ) {
if( config_get_global( 'cdn_enabled' ) == ON ) {
http_csp_add( 'script-src', 'https://cdnjs.cloudflare.com' );
}
}
Expand All @@ -122,14 +122,16 @@ function graph_filter_menu() {
* @return void
*/
function resources() {
if ( config_get_global( 'cdn_enabled' ) == ON ) {
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.min.js', CHARTJS_HASH );
html_javascript_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.bundle.min.js', CHARTJSBUNDLE_HASH );
} else {
echo '<script src="' . plugin_file( 'chart-' . CHARTJS_VERSION . '.min.js' ) . '"></script>';
echo '<script src="' . plugin_file( 'chart.bundle-' . CHARTJS_VERSION . '.min.js' ) . '"></script>';
if( current( explode( '/', gpc_get_string( 'page', '' ) ) ) === $this->basename ) {
if( config_get_global( 'cdn_enabled' ) == ON ) {
html_javascript_cdn_link('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.min.js', CHARTJS_HASH);
html_javascript_cdn_link('https://cdnjs.cloudflare.com/ajax/libs/Chart.js/' . CHARTJS_VERSION . '/Chart.bundle.min.js', CHARTJSBUNDLE_HASH);
} else {
echo '<script src="' . plugin_file('chart-' . CHARTJS_VERSION . '.min.js') . '"></script>';
echo '<script src="' . plugin_file('chart.bundle-' . CHARTJS_VERSION . '.min.js') . '"></script>';
}
echo '<script src="' . plugin_file("MantisGraph.js") . '"></script>';
}
echo '<script src="' . plugin_file( "MantisGraph.js" ) . '"></script>';
}

/**
Expand Down

0 comments on commit 5df95f5

Please sign in to comment.