How to check if short code is present in template?

Assuming the first block of code is executed when your plugin is launched, the has_shortcode function is prescanning the post content to check if the shortcode is present. You then enqueue the scripts. That will work, because plugins are initiated before the scripts are enqueued (init hook comes before wp_enqueue_scripts hook).

If you enqueue scripts inside the shortcode, the function will be executed when the post content is assembled. At that point WP is already past the wp_enqueue_scripts hook. The scripts will then end up in the footer, which may impact their behaviour.

If you use do_shortcode directly in a template, your function with has_shortcode will do nothing, because it only reacts to stuff that is inside the post content. You will have to replicate the circumstances under which do_shortcode will be executed in the template during plugin initialisation to enqueue the scripts.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş