Skip to content

Commit ba60548

Browse files
Fix operator precedence bug causing corechart.js to load on all report pages
The condition in pmpro_report_members_per_level_init() had a precedence bug — the || was not grouped with is_admin(), so the second clause (page == pmpro-reports) fired on every reports page regardless of which report was active. This caused corechart.js to be enqueued on pages like the memberships report, resulting in google.charts.load() being called twice and throwing: 'Google Charts loader.js can only be loaded once.' Fixed by rewriting the condition to require both page and report params.
1 parent 3506c97 commit ba60548

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

adminpages/reports/members-per-level.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function pmpro_report_members_per_level_register( $pmpro_reports ) {
1919

2020
// Enqueue Google Visualization JS on report page
2121
function pmpro_report_members_per_level_init() {
22-
if ( is_admin() && ( isset( $_REQUEST['report'] ) && $_REQUEST[ 'report' ] == 'members_per_level' ) || ( isset( $_REQUEST['page'] ) && $_REQUEST[ 'page' ] == 'pmpro-reports' ) ) {
22+
if ( is_admin() && isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'pmpro-reports' && isset( $_REQUEST['report'] ) && $_REQUEST['report'] == 'members_per_level' ) {
2323
wp_enqueue_script( 'corechart', plugins_url( 'js/corechart.js', plugin_dir_path( __DIR__ ) ) );
2424
}
2525
}

0 commit comments

Comments
 (0)