<?php
/*
Plugin Name: Welcome Visitor!
Plugin URI: http://guff.szub.net/welcome-visitor/
Description: Customizable message that can be added to your sidebar or elsewhere on your blog.
Author: Kaf Oseo
Author URI: http://szub.net/
Version: R1
Copyright (c) 2006 Kaf Oseo (http://szub.net)
Welcome Visitor! is released under the GNU General Public License
(GPL) http://www.gnu.org/licenses/gpl.txt
This is a WordPress plugin (http://wordpress.org).
QUICK INSTALLATION NOTES:
In welcome-visitor.zip you will find:
* welcome-visitor.php (this file)
* welcome-visitor-editor.php
Place both files in a directory called 'welcome-visitor', which must
be a subdirectory of wp-content/plugins/. Then go to your WordPress
admin and in Plugins activate Welcome Visitor!. Once this is active,
the welcome message 'editor' is found at Options > Welcome.
To display your welcome message, insert:
<?php welcome_visitor(); ?>
in the theme template where you'd like it displayed. Most will wish
to display it on the Sidebar; most themes provide a sidebar.php for
this.
*/
function szub_welcome_admin() {
add_options_page('Welcome Message', 'Welcome', 8, 'welcome-visitor/welcome-visitor-editor.php');
}
add_action('admin_menu', 'szub_welcome_admin');
function welcome_visitor($before='', $after='') {
$options = get_option('welcome_visitor');
if('private' == $options['status'])
return;
global $user_identity;
$title = stripslashes($options['title']);
$content = stripslashes($options['content']);
if($options['showusers'] || !$user_identity) {
switch($options['status']) {
case 'title' :
$output = $title;
break;
case 'content' :
$output = $content;
break;
default :
$output = '';
}
if(empty($output)) {
switch($options['style']) {
case 'list' :
$output = "<ul class='welcome-visitor'><li><h2>$title</h2>\n<ul><li>$content</li></ul>\n</li></ul>";
break;
default :
$output = "<div class='welcome-visitor'>\n<h2>$title</h2>\n$content\n</div>";
}
}
if($options['filters'])
$output = apply_filters('the_content', $output);
if(($options['home'] && is_home()) || empty($options['home']))
echo $before . $output . $after;
}
}
// Uncomment next line to automatically call welcome_visitor() in "Meta" section.
//add_filter('wp_meta', 'welcome_visitor');
?>