<?php
/*
Script Name: Welcome Visitor! admin page
Script URI: http://guff.szub.net/welcome-visitor/
QUICK INSTALLATION NOTES:
In welcome-visitor.zip you will find:
* welcome-visitor.php
* welcome-visitor-editor.php (this file)
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.
*/
/*
Welcome Visitor! administration text/label variables. These may be
edited for "localization" purposes.
*/
$no_access_msg = 'You do not have permission to access this page.';
$headline = 'Your Message';
$update_msg = 'Changes to message saved';
$update_btn_text = 'Update Message';
$title_label = 'Title';
$content_label = 'Content';
$default_title = 'Welcome Visitor!';
$default_content = 'This is your welcome message. You will probably want to edit it.';
$status_label = 'Message Status';
$status_publish = 'Published';
$status_title = 'Title only';
$status_content = 'Content only';
$status_private = 'Private';
$style_label = 'HTML Style';
$style_div = 'In <div> element';
$style_list = 'In unordered list';
$display_label = 'Display Options';
$home_label = 'On home page only';
$showusers_label = 'To registered users';
$filters_label = 'Use content filtering';
/*
--------------------------------------------------------------------
*/
global $user_level;
if ($user_level < 8)
die($no_access_msg);
$options = get_option('welcome_visitor');
if(empty($options)) {
$title = $options['title'] = $default_title;
$content = $options['content'] = $default_content;
$status = $options['status'] = 'private';
$style = $options['style'] = 'div';
$showusers = $options['showusers'] = '1';
$filters = $options['filters'] = '1';
$home = $options['home'] = '1';
update_option('welcome_visitor', $options);
} else {
if(!isset($_POST['update'])) {
$title = $options['title'];
$content = $options['content'];
$status = $options['status'];
$style = $options['style'];
$showusers = $options['showusers'];
$filters = $options['filters'];
$home = $options['home'];
} else {
$title = $options['title'] = $_POST['title'];
$content = $options['content'] = $_POST['message'];
$status = $options['status'] = $_POST['status'];
$style = $options['style'] = $_POST['style'];
$showusers = $options['showusers'] = (isset($_POST['showusers'])) ? 1 : 0;
$filters = $options['filters'] = (isset($_POST['filters'])) ? 1 : 0;
$home = $options['home'] = (isset($_POST['home'])) ? 1 : 0;
update_option('welcome_visitor', $options);
?>
<div id="updated" class="updated fade">
<p><strong><?php echo $update_msg; ?></strong></p>
</div>
<?php
}
}
$title = stripslashes(htmlentities($title));
$content = stripslashes(htmlentities($content));
?>
<div class="wrap">
<h2><?php echo $headline; ?></h2>
<form name="szub_welcome" method="post" id="post">
<div id="poststuff">
<fieldset id="moremeta">
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php echo $status_label; ?></h3>
<div class="dbx-content">
<label for="status_publish" class="selectit"><input tabindex="4" id="status_publish" name="status" type="radio" value="publish"<?php if('publish' == $status) echo ' checked="checked"'; ?> /> <?php echo $status_publish; ?></label>
<label for="status_title" class="selectit"><input tabindex="4" id="status_title" name="status" type="radio" value="title"<?php if('title' == $status) echo ' checked="checked"'; ?> /> <?php echo $status_title; ?></label>
<label for="status_content" class="selectit"><input tabindex="4" id="status_content" name="status" type="radio" value="content"<?php if('content' == $status) echo ' checked="checked"'; ?> /> <?php echo $status_content; ?></label>
<label for="status_private" class="selectit"><input tabindex="4" id="status_private" name="status" type="radio" value="private"<?php if('private' == $status) echo ' checked="checked"'; ?> /> <?php echo $status_private; ?></label>
</div>
</fieldset>
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php echo $style_label; ?></h3>
<div class="dbx-content">
<?php if(('title' == $status) || ('content' == $status)) { ?>
<label class="selectit">This option is disabled when status is <?php echo $status; ?> only.</label>
<input type="hidden" name="style" value="<?php echo $style; ?>" />
<?php } else { ?>
<label for="style_div" class="selectit"><input tabindex="5" id="style_div" name="style" type="radio" value="div"<?php if('div' == $style) echo ' checked="checked"'; ?> /> <?php echo $style_div; ?></label>
<label for="style_list" class="selectit"><input tabindex="5" id="style_list" name="style" type="radio" value="list"<?php if('list' == $style) echo ' checked="checked"'; ?> /> <?php echo $style_list; ?></label>
<?php } ?>
</div>
</fieldset>
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php echo $display_label; ?></h3>
<div class="dbx-content">
<label for="home" class="selectit"><input tabindex="6" value="<?php echo $home; ?>" type="checkbox" name="home" id="home" <?php if($home) echo 'checked="checked" '; ?>/> <?php echo $home_label; ?></label>
<label for="showusers" class="selectit"><input tabindex="7" value="<?php echo $showusers; ?>" type="checkbox" name="showusers" id="showusers" <?php if($showusers) echo 'checked="checked" '; ?>/> <?php echo $showusers_label; ?></label>
<label for="filters" class="selectit"><input tabindex="8" value="<?php echo $filters; ?>" type="checkbox" name="filters" id="filters" <?php if($filters) echo 'checked="checked" '; ?>/> <?php echo $filters_label; ?></label>
</div>
</fieldset>
</fieldset>
<fieldset id="titlediv">
<legend><?php echo $title_label; ?></legend>
<div><input type="text" name="title" size="30" tabindex="1" value="<?php echo $title; ?>" id="title" /></div>
</fieldset>
<fieldset id="postdiv">
<legend><?php echo $content_label; ?></legend>
<div id="quicktags">
<script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>
<script type="text/javascript">edToolbar();</script>
</div>
<div><textarea rows="11" cols="40" name="message" tabindex="2" id="content"><?php echo $content; ?></textarea></div>
</fieldset>
<script type="text/javascript">
<!--
edCanvas = document.getElementById('content');
//-->
</script>
<p class="submit">
<input type="submit" name="update" tabindex="3" value="<?php echo $update_btn_text ;?>" title="update"/>
</p>
</div>
</div>
</div>