Created my first wp plugin but...
I just finished up a cool wp plugin that I have been testing. The thing is that it displays no errors when I run the plugin or when I go to the url for the file itself...
The thing is that when I start running it for testing and come back later on that day or week I find its broken and not working, just shows front page of the site...
Any ideas?
Sincerely;
J
The code is below.
<?
global $domain1;
global $domain2;
global $basews;
function eztest(){//works redirects properly using shortcode
global $domain1;
global $domain2;
global $basews;
$domain1=get_option('domain1');
$domain2=get_option('domain2');
$basews=get_option('basews');
$ct = 0;
if(!empty($domain1) || $domain1 != null){
$ct=$ct+1;
}elseif(!empty($domain2) || $domain2 != null){
$ct=$ct+1;
}
$test = rand(0,$ct);
if($test == 0){
$location = $domain1;
}else{
$location = $domain2;
}
header("Location: ".$basews.$location);
}
add_shortcode('eztest','eztest');
function esplit_activate(){//works creates the options and allows for data saved
global $domain1;
global $domain2;
global $basews;
add_option("domain1",null);
add_option("domain2",null);
add_option("basews",null);
}
register_activation_hook(ABSPATH.'/easy-split-test.php','esplit_activate'); // generates call to undefined function
function esplitd(){//works
global $domain1;
global $domain2;
global $basews;
delete_option("domain1");
delete_option("domain2");
delete_option("basews");
}
register_deactivation_hook('/easy-split-test.php','esplitd'); //works
function easy_split_tester(){//works
add_options_page('Easy Split Tester', 'Easy Split Tester', 'manage_options', 'ez-split-tester', 'plugin_options');
}
add_action('admin_menu', 'easy_split_tester'); //works
function plugin_options(){
//works
global $domain1;
global $domain2;
global $basews;
if (!current_user_can('manage_options')) {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
if(isset($_POST['go'])){
$domain1 = $_POST['domain1'];
$domain2 = $_POST['domain2'];
$basews = $_POST['basews'];
update_option('domain1',$domain1);
update_option('domain2',$domain2);
update_option('basews',$basews);
?>
<div class="updated"><p><strong><?php _e('Update Successful!'); ?></strong></p></div>
<?
}else{
$domain1=get_option('domain1');
$domain2=get_option('domain2');
$basews=get_option('basews');
?>
<div class="wrap">
<?php echo "<H2>".__('Easy Split Tester Settings')."</H2>"; ?>
<form method="post" action="<?php echo str_replace('%7E','~',$_SERVER['REQUEST_URI']); ?>">
<input type="text" name="domain1" placeholder="Enter your first page" size="100" value="<?php echo $domain1; ?>" /><br>
<input type="text" name="domain2" placeholder="Enter your second page" size="100" value="<?php echo $domain2; ?>" /><br>
<input type="url" name="basews" placeholder="http://" size="100" value="<?php echo $basews; ?>" /><br />
<p class="submit">
<input type="submit" name="go" value="Save" />
</p>
</form>
</div>
<?
}
}
?>
Great Success is built from many little successes!
http://www.timbrownlaw.com - My Wee Part of the World.
http://www.LookingOverMyShoulder.com
The best way to predict future is to create it ― Abraham Lincoln