找回密码
 立即注册
itemTPLSPATHTEMPLATE | 博客 2022-04-25 232 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
插件描述:
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图片灯箱插件