[博客] Emlog ThemeSwitcher多设备主题切换器插件

[复制链接]
发表于 2022-4-25 18:03:48
插件描述:
ThemeSwitcherForMultiDevice是一款为Emlog提供的根据设备自动切换主题的ThemeSwitcherForEmlog插件
Emlog多个版本插件的使用前提(包含3个必做步骤):
1、修改插件文件ThemeSwitcher.php中大概59行,注释index_head挂载点语句;
//addAction('index_head', 'ThemeSwitcher_head');//主要是去注释其函数中的header跳转语句
复制代码
2、根目录的index.php和微语目录的t/index.php中代码替换
define('TEMPLATE_PATH', TPLS_PATH.Option::get('nonce_templet').'/');
复制代码
替换为
define('TEMPLATE_PATH', TPLS_PATH.TEMPLATE_NAME.'/');
复制代码
3、根目录的init.php中代码替换(需要保持插件启用状态):
define('TEMPLATE_URL',         TPLS_URL.Option::get('nonce_templet').'/');
复制代码
替换为:

session_start();//如果init.php中有了就删掉此语句
require_once dirname(__FILE__).'/content/plugins/ThemeSwitcher/Mobile_Detect.php';
$DB = Database::getInstance();
$get_option = $DB -> once_fetch_array("SELECT * FROM `".DB_PREFIX."options` WHERE `option_name` = 'ThemeSwitcher_option' ");
$config_app=unserialize($get_option["option_value"]);

$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

if(isset($_GET['theme'])){
        $theme = $_GET['theme']=='reset' ? Option::get('nonce_templet') : $_GET['theme'];
}else if($deviceType=='phone'){
        $handle=opendir(TPLS_PATH);
        while (($item=readdir($handle))!==false) {
                if($item!='.'&&$item!='..'){
                        if (is_file ( TPLS_PATH . "/" . $item )) {
                                $arr ['file'] [] = $item;
                        }
                        if (is_dir ( TPLS_PATH . "/" . $item )) {
                                $arr ['dir'] [] = $item;
                        }
                }
        }
        closedir($handle);
        if(in_array($config_app["moblie"],$arr["dir"])){
                $theme=$config_app["moblie"];
        }else{
                $theme="";
        }
}else if($deviceType=='tablet'){
        $handle=opendir(TPLS_PATH);
        while (($item=readdir($handle))!==false) {
                if($item!='.'&&$item!='..'){
                        if (is_file ( TPLS_PATH . "/" . $item )) {
                                $arr ['file'] [] = $item;
                        }
                        if (is_dir ( TPLS_PATH . "/" . $item )) {
                                $arr ['dir'] [] = $item;
                        }
                }
        }
        closedir($handle);
        if(in_array($config_app["tablet"],$arr["dir"])){
                $theme=$config_app["tablet"];
        }else{
                $theme="";
        }
}else if($deviceType=='computer'){
        $handle=opendir(TPLS_PATH);
        while (($item=readdir($handle))!==false) {
                if($item!='.'&&$item!='..'){
                        if (is_file ( TPLS_PATH . "/" . $item )) {
                                $arr ['file'] [] = $item;
                        }
                        if (is_dir ( TPLS_PATH . "/" . $item )) {
                                $arr ['dir'] [] = $item;
                        }
                }
        }
        closedir($handle);
        if(in_array($config_app["other"],$arr["dir"])){
                $theme=$config_app["other"];
        }else{
                $theme="";
        }
}else{
    $theme='';
}
if($theme==''){
    define('TEMPLATE_NAME', Option::get('nonce_templet'));
}else{
    define('TEMPLATE_NAME', $theme);
}
define('TEMPLATE_URL', TPLS_URL.TEMPLATE_NAME.'/');

