I\'m busy with building my own Wordpress Widget. Everything works fine except for the Wordpress media up loader. I have created eight buttons and eight input text fields which s
This script helped me alot. Later on, though, I found out that it messed with the media upload in my posts perhaps because it was calling the media uploader scripts twice. I solved it by adding
if( $hook != 'widgets.php' )
return;
Like this:
// queue up the necessary js
function hrw_enqueue($hook) {
if( $hook != 'widgets.php' )
return;
wp_enqueue_style('thickbox');
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
// I also changed the path, since I was using it directly from my theme and not as a plugin
wp_enqueue_script('hrw', get_template_directory_uri() . '/js/script.js', null, null, true);
}
add_action('admin_enqueue_scripts', 'hrw_enqueue');
That way the widget calls the uploader script only in the widgets' page and not in the entire admin.