100 ) { $scroll_trigger = 100; // Maximum is 100%. } $scroll_percentage = $scroll_trigger / 100; // Convert to decimal (50 -> 0.5). // Build config for JS (exact values you already use). // All values are sanitized: network_code (sanitize_text_field), popup_option (literal), scroll_percentage (calculated number). $config = array( 'popup_option' => sanitize_text_field( $popup_option ), // "ONCE_PER_SESSION". 'network_code' => esc_js( $network_code ), // Escaped for JavaScript context. 'scroll_trigger' => (float) $scroll_percentage, // Scroll trigger as decimal (0.5 = 50%). ); // IMPORTANT: wp_json_encode properly escapes JSON values. // All values in $config are already sanitized/escaped above. $config_js = 'window.ADXBYMS_POPUP_DATA = ' . wp_json_encode( $config, JSON_UNESCAPED_SLASHES ) . ';'; // Register + enqueue the external JS file. // Path provided by you: ADXBYMS_URL . 'views/js/popup.js'. $popup_js_url = trailingslashit( ADXBYMS_URL ) . 'views/js/popup.js'; wp_register_script( 'adxbyms_popup_script', $popup_js_url, array( 'adxbyms-gpt' ), // no deps; GPT loader stays inside popup.js. ADXBYMS_JS_VERSION, true // load in footer. ); // Make sure data is available BEFORE popup.js executes. wp_add_inline_script( 'adxbyms_popup_script', $config_js, 'before' ); // Enqueue the script. wp_enqueue_script( 'adxbyms_popup_script' ); }