Don't hide links to the upload form and show an error for mobile devices that cannot upload, see #20410

git-svn-id: http://svn.automattic.com/wordpress/trunk@20449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-04-12 00:16:37 +00:00
parent 65382b14f8
commit 817b932ed1
7 changed files with 32 additions and 23 deletions

View File

@ -64,13 +64,7 @@ add_filter('media_upload_tabs', 'update_gallery_tab');
function the_media_upload_tabs() {
global $redir_tab;
$tabs = media_upload_tabs();
if ( wp_is_mobile() ) {
unset($tabs['type']);
$default = 'type_url';
} else {
$default = 'type';
}
$default = 'type';
if ( !empty($tabs) ) {
echo "<ul id='sidemenu'>\n";
@ -598,10 +592,7 @@ function wp_media_upload_handler() {
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
}
if ( wp_is_mobile() )
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
else
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
}
/**
@ -1306,8 +1297,10 @@ function media_upload_header() {
function media_upload_form( $errors = null ) {
global $type, $tab, $pagenow, $is_IE, $is_opera;
if ( wp_is_mobile() )
if ( ! _device_can_upload() ) {
echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href=" http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>';
return;
}
$upload_action_url = admin_url('async-upload.php');
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
@ -1438,8 +1431,6 @@ if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
* @param unknown_type $id
*/
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
if ( wp_is_mobile() )
return;
media_upload_header();

View File

@ -9,8 +9,4 @@
$_GET['inline'] = 'true';
/** Administration bootstrap */
require_once('./admin.php');
if ( wp_is_mobile() ) // cannot upload files from mobile devices
return;
require_once('./media-upload.php');

View File

@ -106,7 +106,7 @@ case 'edit' :
<h2>
<?php
echo esc_html( $title );
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
if ( current_user_can( 'upload_files' ) ) { ?>
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a>
<?php } ?>
</h2>

View File

@ -56,8 +56,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu
$menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
/* translators: add new file */
if ( ! wp_is_mobile() )
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
$submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
$submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );

View File

@ -179,7 +179,7 @@ require_once('./admin-header.php');
<h2>
<?php
echo esc_html( $title );
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() ) { ?>
if ( current_user_can( 'upload_files' ) ) { ?>
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
}
if ( ! empty( $_REQUEST['s'] ) )

View File

@ -489,7 +489,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
unset( $cpts['post'] );
}
if ( current_user_can( 'upload_files' ) && ! wp_is_mobile() )
if ( current_user_can( 'upload_files' ) )
$actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
if ( current_user_can( 'manage_links' ) )

View File

@ -3676,3 +3676,26 @@ function _get_non_cached_ids( $object_ids, $cache_key ) {
return $clean;
}
/**
* Test if the current device has the capability to upload files.
*
* @since 3.4.0
* @access private
*
* @return bool true|false
*/
function _device_can_upload() {
if ( ! wp_is_mobile() )
return true;
$ua = $_SERVER['HTTP_USER_AGENT'];
if ( strpos($ua, 'iPhone') !== false
|| strpos($ua, 'iPad') !== false
|| strpos($ua, 'iPod') !== false ) {
return false;
} else {
return true;
}
}