Changeset 37002

Show
Ignore:
Timestamp:
03/31/08 05:20:39 (4 months ago)
Author:
alexkingorg
Message:

updates to try to help people that don't RTFM

Location:
wordpress-mobile-edition/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • wordpress-mobile-edition/trunk/README.txt

    r25078 r37002  
    33Contributors: alexkingorg 
    44Minimum version: 1.5 
    5 Tested with: 2.0.5 
    6 Stable tag: 2.0 
     5Tested with: 2.5 
     6Stable tag: 2.1 
    77 
    88WordPress Mobile Edition is a plugin that shows an interface designed for a mobile device when visitors come to your site on a mobile device. 
     
    2929 
    3030 
    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? = 
    3232 
    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. 
     33Yes, 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(); ?>` 
    3436 
    3537 
  • wordpress-mobile-edition/trunk/wp-mobile.php

    r35986 r37002  
    33// WordPress Mobile Edition 
    44// 
    5 // Copyright (c) 2002-2006 Alex King 
     5// Copyright (c) 2002-2008 Alex King 
    66// http://alexking.org/projects/wordpress 
    77// 
     
    2121Author: Alex King 
    2222Author URI: http://alexking.org 
    23 Version: 2.1dev 
     23Version: 2.1 
    2424*/  
     25 
     26if (!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} 
    2539 
    2640$_SERVER['REQUEST_URI'] = ( isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_NAME'] . (( isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''))); 
     
    109123 
    110124function 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 
     133function akm_installed() { 
     134      return is_dir(ABSPATH.'/wp-content/themes/wp-mobile'); 
     135} 
     136 
     137function 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 
     141if (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      } 
    112146} 
    113147 
    114148function 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 
     152function akm_mobile_link() { 
     153      echo '<a href="'.get_bloginfo('wpurl').'/index.php?ak_action=force_mobile">Mobile Edition</a>'; 
    116154} 
    117155 
     
    159197} 
    160198 
    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']; 
     199function 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']; 
    197205            } 
    198206            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} 
     245add_action('init', 'akm_request_handler'); 
    205246 
    206247if (akm_check_mobile()) {