Can we somehow use wp_localize_script() to create global js variables without a specific script handle which can be accessed from all the js files, even if the js scripts are not enqueued properly by using wp_enqueue_script ?
This is the code I am using which creates varibale for 'ajaxscript' handle, so I cant access the object 'ajaxobject' in a js file which is being included in the header.php directly by <script src="xxx" .... />
wp_register_script( 'ajaxscript', get_bloginfo( 'template_url' ) . '/js/ajaxscript.js', array(), $version );
wp_enqueue_script( 'ajaxscript' );
wp_localize_script( 'ajaxscript', 'ajaxobject',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'ajaxnonce' => wp_create_nonce( 'itr_ajax_nonce' )
)
);
wp_localize_script
does anyway. With both methods, the variables are accessible from any script