Ticket #18893: current_web_browser.patch
| File current_web_browser.patch, 5.1 KB (added by azaozz, 20 months ago) |
|---|
-
wp-includes/general-template.php
1713 1713 * @return bool 1714 1714 */ 1715 1715 function user_can_richedit() { 1716 global $wp_rich_edit, $pagenow, $is_iphone; 1716 global $current_web_browser; 1717 static $can_richedit = null; 1717 1718 1718 if ( !isset( $wp_rich_edit) ) { 1719 if ( get_user_option( 'rich_editing' ) == 'true' && 1720 !$is_iphone && // this includes all Safari mobile browsers 1721 ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || 1722 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) 1723 ) { 1724 $wp_rich_edit = true; 1725 } else { 1726 $wp_rich_edit = false; 1727 } 1719 if ( $can_richedit === null ) { 1720 if ( get_user_option( 'rich_editing' ) == 'true' && !empty($current_web_browser['richedit']) ) 1721 $can_richedit = true; 1722 else 1723 $can_richedit = false; 1728 1724 } 1729 1725 1730 return apply_filters('user_can_richedit', $ wp_rich_edit);1726 return apply_filters('user_can_richedit', $can_richedit); 1731 1727 } 1732 1728 1733 1729 /** -
wp-includes/vars.php
43 43 // Simple browser detection 44 44 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false; 45 45 46 $current_web_browser = array( 47 'name' => '', 48 'engine' => '', 49 'engine_version' => '', 50 'os' => '', 51 'device' => '', 52 'richedit' => false, 53 'platform' => '' 54 ); 55 46 56 if ( isset($_SERVER['HTTP_USER_AGENT']) ) { 47 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) { 57 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) { // is this still needed? 48 58 $is_lynx = true; 59 $current_web_browser['name'] = 'Lynx'; 60 $current_web_browser['os'] = 'Linux'; 49 61 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) { 50 62 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { 51 63 if ( $is_chrome = apply_filters( 'use_google_chrome_frame', is_admin() ) ) … … 54 66 } else { 55 67 $is_chrome = true; 56 68 } 69 $current_web_browser['name'] = 'Chrome'; 70 $current_web_browser['engine'] = 'WebKit'; 57 71 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) { 58 72 $is_safari = true; 73 $current_web_browser['name'] = 'Safari'; 74 $current_web_browser['engine'] = 'WebKit'; 59 75 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) { 60 76 $is_gecko = true; 61 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) { 62 $is_winIE = true; 63 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) { 64 $is_macIE = true; 77 $current_web_browser['engine'] = 'Gecko'; 78 79 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false ) 80 $current_web_browser['name'] = 'Firefox'; 81 82 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false ) { 83 $is_IE = $is_winIE = true; 84 $current_web_browser['name'] = $current_web_browser['engine'] = 'MSIE'; 65 85 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) { 66 86 $is_opera = true; 67 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {68 $ is_NS4 = true;87 $current_web_browser['name'] = 'Opera'; 88 $current_web_browser['engine'] = 'Presto'; 69 89 } 70 90 } 71 91 72 if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false ) 73 $is_iphone = true;92 function _current_web_browser() { 93 global $current_web_browser, $is_safari, $is_iphone; 74 94 75 $is_IE = ( $is_macIE || $is_winIE ); 95 $matches = array(); 96 if ( stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) { 97 $current_web_browser['platform'] = 'mobile'; 76 98 99 if ( preg_match('/(iphone|ipod|ipad|blackberry|android)/i', $_SERVER['HTTP_USER_AGENT'], $matches) ) 100 $current_web_browser['device'] = $matches[1]; 101 102 // back compat 103 if ( $is_safari ) 104 $is_iphone = true; 105 106 } elseif ( preg_match('/(spider|crawl|slurp|bot)/i', $_SERVER['HTTP_USER_AGENT']) ) { 107 $current_web_browser['platform'] = 'bot'; 108 } 109 110 if ( preg_match('/(windows|linux|macintosh|solaris|bsd)/i', $_SERVER['HTTP_USER_AGENT'], $matches) ) { 111 $current_web_browser['os'] = $matches[1]; 112 113 if ( empty($current_web_browser['platform']) ) { 114 $current_web_browser['platform'] = 'desktop'; 115 $current_web_browser['device'] = 'pc'; // includes laptops 116 $current_web_browser['richedit'] = true; 117 } 118 } 119 120 if ( preg_match('!(?:AppleWebKit/|Gecko/|Presto/|MSIE )([0-9.]+)!', $_SERVER['HTTP_USER_AGENT'], $matches) ) 121 $current_web_browser['engine_version'] = round( (float) $matches[1], 2 ); 122 123 if ( $current_web_browser['engine'] == 'WebKit' && $current_web_browser['engine_version'] >= 534 ) 124 $current_web_browser['richedit'] = true; 125 } 126 _current_web_browser(); 127 77 128 // Server detection 78 129 79 130 /**
