How do I activate jQuery/script on demand?

1. Register jQuery and the plugin within your head wp_register_script( ‘jquery’ ); wp_register_script( ‘your_jquery_plugin’, STYLESHEETPATH, ‘jquery’, ‘0.0’, false ); 2. Register a meta box It should be a simple checkbox. Please do it like it’s described on the codex page for add_meta_box() (don’t just repeat this one here). If you follow the rest, then the … Read more

Enqueuing jQuery in plug-ins

First of all, if your code (or the theme’s code) is unregistering jQuery and re-registering it from another location (Google), you need to add this somewhere: jQuery.noConflict(); This makes jQuery cooperate with other scripts (i.e. Prototype) that try to define the $ variable globally. WordPress has this line bundled into their version, Google does not. … Read more

Using wp_ajax and wp_ajax_nopriv hooks

It depends on what exactly you want to do. If you want to show just a short message, use the same callback for both. But if you need completely different objects and load different additional files depending on the log-in status, use separate callbacks. Basic example, probably not a recommended implementation. 🙂 class Ajax_Controller { … Read more

WordPress Script Loading/Unloading — wp_deregister_script(‘jquery’)

WordPress has essentially two groups of methods to handle scripts, both of which should be used: wp_register_script Registers a script in WordPress. It does not get called, it is just available for WordPress, if it is needed. wp_deregister_script is the exact opposite. It deletes the definitions made in wp_register_script, the script is no longer available … Read more

How to load a jQuery script last?

add_action(‘wp_footer’,’myscript_in_footer’); function myscript_in_footer(){ ?> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(“div.domTip_tipBody”).mouseover(function(){ jQuery(“#yyy a.tippy_link”).css(“background-color”,”yellow”);}); jQuery(“div.domTip_tipBody”).mouseout(function(){ jQuery(“#yyy a.tippy_link”).css(“background-color”,”red”); }); }); </script> <?php }

Enqueue jQuery in WordPress

You’re on the right track, but missing one piece: add_action(‘wp_enqueue_scripts’, ‘my_scripts_method’); add_action allows you to run code at specific times during page loads / specific events. The above action tells WP to run your function when it is adding the scripts to the html head element. Your function in turn instructs WP to add the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)