[插件]Wordpress第一次访问的特定模板(并编写cookie)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[插件]Wordpress第一次访问的特定模板(并编写cookie)相关的知识,希望对你有一定的参考价值。
<?php /* Plugin Name: first-visit-template Description: Loads a welcome.php template in theme directory if it is the first visit (the function is not lauched if you're logged as admin), and writes a cookie so it's shown only once. Author: G.Lachance Author URI: http://tinyurl.com/9wb48o Credits: Based upon the "Welcome Visitor! Reloaded" plugin from Alaeddin, which is largely based upon the original Welcome Visitor! plugin by Kaf (http://guff.szub.net/2006/04/12/welcome-visitor/) which was released under the GNU General Public License. Version: 1 */ //for testing your template, uncomment line 30. function welcome_visitor_reloaded() { if(is_new_visitor()) { $tpl_file = TEMPLATEPATH . '/welcome.php'; include($tpl_file); exit; } } } function is_new_visitor() { //return true; //uncomment this for testing. global $visits; if (!is_admin()) { $visits = $_COOKIE['visits'] + 1; else $visits = 1; } else return false; return $visits == 1; } /// add_action('template_redirect', 'welcome_visitor_reloaded'); ?>
以上是关于[插件]Wordpress第一次访问的特定模板(并编写cookie)的主要内容,如果未能解决你的问题,请参考以下文章