jQuery UI inside widget on admin page

Ok, so, for some reason I can’t comprehend, the answer is that the div element containing the tabs should have a class and not an id for jQuery UI to work properly, as such: <div class=”mytabs”> and jQuery(document).ready(function($) { $(“.mytabs”).tabs(); }); Just for the record, the way I enqued the scripts is: add_action( ‘admin_enqueue_scripts’, ‘load_my_admin_js’ … Read more

How to load javascript file on homepage in WordPress in order?

In your functions.php: edit: First register the quicktags script under a different name than already registered in wp “quicktags” , see Codex function quicktags_script() { wp_register_script( ‘quicktags-min’, ‘/wp-includes/js/quicktags.min.js?ver=3.5.1’,”,”,true); wp_enqueue_script( ‘quicktags-min’ ); } add_action( ‘wp_enqueue_scripts’, ‘quicktags_script’ ); This will load the script for all the pages on your front-end. To load it only on front-page : … Read more

Putting PHP variables into javascript [duplicate]

Use wp_localize_script: wp_enqueue_script(‘YOUR_SCRIPT_HANDLE’); $object = array( ‘zoom’ => get_option(‘map_zoom’), ‘longitude’ => get_option(‘map_longitude’), ‘latitude’ => get_option(‘map_latitude’), ); wp_localize_script(‘YOUR_SCRIPT_HANDLE’, ‘JSObject’, $object); And then use it in your JS file like JSObject.zoom and the like.

JQuery not working in my plugin [closed]

You’re using an invalid action: add_action(‘wp_enqueue_script’, ‘run_js_script’); The correct action is wp_enqueue_scripts (plural), not wp_enqueue_script (singular). Use this instead: add_action(‘wp_enqueue_scripts’, ‘run_js_script’); Edit Same problem here: add_action(‘wp_register_script’, ‘register_script’); Just hook it into wp_enqueue_scripts for simplicity: add_action(‘wp_enqueue_scripts’, ‘register_script’); Actually, two better options: Put your wp_register_script() call in the same run_js_script callback as your wp_enqueue_script() call. Eliminate wp_register_script() … Read more