WordPress 微信访问切换主题插件

WordPress 微信访问切换主题插件,第1张

概述将下面的代码保存为weixin.php 并上传到wp-content/plugins目录下

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。内存溢出小编现在分享给大家,也给大家做个参考。

将下面的代码保存为 weixin.PHP 并上传到 wp-content/plugins 目录下


<?PHP


/*


Plugin name: Weixin Switch theme


Plugin URI: http://fatesinger.com/74958


Description: 切换微信主题


Version: 1.0.0


Author: Bigfa


Author URI: http://fatesinger.com/


*/


if( !function_exists('is_weixin') ) :


function is_weixin(){


if ( strpos($_SERVER['http_USER_AGENT'],'MicroMessenger') !== false ) {


return true;


}


return false;


}


endif;


function angela_switch_theme($theme){


if( is_weixin() ){


$theme = 'Bur';//主题文件夹名而不是主题名


}


return $theme;


}


add_filter( 'template','angela_switch_theme' );


add_filter( 'stylesheet','angela_switch_theme' );


?>


之后在插件后台激活即可。


激活后在微信中将自动启用 Bur 主题


如果当作移动主题使用则使用下面的代码


<?PHP


/*


Plugin name: Mobile Switch theme


Plugin URI: http://fatesinger.com/74958


Description: 切换移动主题


Version: 1.0.0


Author: Bigfa


Author URI: http://fatesinger.com/


*/

function angela_switch_theme($theme){


if( wp_is_mobile() ){


$theme = 'Bur';//主题文件夹名而不是主题名


}


return $theme;


}


add_filter( 'template','angela_switch_theme' );


?>

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的WordPress 微信访问切换主题插件全部内容,希望文章能够帮你解决WordPress 微信访问切换主题插件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zz/1012638.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存