iPhone and iPod touch.
Author: ContentRobot
Version: 0.1.2
Author URI: http://www.contentrobot.com
# Special thanks to Imthiaz Rafiq and the wp-pda Plugin (http://imthi.com/wp-pda/) which this plugin is derived from.
# This plugin is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This plugin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this plugin; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
$trans = array(
'à'=>'à','á'=>'á','ả'=>'ả','ã'=>'ã','ạ'=>'ạ',
'ă'=>'ă','ằ'=>'ằ','ắ'=>'ắ','ẳ'=>'ẳ','ẵ'=>'ẵ','ặ'=>'ặ',
'â'=>'â','ầ'=>'ầ','ấ'=>'ấ','ẩ'=>'ẩ','ẫ'=>'ẫ','ậ'=>'ậ',
'À'=>'À','Á'=>'Á','Ả'=>'Ả','Ã'=>'Ã','Ạ'=>'Ạ',
'Ă'=>'Ă','Ằ'=>'A','Ắ'=>'Ắ','Ẳ'=>'Ẳ','Ẵ'=>'Ẵ','Ặ'=>'Ặ',
'Â'=>'Â','Ầ'=>'Ầ','Ấ'=>'Ấ','Ẩ'=>'Ẩ','Ẫ'=>'Ẫ','Ậ'=>'Ậ',
'Đ'=>'Đ','đ'=>'đ',
'è'=>'è','é'=>'é','ẻ'=>'ẻ','ẽ'=>'ẽ','ẹ'=>'ẹ',
'ê'=>'ê','ề'=>'ề','ế'=>'ế','ể'=>'ể','ễ'=>'ễ','ệ'=>'ệ',
'È'=>'È','É'=>'É','Ẻ'=>'Ẻ','Ẽ'=>'Ẽ','Ẹ'=>'Ẹ',
'Ê'=>'Ê','Ề'=>'Ề','Ế'=>'Ế','Ể'=>'Ể','Ễ'=>'Ễ','Ệ'=>'Ệ',
'ì'=>'ì','í'=>'í','ỉ'=>'ỉ','ĩ'=>'ĩ','ị'=>'ị',
'Ì'=>'Ì','Í'=>'Í','Ỉ'=>'Ỉ','Ĩ'=>'Ĩ','Ị'=>'Ị',
'ò'=>'ò','ó'=>'ó','ỏ'=>'ỏ','õ'=>'õ','ọ'=>'ọ',
'ô'=>'ô','ồ'=>'ồ','ố'=>'ố','ổ'=>'ổ','ỗ'=>'ỗ','ộ'=>'ộ',
'ơ'=>'ơ','ờ'=>'ờ','ớ'=>'ớ','ở'=>'ở','ỡ'=>'ỡ','ợ'=>'ợ',
'Ò'=>'Ờ','Ó'=>'Ớ','Ỏ'=>'Ở','Õ'=>'Ỡ','Ọ'=>'Ợ',
'Ô'=>'Ô','Ồ'=>'Ồ','Ố'=>'Ố','Ổ'=>'Ồ','Ỗ'=>'Ỗ','Ộ'=>'Ộ',
'Ơ'=>'Ơ','Ờ'=>'Ờ','Ớ'=>'Ớ','Ở'=>'Ở','Ỡ'=>'Ỡ','Ợ'=>'Ợ',
'ù'=>'ù','ú'=>'ú','ủ'=>'ủ','ũ'=>'ũ','ụ'=>'ụ',
'ư'=>'ư','ừ'=>'ừ','ứ'=>'ứ','ử'=>'ử','ữ'=>'ữ','ự'=>'ự',
'Ù'=>'Ù','Ú'=>'Ú','Ủ'=>'Ủ','Ũ'=>'Ũ','Ụ'=>'Ụ',
'Ư'=>'Ư','Ừ'=>'Ừ','Ứ'=>'Ứ','Ử'=>'Ử','Ữ'=>'Ữ','Ự'=>'Ự',
'ỳ'=>'ỳ','ý'=>'ý','ỷ'=>'ỷ','ỹ'=>'ỹ','ỵ'=>'ỵ',
'Y'=>'Y','Ỳ'=>'Ỳ','Ý'=>'Ý','Ỷ'=>'Ỷ','Ỹ'=>'Ỹ','Ỵ'=>'Ỵ'
);
*/
function remove_vietnamese_accents($string) {
$trans = array(
'à'=>'a','á'=>'a','ả'=>'a','ã'=>'a','ạ'=>'a',
'ă'=>'a','ằ'=>'a','ắ'=>'a','ẳ'=>'a','ẵ'=>'a','ặ'=>'a',
'â'=>'a','ầ'=>'a','ấ'=>'a','ẩ'=>'a','ẫ'=>'a','ậ'=>'a',
'À'=>'a','Á'=>'a','Ả'=>'a','Ã'=>'a','Ạ'=>'a',
'Ă'=>'A','Ằ'=>'A','Ắ'=>'A','Ẳ'=>'A','Ẵ'=>'A','Ặ'=>'A',
'Â'=>'A','Ầ'=>'A','Ấ'=>'A','Ẩ'=>'A','Ẫ'=>'A','Ậ'=>'A',
'Đ'=>'D','đ'=>'d',
'è'=>'e','é'=>'e','ẻ'=>'e','ẽ'=>'e','ẹ'=>'e',
'ê'=>'e','ề'=>'e','ế'=>'e','ể'=>'e','ễ'=>'e','ệ'=>'e',
'È'=>'E','É'=>'E','Ẻ'=>'E','Ẽ'=>'E','Ẹ'=>'E',
'Ê'=>'E','Ề'=>'E','Ế'=>'E','Ể'=>'E','Ễ'=>'E','Ệ'=>'E',
'ì'=>'i','í'=>'i','ỉ'=>'i','ĩ'=>'i','ị'=>'i',
'Ì'=>'I','Í'=>'I','Ỉ'=>'I','Ĩ'=>'I','Ị'=>'I',
'ò'=>'o','ó'=>'o','ỏ'=>'o','õ'=>'o','ọ'=>'o',
'ô'=>'o','ồ'=>'o','ố'=>'o','ổ'=>'o','ỗ'=>'o','ộ'=>'o',
'ơ'=>'o','ờ'=>'o','ớ'=>'o','ở'=>'o','ỡ'=>'o','ợ'=>'o',
'Ò'=>'O','Ó'=>'O','Ỏ'=>'O','Õ'=>'O','Ọ'=>'O',
'Ô'=>'O','Ồ'=>'O','Ố'=>'O','Ổ'=>'O','Ỗ'=>'O','Ộ'=>'O',
'Ơ'=>'O','Ờ'=>'O','Ớ'=>'O','Ở'=>'O','Ỡ'=>'O','Ợ'=>'O',
'ù'=>'u','ú'=>'u','ủ'=>'u','ũ'=>'u','ụ'=>'u',
'ư'=>'u','ừ'=>'u','ứ'=>'u','ử'=>'u','ữ'=>'u','ự'=>'u',
'Ù'=>'U','Ú'=>'U','Ủ'=>'U','Ũ'=>'U','Ụ'=>'U',
'Ư'=>'U','Ừ'=>'U','Ứ'=>'U','Ử'=>'U','Ữ'=>'U','Ự'=>'U',
'ỳ'=>'y','ý'=>'y','ỷ'=>'y','ỹ'=>'y','ỵ'=>'y',
'Y'=>'Y','Ỳ'=>'Y','Ý'=>'Y','Ỷ'=>'Y','Ỹ'=>'Y','Ỵ'=>'Y'
);
return strtr($string, $trans);
}
class iWPhonePlugin{
var $iphone;
function iWPhonePlugin(){
$this->iphone = false;
add_action('plugins_loaded',array(&$this,'detectiPhone'));
add_filter('stylesheet',array(&$this,'get_stylesheet'));
add_filter('template',array(&$this,'get_template'));
}
function detectiPhone($query){
$container = $_SERVER['HTTP_USER_AGENT'];
//print_r($container); //this prints out the user agent array. uncomment to see it shown on page.
$useragents = array (
"iPhone","iPod");
$this->iphone = false;
foreach ( $useragents as $useragent ) {
if (eregi($useragent,$container)){
$this->iphone = true;
}
}
if ($this->iphone) {
add_filter('the_content','remove_vietnamese_accents');
add_filter('comment_text','remove_vietnamese_accents');
add_filter('the_title','remove_vietnamese_accents');
add_filter('the_category','remove_vietnamese_accents');
add_filter('single_cat_title','remove_vietnamese_accents');
add_filter('comment_author','remove_vietnamese_accents');
}
/*if($this->iphone){
echo ("You are on an iPhone or iPod touch - Lucky you!
");
}else{
echo ("You are not on an iPhone or iPod touch - Too bad :(
");
}*/
}
function get_stylesheet($stylesheet) {
if($this->iphone){
return 'iwphone-by-contentrobot';
}else{
return $stylesheet;
}
}
function get_template($template) {
if($this->iphone){
return 'iwphone-by-contentrobot';
}else{
return $template;
}
}
}
$wp_iwphone = new iWPhonePlugin();
?>