I think there is a better way to enqueue or load your scripts first register the script or styles with wp_register_style and wp_register_script.
After registering you can load the script/style when required. For example when you render a shortcode with wp_enqueue_style("your_style") and wp_enqueue_script("your_script").
Example
[my_shortcode other parameters]
Add action for the script by registering and enqueuing when required.
function prefix_my_shortcode_wp_enqueue_scripts() {
wp_register_script( 'my-shortcode-script', plugins_url( 'path/myscript.css' ) );
}
add_action( 'wp_enqueue_scripts', 'prefix_my_shortcode_wp_enqueue_scripts' );
Your shortcode function
function prefix_function_my_shortcode( $attributes ) {
extract( shortcode_atts(
// your shortcode array args
));
wp_enqueue_script( 'my-shortcode-script' );
return 'your shortcode output;
}
add_shortcode( 'my_shortcode', 'prefix_function_my_shortcode' );
Hope that answers your question. Let me know if that helps out.
get_page_templateto get the template path for current page, e.gprint_r( has_shortcode(file_get_contents(get_page_template()), "my_shortcode") );