Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $rnd_id = dt_random_id(3);
- $token = wp_generate_password(5, false, false);
- wp_enqueue_script('script_js', 'scripts.js', [], null, true);
- wp_localize_script('script_js', 'object_name_'.$token, array(
- 'id' => $rnd_id,
- 'var_name' => 'var_val',
- )
- );
- <div class="class_name" id="id_prifix-'.$rnd_id.'" data-token="'.$token.'">
- </div>
- jQuery('.class_name[id^="id_prifix"]').each( function() {
- var div = jQuery(this);
- var token = div.data('token');
- var settingObj = window['object_name_' + token];
- console.log(settingObj);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement