I’m using wordpress mediaupload function in my plugin.
Error: jQuery is not defined
Source File: http://localhost/my_wp/wp-admin/load-scripts.php?c=0&load=utils,thickbox,media-upload&ver=4ec4a484079ac4122099967c5457437d
Line: 19
This is my error message when my plugin load. When i see the code the media upload script is loading first then jquery is loading.
this is my code
add_action( 'admin_enqueue_scripts', 'wpvote_include_files' );
function wpvote_include_files() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
wp_register_script('my-upload', WPVOTE_PLUGIN_URL.'wpmediaupload_scripts.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script('my-upload');
}
this is my page source code
<script type='text/javascript' src='http://localhost/my_wp/wp-admin/load-scripts.php?c=0&load=utils,thickbox,media-upload&ver=4ec4a484079ac4122099967c5457437d'></script>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js?ver=3.3.2'></script>
A posible problem is that you are trying to enqueue a script in the admin area. Why don’t you try using the admin_enqueue_scripts method?
Reference: http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts