JavaScript missing from shortcode content
I am trying to add a short javascript as part of registering a WP shortcode. You can see my simplified code below. When I execute this on my website everything loads fine except for the part between the script ... /script
tags. I looked at the source code after the page has loaded and neither the script
tags nor the function in between is there.
I don't know what I'm doing wrong.
Is there a filter in WP that removes script
tags?
Thank you!
// register custom shortcodes
function psb_register_shortcodes() {
add_shortcode('psb-booking', 'psb_booking_shortcode');
}
function psb_booking_shortcode( $args, $content='' ) {
global $wpdb;
$output =
'script
function doSomething () {};
/script';
$output .= 'p testing /p';
$table_name = $wpdb-prefix . 'psb_booking';
foreach ( $wpdb-get_col( $wpdb-prepare(DESC . $table_name, 0 )) as $column_name ) {
error_log( $column_name );
}
$output .= file_get_contents(plugin_dir_path( __FILE__ ) . 'includes/psb-booking.html');
return $output;
}