php – wp_enqueue_scripts with JS script as a string

Question

isn’t there any way to load a script through wp_enqueue_scripts and have my script instead of in a file, in a variable declared earlier? Something like:

$script = <<<JS
<script type="text/javascript">
jQuery(function($) {
    $(document).ready(function() {
        alert('asdasd');
    });
});
</script>
JS;
      
wp_enqueue_script( 'ajax_check_payment', $script, array('jquery'), time(), true );

0
Faye D. 2 months 2022-09-25T16:57:17-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse