Enqueue WP Script that contained PHP variables

I am trying to find out if you can enqueue a script in WordPress that has php variables within it. If this is possible how would it be done?

I have tried this, however I get errors.

function my_scripts_method() {
wp_enqueue_script(
    'custom-script',
    get_stylesheet_directory_uri() . '/masonry.php',
    array( 'jquery' )
);
}

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

Read more here: Enqueue WP Script that contained PHP variables

Leave a Reply

Your email address will not be published. Required fields are marked *