Handling jQuery Component Collision

My suggestion would be to use a mix of code isolation in an anonymous function and checking if jquery is already present. Here’s an example: (function() { var jQuery; // your jquery variable // check if jquery is present and if it has the version you want if (window.jQuery === undefined || window.jQuery.fn.jquery !== ‘1.8.3’) … Read more

Placement of Code in Plugin for hooking `save_post`

I’m not sure if if( !current_user_can( ‘edit_post’, $post_id ) ) return; really works. Maybe the current user isn’t set up there and you’ll have to work around it by passing the user ID in a hidden field, then retrieving it using $user = get_user_by( ‘id’, esc_attr( $_POST[‘user_id’] ) ); wp_set_current_user( $user->user_id ); if ( ! … Read more

wpColorPicker is not a function!

This is happening because you are calling wpColorPicker function before loading wp-color-picker script so to overcome this situation call wpColorPicker() function after loading wp-color-picker script by adding following script in js file in this example i have added it in wp-color-picker-script.js. jQuery(document).ready(function($){ $(‘.ir’).wpColorPicker(); }); and then enqueue it using admin_enqueue_scripts action after enqueuing wp-color-picker script … Read more