Introduce wp_is_mobile() and use it instead of $is_iphone global, see #20014
git-svn-id: https://develop.svn.wordpress.org/trunk@20417 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fdce6271d0
commit
bce0d37a67
@ -11,7 +11,7 @@ if ( ! defined( 'WP_ADMIN' ) )
|
|||||||
require_once( './admin.php' );
|
require_once( './admin.php' );
|
||||||
|
|
||||||
// In case admin-header.php is included in a function.
|
// In case admin-header.php is included in a function.
|
||||||
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version, $is_iphone,
|
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $wp_version,
|
||||||
$current_site, $update_title, $total_update_count, $parent_file;
|
$current_site, $update_title, $total_update_count, $parent_file;
|
||||||
|
|
||||||
// Catch plugins that include admin-header.php before admin.php completes.
|
// Catch plugins that include admin-header.php before admin.php completes.
|
||||||
@ -87,9 +87,10 @@ $admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-
|
|||||||
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
|
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
|
||||||
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
|
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
|
||||||
|
|
||||||
if ( $is_iphone ) { ?>
|
if ( wp_is_mobile() )
|
||||||
<style type="text/css">.row-actions{visibility:visible;}</style>
|
$admin_body_class .= ' mobile';
|
||||||
<?php } ?>
|
|
||||||
|
?>
|
||||||
</head>
|
</head>
|
||||||
<body class="wp-admin no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
|
<body class="wp-admin no-js <?php echo apply_filters( 'admin_body_class', '' ) . " $admin_body_class"; ?>">
|
||||||
<script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
|
<script type="text/javascript">document.body.className = document.body.className.replace('no-js','js');</script>
|
||||||
|
@ -5323,6 +5323,10 @@ p.pagenav {
|
|||||||
padding: 2px 0 0;
|
padding: 2px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mobile .row-actions {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
tr:hover .row-actions,
|
tr:hover .row-actions,
|
||||||
div.comment-item:hover .row-actions {
|
div.comment-item:hover .row-actions {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
|
@ -62,10 +62,10 @@ add_filter('media_upload_tabs', 'update_gallery_tab');
|
|||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*/
|
*/
|
||||||
function the_media_upload_tabs() {
|
function the_media_upload_tabs() {
|
||||||
global $redir_tab, $is_iphone;
|
global $redir_tab;
|
||||||
$tabs = media_upload_tabs();
|
$tabs = media_upload_tabs();
|
||||||
|
|
||||||
if ( $is_iphone ) {
|
if ( wp_is_mobile() ) {
|
||||||
unset($tabs['type']);
|
unset($tabs['type']);
|
||||||
$default = 'type_url';
|
$default = 'type_url';
|
||||||
} else {
|
} else {
|
||||||
@ -528,8 +528,6 @@ function media_upload_form_handler() {
|
|||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
function wp_media_upload_handler() {
|
function wp_media_upload_handler() {
|
||||||
global $is_iphone;
|
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
@ -600,7 +598,7 @@ function wp_media_upload_handler() {
|
|||||||
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
|
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $is_iphone )
|
if ( wp_is_mobile() )
|
||||||
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
|
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
|
||||||
else
|
else
|
||||||
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
|
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
|
||||||
@ -1306,9 +1304,9 @@ function media_upload_header() {
|
|||||||
* @param unknown_type $errors
|
* @param unknown_type $errors
|
||||||
*/
|
*/
|
||||||
function media_upload_form( $errors = null ) {
|
function media_upload_form( $errors = null ) {
|
||||||
global $type, $tab, $pagenow, $is_IE, $is_opera, $is_iphone;
|
global $type, $tab, $pagenow, $is_IE, $is_opera;
|
||||||
|
|
||||||
if ( $is_iphone )
|
if ( wp_is_mobile() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$upload_action_url = admin_url('async-upload.php');
|
$upload_action_url = admin_url('async-upload.php');
|
||||||
@ -1440,9 +1438,7 @@ if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
|
|||||||
* @param unknown_type $id
|
* @param unknown_type $id
|
||||||
*/
|
*/
|
||||||
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
||||||
global $is_iphone;
|
if ( wp_is_mobile() )
|
||||||
|
|
||||||
if ( $is_iphone )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
media_upload_header();
|
media_upload_header();
|
||||||
|
@ -583,8 +583,9 @@ foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _ipad_meta() {
|
function _ipad_meta() {
|
||||||
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false ) { ?>
|
if ( wp_is_mobile() ) {
|
||||||
<meta name="viewport" id="ipad-viewportmeta" content="width=device-width, initial-scale=1">
|
?>
|
||||||
|
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var postboxes, is_iPad = navigator.userAgent.match(/iPad/);
|
var postboxes;
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
postboxes = {
|
postboxes = {
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
* @subpackage Administration
|
* @subpackage Administration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
global $is_iphone;
|
if ( wp_is_mobile() ) // cannot upload files from mobile devices
|
||||||
|
|
||||||
if ( $is_iphone ) // cannot upload files from iPhone/iPad
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$_GET['inline'] = 'true';
|
$_GET['inline'] = 'true';
|
||||||
|
@ -56,7 +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' );
|
$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');
|
$submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
|
||||||
/* translators: add new file */
|
/* translators: add new file */
|
||||||
if ( !$is_iphone )
|
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' );
|
$menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'div' );
|
||||||
|
@ -321,7 +321,7 @@ class WP_Admin_Bar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final protected function _render( $root ) {
|
final protected function _render( $root ) {
|
||||||
global $is_IE, $is_iphone;
|
global $is_IE;
|
||||||
|
|
||||||
// Add browser classes.
|
// Add browser classes.
|
||||||
// We have to do this here since admin bar shows on the front end.
|
// We have to do this here since admin bar shows on the front end.
|
||||||
@ -333,7 +333,7 @@ class WP_Admin_Bar {
|
|||||||
$class .= ' ie8';
|
$class .= ' ie8';
|
||||||
elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) )
|
elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) )
|
||||||
$class .= ' ie9';
|
$class .= ' ie9';
|
||||||
} elseif ( $is_iphone ) {
|
} elseif ( wp_is_mobile() ) {
|
||||||
$class .= ' mobile';
|
$class .= ' mobile';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1746,14 +1746,14 @@ function rich_edit_exists() {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function user_can_richedit() {
|
function user_can_richedit() {
|
||||||
global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_iphone, $is_IE;
|
global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
|
||||||
|
|
||||||
if ( !isset($wp_rich_edit) ) {
|
if ( !isset($wp_rich_edit) ) {
|
||||||
$wp_rich_edit = false;
|
$wp_rich_edit = false;
|
||||||
|
|
||||||
if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
|
if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
|
||||||
if ( $is_safari ) {
|
if ( $is_safari ) {
|
||||||
if ( $is_iphone || false !== strpos( $_SERVER['HTTP_USER_AGENT'], '; Silk/' ) )
|
if ( wp_is_mobile() || false !== strpos( $_SERVER['HTTP_USER_AGENT'], '; Silk/' ) )
|
||||||
$wp_rich_edit = ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
|
$wp_rich_edit = ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
|
||||||
else
|
else
|
||||||
$wp_rich_edit = true;
|
$wp_rich_edit = true;
|
||||||
|
@ -97,3 +97,28 @@ $is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !
|
|||||||
* @global bool $is_iis7
|
* @global bool $is_iis7
|
||||||
*/
|
*/
|
||||||
$is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
|
$is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the current browser runs on a mobile device (smart phone, tablet, etc.)
|
||||||
|
*
|
||||||
|
* @return bool true|false
|
||||||
|
*/
|
||||||
|
function wp_is_mobile() {
|
||||||
|
static $is_mobile;
|
||||||
|
|
||||||
|
if ( isset($is_mobile) )
|
||||||
|
return $is_mobile;
|
||||||
|
|
||||||
|
if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
|
||||||
|
$is_mobile = false;
|
||||||
|
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)
|
||||||
|
|| strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
|
||||||
|
|| strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false
|
||||||
|
|| strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) {
|
||||||
|
$is_mobile = true;
|
||||||
|
} else {
|
||||||
|
$is_mobile = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $is_mobile;
|
||||||
|
}
|
||||||
|
17
wp-login.php
17
wp-login.php
@ -39,7 +39,7 @@ if ( force_ssl_admin() && !is_ssl() ) {
|
|||||||
* @param WP_Error $wp_error Optional. WordPress Error Object
|
* @param WP_Error $wp_error Optional. WordPress Error Object
|
||||||
*/
|
*/
|
||||||
function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
||||||
global $error, $is_iphone, $interim_login, $current_site;
|
global $error, $interim_login, $current_site;
|
||||||
|
|
||||||
// Don't index any of these forms
|
// Don't index any of these forms
|
||||||
add_action( 'login_head', 'wp_no_robots' );
|
add_action( 'login_head', 'wp_no_robots' );
|
||||||
@ -54,17 +54,18 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
|||||||
if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
|
if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
|
||||||
add_action( 'login_head', 'wp_shake_js', 12 );
|
add_action( 'login_head', 'wp_shake_js', 12 );
|
||||||
|
|
||||||
?>
|
?><!DOCTYPE html>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
|
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
|
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
|
||||||
<title><?php bloginfo('name'); ?> › <?php echo $title; ?></title>
|
<title><?php bloginfo('name'); ?> › <?php echo $title; ?></title>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
wp_admin_css( 'wp-admin', true );
|
wp_admin_css( 'wp-admin', true );
|
||||||
wp_admin_css( 'colors-fresh', true );
|
wp_admin_css( 'colors-fresh', true );
|
||||||
|
|
||||||
if ( $is_iphone ) { ?>
|
if ( wp_is_mobile() ) {
|
||||||
|
?>
|
||||||
<meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
|
<meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
.login form, .login .message, #login_error { margin-left: 0px; }
|
.login form, .login .message, #login_error { margin-left: 0px; }
|
||||||
@ -88,16 +89,19 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
|
|||||||
|
|
||||||
$login_header_url = apply_filters( 'login_headerurl', $login_header_url );
|
$login_header_url = apply_filters( 'login_headerurl', $login_header_url );
|
||||||
$login_header_title = apply_filters( 'login_headertitle', $login_header_title );
|
$login_header_title = apply_filters( 'login_headertitle', $login_header_title );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</head>
|
</head>
|
||||||
<body class="login">
|
<body class="login">
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
|
<h1><a href="<?php echo esc_url( $login_header_url ); ?>" title="<?php echo esc_attr( $login_header_title ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
unset( $login_header_url, $login_header_title );
|
unset( $login_header_url, $login_header_title );
|
||||||
|
|
||||||
$message = apply_filters('login_message', $message);
|
$message = apply_filters('login_message', $message);
|
||||||
if ( !empty( $message ) ) echo $message . "\n";
|
if ( !empty( $message ) )
|
||||||
|
echo $message . "\n";
|
||||||
|
|
||||||
// In case a plugin uses $error rather than the $wp_errors object
|
// In case a plugin uses $error rather than the $wp_errors object
|
||||||
if ( !empty( $error ) ) {
|
if ( !empty( $error ) ) {
|
||||||
@ -149,8 +153,7 @@ if(typeof wpOnload=='function')wpOnload();
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wp_shake_js() {
|
function wp_shake_js() {
|
||||||
global $is_iphone;
|
if ( wp_is_mobile() )
|
||||||
if ( $is_iphone )
|
|
||||||
return;
|
return;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
Loading…
Reference in New Issue
Block a user