Changeset 37002
- Timestamp:
- 03/31/08 05:20:39 (4 months ago)
- Location:
- wordpress-mobile-edition/trunk
- Files:
-
- 2 modified
-
README.txt (modified) (2 diffs)
-
wp-mobile.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-mobile-edition/trunk/README.txt
r25078 r37002 3 3 Contributors: alexkingorg 4 4 Minimum version: 1.5 5 Tested with: 2. 0.56 Stable tag: 2. 05 Tested with: 2.5 6 Stable tag: 2.1 7 7 8 8 WordPress Mobile Edition is a plugin that shows an interface designed for a mobile device when visitors come to your site on a mobile device. … … 29 29 30 30 31 = I visited the site in a mobile browser and my theme was reset to default, why? =31 = Can I create a link that forces someone to see the mobile version? = 32 32 33 Probably because you missed step 2 in the installation directions above. If the requested theme is not available, WordPress will reset your theme to the default. 33 Yes, this is included as an experimental feature in version 2.1. The link can be added to your theme by using the akm_mobile_link() template tag: 34 35 `<?php akm_mobile_link(); ?>` 34 36 35 37 -
wordpress-mobile-edition/trunk/wp-mobile.php
r35986 r37002 3 3 // WordPress Mobile Edition 4 4 // 5 // Copyright (c) 2002-200 6Alex King5 // Copyright (c) 2002-2008 Alex King 6 6 // http://alexking.org/projects/wordpress 7 7 // … … 21 21 Author: Alex King 22 22 Author URI: http://alexking.org 23 Version: 2.1 dev23 Version: 2.1 24 24 */ 25 26 if (!function_exists('is_admin_page')) { 27 function is_admin_page() { 28 if (function_exists('is_admin')) { 29 return is_admin(); 30 } 31 if (function_exists('check_admin_referer')) { 32 return true; 33 } 34 else { 35 return false; 36 } 37 } 38 } 25 39 26 40 $_SERVER['REQUEST_URI'] = ( isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_NAME'] . (( isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''))); … … 109 123 110 124 function akm_template($theme) { 111 return apply_filters('akm_template', 'wp-mobile'); 125 if (akm_installed()) { 126 return apply_filters('akm_template', 'wp-mobile'); 127 } 128 else { 129 return $theme; 130 } 131 } 132 133 function akm_installed() { 134 return is_dir(ABSPATH.'/wp-content/themes/wp-mobile'); 135 } 136 137 function akm_misinstalled($content) { 138 return $content.'<p>WordPress Mobile Edition has been incorrectly installed. Please follow the steps in the README to install it correctly or disable the plugin.</p>'; 139 } 140 141 if (is_admin_page() && !akm_installed()) { 142 global $wp_version; 143 if (isset($wp_version) && version_compare($wp_version, '2.5', '>=')) { 144 add_action('admin_notices', create_function( '', "echo '<div class=\"error\">WP Mobile is incorrectly installed. Please check the <a href=\"http://alexking.org/projects/wordpress/readme?project=wordpress-mobile-edition\">README</a>.</div>';" ) ); 145 } 112 146 } 113 147 114 148 function akm_mobile_available($content) { 115 return $content.'<p><a href="'.get_bloginfo('wpurl').'/wp-admin/options-general.php?ak_action=accept_mobile">Return to the Mobile Edition</a>.</p>'; 149 return $content.'<p><a href="'.get_bloginfo('wpurl').'/index.php?ak_action=accept_mobile">Return to the Mobile Edition</a>.</p>'; 150 } 151 152 function akm_mobile_link() { 153 echo '<a href="'.get_bloginfo('wpurl').'/index.php?ak_action=force_mobile">Mobile Edition</a>'; 116 154 } 117 155 … … 159 197 } 160 198 161 if (isset($_GET['ak_action'])) { 162 $url = parse_url(get_bloginfo('home')); 163 $domain = $url['host']; 164 if (!empty($url['path'])) { 165 $path = $url['path']; 166 } 167 else { 168 $path = '/'; 169 } 170 $redirect = false; 171 switch ($_GET['ak_action']) { 172 case 'reject_mobile': 173 setcookie( 174 'akm_mobile' 175 , 'false' 176 , time() + 300000 177 , $path 178 , $domain 179 ); 180 $redirect = true; 181 break; 182 case 'force_mobile': 183 case 'accept_mobile': 184 setcookie( 185 'akm_mobile' 186 , 'true' 187 , time() + 300000 188 , $path 189 , $domain 190 ); 191 $redirect = true; 192 break; 193 } 194 if ($redirect) { 195 if (!empty($_SERVER['HTTP_REFERER'])) { 196 $go = $_SERVER['HTTP_REFERER']; 199 function akm_request_handler() { 200 if (isset($_GET['ak_action'])) { 201 $url = parse_url(get_bloginfo('home')); 202 $domain = $url['host']; 203 if (!empty($url['path'])) { 204 $path = $url['path']; 197 205 } 198 206 else { 199 $go = get_bloginfo('home'); 200 } 201 header('Location: '.$go); 202 die(); 203 } 204 } 207 $path = '/'; 208 } 209 $redirect = false; 210 switch ($_GET['ak_action']) { 211 case 'reject_mobile': 212 setcookie( 213 'akm_mobile' 214 , 'false' 215 , time() + 300000 216 , $path 217 , $domain 218 ); 219 $redirect = true; 220 break; 221 case 'force_mobile': 222 case 'accept_mobile': 223 setcookie( 224 'akm_mobile' 225 , 'true' 226 , time() + 300000 227 , $path 228 , $domain 229 ); 230 $redirect = true; 231 break; 232 } 233 if ($redirect) { 234 if (!empty($_SERVER['HTTP_REFERER'])) { 235 $go = $_SERVER['HTTP_REFERER']; 236 } 237 else { 238 $go = get_bloginfo('home'); 239 } 240 header('Location: '.$go); 241 die(); 242 } 243 } 244 } 245 add_action('init', 'akm_request_handler'); 205 246 206 247 if (akm_check_mobile()) {
