From f9f960b1d062fd08df68a577f6722469b5a6467c Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 11 Jul 2008 01:45:41 +0000 Subject: [PATCH] Add flash uploader bypass toggle. Props tellyworth. fixes #7281 git-svn-id: http://svn.automattic.com/wordpress/trunk@8310 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index d8b87a57f3..58a3753f98 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1407,6 +1407,49 @@ function type_form_file() { '; } +// support a GET parameter for disabling the flash uploader +function media_upload_use_flash($flash) { + if ( array_key_exists('flash', $_REQUEST) ) + $flash = !empty($_REQUEST['flash']); + return $flash; +} + +add_filter('flash_uploader', 'media_upload_use_flash'); + +function media_upload_flash_bypass() { + echo '

'; + printf( __('You are using the Flash uploader. Problems? Try the Browser uploader instead.'), add_query_arg('flash', 0) ); + echo '

'; +} + +add_action('post-flash-upload-ui', 'media_upload_flash_bypass'); + +function media_upload_html_bypass() { + echo '

'; + if ( array_key_exists('flash', $_REQUEST) ) + // the user manually selected the browser uploader, so let them switch back to Flash + printf( __('You are using the Browser uploader. Try the Flash uploader instead.'), add_query_arg('flash', 1) ); + else + // the user probably doesn't have Flash + printf( __('You are using the Browser uploader.') ); + + echo '

'; +} + +add_action('post-flash-upload-ui', 'media_upload_flash_bypass'); +add_action('post-html-upload-ui', 'media_upload_html_bypass'); + +// make sure the GET parameter sticks when we submit a form +function media_upload_bypass_url($url) { + if ( array_key_exists('flash', $_REQUEST) ) + $url = add_query_arg('flash', intval($_REQUEST['flash'])); + return $url; +} + +add_filter('media_upload_form_url', 'media_upload_bypass_url'); + + + add_filter('async_upload_image', 'get_media_item', 10, 2); add_filter('async_upload_audio', 'get_media_item', 10, 2); add_filter('async_upload_video', 'get_media_item', 10, 2);