/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?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'); ?>