Trouble adding inline style after jQuery in the footer!

You are trying to load your inline js script after jQuery just by calling add_action( ‘wp_footer’, ‘myscript’ ); after wp_enqueue_script( ‘jquery’ ); But this will not load your myscript after jQuery. It is not how wp_footer and wp_enqueue_script works. wp_footer has a third argument named “priority”. add_action( ‘wp_footer’, ‘your_function’, 100 ); //100 is priority here. … Read more

Firebug says jQuery is loaded but $() and jQuery() are not defined

jQuery needs to be outside the wrapper like so: <script type=”text/javascript”> (function($) { $(document).ready(function() { alert(‘hello?’); }); })(jQuery); </script> Edit: A better way would be: jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); Also make sure any inline script tags are AFTER your call to wp_head(); And … Read more

Enque Javascript in Footer?

The fifth parameter is $in_footer. You have left that out. Add that parameter, set it to true. wp_register_script( ‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”, false, null, true ); But I echo the concern expressed by @Andrew in a comment. You can cause yourself trouble by deregistering/replacing the core libraries. … Read more

Call a javascript function from another file

The issue you have is that Slider is not accessible outside of its scope as that’s defined by the .ready() though you’ve used shorthand for that. The function needs to be available in the global scope: file1.js function Slider() { this.nb_ele = 10; } jQuery(function($) { // … }); file2.js jQuery(function($) { var slider = … Read more

How to isolate code to the post edit screen

Use the WP_Screen object to tell where you are at in the admin instead. Much more convenient. $screen = get_current_screen(); if ( $screen->id == ‘edit-post’ ) { // you’re on the posts screen } Note that you have to wait until at least the admin_head hook to run for the current screen to have been … Read more

wp_dequeue_script not working in my plugin

wp_enqueue_script() also registers the script. So, you’ll also need to de-register it first. This code should work depending on how and where the script is enqueued. function my_dequeue() { wp_deregister_script( ‘ocmx-jquery’ ); wp_dequeue_script( ‘ocmx-jquery’ ); } add_action( ‘admin_enqueue_scripts’, ‘my_dequeue’, 10 ); You might also need to play with the priority of the action.

How to enqueue jquery in admin and why is it not already there?

First, check for syntax errors. The syntax highlighting seems to indicate that you have syntax errors. Second, don’t wrap your add_action() calls inside conditionals; rather, wrap your callback function content inside the conditionals, e.g.: <?php function theme_upgrade_alernt() { if ( is_admin() && $pagenow == ‘theme-install.php’ && $_GET[‘tab’]==”upload”){ // CODE GOES HERE } else { // … Read more