All Questions
Tagged with wp-localize-script functions
5 questions
0
votes
1
answer
309
views
localize_script but data changes dependent on product ID
I currently have this code in my functions.php file.
$dataToBePassed = array();
add_action( 'wp_enqueue_scripts', function() {
$handle = 'three-d-scripts';
$src = ...
1
vote
2
answers
6k
views
Get Current User info using wp_localize_script, in functions.php
I need to pass the info from wp_get_current_user() to the front end for a script that uses it. To achieve this, I am using wp_localize_script() to pass the information. I put the code at the top of my ...
0
votes
1
answer
602
views
Using wp_localize_script in template file - is it secure?
I have the following code inside one of my template files (NOT functions.php)
$datatoBePassed = array(
'pageTitle' => get_the_title()
);
wp_localize_script( 'main-js', '...
0
votes
0
answers
260
views
Pass max posts to Javascript
I'm doing a fairly standard situation where posts are loaded with AJAX via a list. I'm having difficulty passing from WP/PHP to JS when the max posts are reached.
Here's what I use to enqueue assets ...
0
votes
2
answers
267
views
adding custom script to functions file
I have a problem adding a custom script to my functions.php file:
add_action('wp_print_scripts', 'load_AJAX_URL__');
function load_AJAX_URL__() {
wp_localize_script( 'ajax_URL', 'MyAjax', array( '...