(Plug in Description:Themeswitcherforemdevice is a themeswitcherforemlog plug-in for emlog that automatically switches themes according to devicesPrerequisites for using multiple versions of emlog plug-ins (including 3 required steps):1. Modify the plug-in file themeswitch There are about 59 lines in PHP, with the comment index_ Head mount point statement;//addAction('index_head', 'ThemeSwitcher_head');// It is mainly to annotate the header jump statement in its functionCopy code2. Index. Of the root directory T / index. PHP and micro language directory Code replacement in PHPdefine('TEMPLATE_PATH', TPLS_PATH.Option::get('nonce_templet').'/');Copy codeReplace withdefine('TEMPLATE_PATH', TPLS_PATH.TEMPLATE_NAME.'/');Copy code3. Init. Of the root directory Code replacement in PHP (you need to keep the plug-in enabled):define('TEMPLATE_URL',         TPLS_URL.Option::get('nonce_templet').'/');Copy codeReplace with:session_ start();// If init Delete this statement when you have it in PHPrequire_ once dirname(__FILE__).'/ content/plugins/ThemeSwitcher/Mobile_ Detect. php';$DB = Database::getInstance();$get_ option = $DB -> once_ fetch_ array("SELECT * FROM `".DB_PREFIX."options` WHERE `option_name` = 'ThemeSwitcher_option' ");$config_ app=unserialize($get_option["option_value"]);$detect = new Mobile_ Detect;$deviceType = ($detect->isMobile() ?  ($detect->isTablet() ? ' tablet' : 'phone') : 'computer');if(isset($_GET['theme'])){$theme = $_ GET['theme']=='reset' ?  Option::get('nonce_templet') : $_ GET['theme'];}else if($deviceType=='phone'){$handle=opendir(TPLS_PATH);while (($item=readdir($handle))!== false) {if($item!='.'&&$item!='..'){if (is_file ( TPLS_PATH . "/" . $item )) {$arr ['file'] [] = $item;}if (is_dir ( TPLS_PATH . "/" . $item )) {$arr ['dir'] [] = $item;}}}closedir($handle);if(in_array($config_app["moblie"],$arr["dir"])){$theme=$config_ app["moblie"];}else{$theme="";}}else if($deviceType=='tablet'){$handle=opendir(TPLS_PATH);while (($item=readdir($handle))!== false) {If ($item! ='.'& $item! ='.. '){if (is_file ( TPLS_PATH . "/" . $item )) {$arr ['file'] [] = $item;}if (is_dir ( TPLS_PATH . "/" . $item )) {$arr ['dir'] [] = $item;}}}closedir($handle);if(in_array($config_app["tablet"],$arr["dir"])){$theme=$config_ app["tablet"];}else{$theme="";}}else if($deviceType=='computer'){$handle=opendir(TPLS_PATH);while (($item=readdir($handle))!== false) {if($item!='.'&&$item!='..'){if (is_file ( TPLS_PATH . "/" . $item )) {$arr ['file'] [] = $item;}if (is_dir ( TPLS_PATH . "/" . $item )) {$arr ['dir'] [] = $item;}}}closedir($handle);if(in_array($config_app["other"],$arr["dir"])){$theme=$config_ app["other"];}else{$theme="";}}else{$theme='';}if($theme==''){define('TEMPLATE_NAME', Option::get('nonce_templet'));}else{define('TEMPLATE_NAME', $theme);}define('TEMPLATE_URL', TPLS_URL.TEMPLATE_NAME.'/');)

[下载]18034724526.rar


180347zsb8q87qlseczjqj.jpg


上一篇:emlog 模板设置插件
下一篇:emlog图片灯箱插件

使用道具 举报

Archiver|手机版|小黑屋|吾爱开源 |网站地图

Copyright 2011 - 2012 Lnqq.NET.All Rights Reserved( ICP备案粤ICP备14042591号-1粤ICP14042591号 )

关于本站 - 版权申明 - 侵删联系 - Ln Studio! - 广告联系

本站资源来自互联网,仅供用户测试使用,相关版权归原作者所有

快速回复 返回顶部 返回列表