<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20449] trunk: Don't hide links to the upload form and show an error for mobile devices that cannot upload, see #20410</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20449">20449</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2012-04-12 00:16:37 +0000 (Thu, 12 Apr 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't hide links to the upload form and show an error for mobile devices that cannot upload, see <a href="http://core.trac.wordpress.org/ticket/20410">#20410</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminmedianewphp">trunk/wp-admin/media-new.php</a></li>
<li><a href="#trunkwpadminmediaphp">trunk/wp-admin/media.php</a></li>
<li><a href="#trunkwpadminmenuphp">trunk/wp-admin/menu.php</a></li>
<li><a href="#trunkwpadminuploadphp">trunk/wp-admin/upload.php</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-admin/includes/media.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -64,14 +64,8 @@
</span><span class="cx"> function the_media_upload_tabs() {
</span><span class="cx">         global $redir_tab;
</span><span class="cx">         $tabs = media_upload_tabs();
</span><ins>+        $default = 'type';
</ins><span class="cx"> 
</span><del>-        if ( wp_is_mobile() ) {
-                unset($tabs['type']);
-                $default = 'type_url';
-        } else {
-                $default = 'type';
-        }
-
</del><span class="cx">         if ( !empty($tabs) ) {
</span><span class="cx">                 echo &quot;&lt;ul id='sidemenu'&gt;\n&quot;;
</span><span class="cx">                 if ( isset($redir_tab) &amp;&amp; array_key_exists($redir_tab, $tabs) )
</span><span class="lines">@@ -598,10 +592,7 @@
</span><span class="cx">                 return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        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 );
</del><ins>+        return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1306,8 +1297,10 @@
</span><span class="cx"> function media_upload_form( $errors = null ) {
</span><span class="cx">         global $type, $tab, $pagenow, $is_IE, $is_opera;
</span><span class="cx"> 
</span><del>-        if ( wp_is_mobile() )
</del><ins>+        if ( ! _device_can_upload() ) {
+                echo '&lt;p&gt;' . __('The web browser on your device cannot be used to upload files. You may be able to use the &lt;a href=&quot; http://wordpress.org/extend/mobile/&quot;&gt;native app for your device&lt;/a&gt; instead.') . '&lt;/p&gt;';
</ins><span class="cx">                 return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         $upload_action_url = admin_url('async-upload.php');
</span><span class="cx">         $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
</span><span class="lines">@@ -1438,8 +1431,6 @@
</span><span class="cx">  * @param unknown_type $id
</span><span class="cx">  */
</span><span class="cx"> function media_upload_type_form($type = 'file', $errors = null, $id = null) {
</span><del>-        if ( wp_is_mobile() )
-                return;
</del><span class="cx"> 
</span><span class="cx">         media_upload_header();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminmedianewphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/media-new.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/media-new.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-admin/media-new.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -9,8 +9,4 @@
</span><span class="cx"> $_GET['inline'] = 'true';
</span><span class="cx"> /** Administration bootstrap */
</span><span class="cx"> require_once('./admin.php');
</span><del>-
-if ( wp_is_mobile() ) // cannot upload files from mobile devices
-        return;
-
</del><span class="cx"> require_once('./media-upload.php');
</span></span></pre></div>
<a id="trunkwpadminmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/media.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/media.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-admin/media.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx"> &lt;h2&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> echo esc_html( $title );
</span><del>-if ( current_user_can( 'upload_files' ) &amp;&amp; ! wp_is_mobile() ) { ?&gt;
</del><ins>+if ( current_user_can( 'upload_files' ) ) { ?&gt;
</ins><span class="cx">         &lt;a href=&quot;media-new.php&quot; class=&quot;add-new-h2&quot;&gt;&lt;?php echo esc_html_x('Add New', 'file'); ?&gt;&lt;/a&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> &lt;/h2&gt;
</span></span></pre></div>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-admin/menu.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -56,8 +56,7 @@
</span><span class="cx"> $menu[10] = array( __('Media'), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'div' );
</span><span class="cx">         $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
</span><span class="cx">         /* translators: add new file */
</span><del>-        if ( ! wp_is_mobile() )
-                $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
</del><ins>+        $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
</ins><span class="cx"> 
</span><span class="cx"> $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
</span><span class="cx">         $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
</span></span></pre></div>
<a id="trunkwpadminuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/upload.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/upload.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-admin/upload.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> &lt;h2&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> echo esc_html( $title );
</span><del>-if ( current_user_can( 'upload_files' ) &amp;&amp; ! wp_is_mobile() ) { ?&gt;
</del><ins>+if ( current_user_can( 'upload_files' ) ) { ?&gt;
</ins><span class="cx">         &lt;a href=&quot;media-new.php&quot; class=&quot;add-new-h2&quot;&gt;&lt;?php echo esc_html_x('Add New', 'file'); ?&gt;&lt;/a&gt;&lt;?php
</span><span class="cx"> }
</span><span class="cx"> if ( ! empty( $_REQUEST['s'] ) )
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-includes/admin-bar.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -489,7 +489,7 @@
</span><span class="cx">                 unset( $cpts['post'] );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( current_user_can( 'upload_files' ) &amp;&amp; ! wp_is_mobile() )
</del><ins>+        if ( current_user_can( 'upload_files' ) )
</ins><span class="cx">                 $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
</span><span class="cx"> 
</span><span class="cx">         if ( current_user_can( 'manage_links' ) )
</span></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (20448 => 20449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2012-04-11 22:03:24 UTC (rev 20448)
+++ trunk/wp-includes/functions.php        2012-04-12 00:16:37 UTC (rev 20449)
</span><span class="lines">@@ -3676,3 +3676,26 @@
</span><span class="cx">         return $clean;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * 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;
+        }
+}
+
</ins></span></pre>
</div>
</div>

</body>
</html>