2 /* |
2 /* |
3 Plugin Name: xili-theme-select |
3 Plugin Name: xili-theme-select |
4 Plugin URI: http://dev.xiligroup.com/xilitheme-select/ |
4 Plugin URI: http://dev.xiligroup.com/xilitheme-select/ |
5 Description: A plugin for WordPress that automatically redirects your blog's theme for optimized viewing on Apple's <a href="http://www.apple.com/iphone/">iPhone</a> and <a href="http://www.apple.com/ipodtouch/">iPod touch</a>. |
5 Description: A plugin for WordPress that automatically redirects your blog's theme for optimized viewing on Apple's <a href="http://www.apple.com/iphone/">iPhone</a> and <a href="http://www.apple.com/ipodtouch/">iPod touch</a>. |
6 Author: MS xiligroup dev |
6 Author: MS xiligroup dev |
7 Version: 1.0.1 |
7 Version: 1.0.3 |
8 Author URI: http://dev.xiligroup.com |
8 Author URI: http://dev.xiligroup.com |
9 |
9 |
10 # inspired initially from iwphone from Robot Content - 2007 - (http://www.contentrobot.com) |
10 # inspired initially from iwphone from Robot Content - 2007 - (http://www.contentrobot.com) |
11 # 2008-10 : optimized rewritting with class and optional dashboard settings |
11 # 2008-10 : optimized rewritting with class and optional dashboard settings |
12 # the "iphone / itouch" theme folder must have the same name with an extension ('_4touch') declared in instantiation |
12 # the "iphone / itouch" theme folder must have the same name with an extension ('_4touch') declared in instantiation |
31 # License along with this plugin; if not, write to the Free Software |
31 # License along with this plugin; if not, write to the Free Software |
32 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
32 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
33 |
33 |
34 */ |
34 */ |
35 |
35 |
36 define('XILITHEME_VER','1.0.1'); |
36 define('XILITHEME_VER','1.0.3'); |
37 |
37 |
38 class xilithemeselector{ |
38 class xilithemeselector{ |
39 |
39 |
40 var $themextend = ""; /*no extension = no touch theme*/ |
40 var $themextend = ""; /*no extension = no touch theme*/ |
41 var $iphone = false; |
41 var $iphone = false; |
42 var $currentthemefolder; /*the normal theme used by default*/ |
42 var $currentthemefolder; /*the normal theme used by default*/ |
43 var $newfolder; |
43 var $newfolder; |
44 var $listofdevices = array("iPhone","iPod"); /* if present selector is activated - can be upgraded !*/ |
44 var $listofdevices = array("iPhone","iPod"); /* if present selector is activated - can be upgraded ! - iPad if you need !!*/ |
45 var $xitype; /*type of the selected device*/ |
45 var $xitype; /*type of the selected device*/ |
46 var $xiversion; /*release of the selected device*/ |
46 var $xiversion; /*release of the selected device*/ |
47 /**/ |
47 /**/ |
48 var $testnoappledevices = true; /* if true call a function to check no apple devices*/ |
48 var $testnoappledevices = true; /* if true call a function to check no apple devices*/ |
49 var $othermobile = false; |
49 var $othermobile = false; |
116 |
116 |
117 |
117 |
118 |
118 |
119 function detectiPhone($query){ |
119 function detectiPhone($query){ |
120 /* prepare target theme folders according options and test them */ |
120 /* prepare target theme folders according options and test them */ |
121 $this->currentthemefolder = str_replace(get_theme_root()."/","",get_template_directory()); |
121 |
|
122 $this->currentthemefolder = str_replace(get_theme_root()."/","",get_stylesheet_directory()); |
|
123 |
122 if($this->isfullname) : |
124 if($this->isfullname) : |
123 /*test if theme with fullname exist*/ |
125 /*test if theme with fullname exist*/ |
124 $curpath = get_theme_root()."/".$this->xilithemefullname; |
126 $curpath = get_theme_root()."/".$this->xilithemefullname; |
125 if (file_exists($curpath)) : |
127 if (file_exists($curpath)) : |
126 $this->newfolder = $this->xilithemefullname; |
128 $this->newfolder = $this->xilithemefullname; |
331 |
333 |
332 ?> |
334 ?> |
333 <div class='wrap'> |
335 <div class='wrap'> |
334 <h2><?php _e("Xilitheme select settings","xilithemeselect"); ?></h2> |
336 <h2><?php _e("Xilitheme select settings","xilithemeselect"); ?></h2> |
335 <p><cite><a href='http://www.xiliphone.mobi' target='_blank'>Xilitheme select</a></cite> <?php _e("provides an automatic selection of the theme for iphone's user when visiting your site.<br />Don't forget to upload a specific theme for ipod touch / iphone with a right folder's name in the wp-content/themes folder.<br /> If an error occur, the current theme is displayed in ipod touch / iphone browser.","xilithemeselect"); ?></p> |
337 <p><cite><a href='http://www.xiliphone.mobi' target='_blank'>Xilitheme select</a></cite> <?php _e("provides an automatic selection of the theme for iphone's user when visiting your site.<br />Don't forget to upload a specific theme for ipod touch / iphone with a right folder's name in the wp-content/themes folder.<br /> If an error occur, the current theme is displayed in ipod touch / iphone browser.","xilithemeselect"); ?></p> |
336 <p><?php _e("the current theme is","xilithemeselect"); echo ": <em>".$this->currentthemefolder ?>. </em><strong><br /> |
338 <p><?php |
|
339 |
|
340 if (function_exists('is_child_theme') && is_child_theme() ) { |
|
341 $theme_name = get_option("stylesheet").' '.__('child of','xili-language').' '.get_option("template"); |
|
342 } else { |
|
343 $theme_name = get_option("template"); |
|
344 } |
|
345 _e("the current theme is","xilithemeselect"); echo ": <em>".$theme_name ?>. </em><strong><br /> |
337 <?php _e("itouch theme's folder","xilithemeselect"); echo ": <em>".$this->currentthemefolder.$this->xilithemeextension."</em> "; |
346 <?php _e("itouch theme's folder","xilithemeselect"); echo ": <em>".$this->currentthemefolder.$this->xilithemeextension."</em> "; |
338 $curpath = get_theme_root()."/".$this->currentthemefolder.$this->xilithemeextension; |
347 $curpath = get_theme_root()."/".$this->currentthemefolder.$this->xilithemeextension; |
339 if (file_exists($curpath)) : |
348 if (file_exists($curpath)) : |
340 _e("is available","xilithemeselect"); |
349 _e("is available","xilithemeselect"); |
341 else : |
350 else : |
397 global $wp_ismobile; |
406 global $wp_ismobile; |
398 $wp_ismobile = new xilithemeselector(true); //true if dashboard part - false w/o dashboard - see doc on top |
407 $wp_ismobile = new xilithemeselector(true); //true if dashboard part - false w/o dashboard - see doc on top |
399 $wp_ismobile->cookienable = 1; /*0 to disable*/ |
408 $wp_ismobile->cookienable = 1; /*0 to disable*/ |
400 |
409 |
401 /**** tag insertable in the theme's footer or elsewhere ****/ |
410 /**** tag insertable in the theme's footer or elsewhere ****/ |
402 /* example 1 (in browser): if (function_exists('the_xilithemelink')) the_xilithemelink('mobbro=<img src="'.get_bloginfo("template_directory").'/images/mobilelink.gif" alt=""/>'); |
411 /* example 1 (in browser): if (function_exists('the_xilithemelink')) the_xilithemelink('mobbro=<img src="'.get_bloginfo("stylesheet_directory").'/images/mobilelink.gif" alt=""/>'); |
403 */ |
412 */ |
404 /* example 2 (in mobilebrowser): if (function_exists('the_xilithemelink')) the_xilithemelink('bro=naviguer en mode normal'); |
413 /* example 2 (in mobilebrowser): if (function_exists('the_xilithemelink')) the_xilithemelink('bro=naviguer en mode normal'); |
405 */ |
414 */ |
406 function the_xilithemelink($args = ''){ |
415 function the_xilithemelink($args = ''){ |
407 |
416 |