plugin_name);
// avoid undefined errors when running it for the first time :
if (!isset($options["username"]))
$options["username"] = "";
if (!isset($options["posting-key"]))
$options["posting-key"] = "";
if (!isset($options["use-testnet"]))
$options["use-testnet"] = "no";
if (!isset($options["testnet-username"]))
$options["username"] = "";
if (!isset($options["testnet-posting-key"]))
$options["posting-key"] = "";
if (!isset($options["reward"]))
$options["reward"] = "100";
if (!isset($options["tags"]))
$options["tags"] = "";
if (!isset($options["category"]))
$options["category"] = "";
if (!isset($options["seo"]))
$options["seo"] = "on";
if (!isset($options["vote"]))
$options["vote"] = "on";
if (!isset($options['template']))
$options['template'] = "{{content}}";
?>
Connectivity and username/password tests:";
$options = get_option($this->plugin_name);
//echo "OPTIONS:
";
//print_r($options);
//echo "";
$livevalid = isset($options['live-authvalid']) ? $options['live-authvalid'] : '';
$testvalid = isset($options['testnet-authvalid']) ? $options['testnet-authvalid'] : '';
//echo "TESTNET AUTH PREVIOUS VALUE: $testvalid | LIVE AUTH PREVIOUS VALUE: $livevalid";
$steemuser = isset($options["username"]) ? $options["username"] : '';
$steemwif = isset($options["posting-key"]) ? $options["posting-key"] : '';
$testnetuser = isset($options["testnet-username"]) ? $options["testnet-username"] : '';
$testnetwif = isset($options["testnet-posting-key"]) ? $options["testnet-posting-key"] : '';
$testnetdata = array("body" => array("testnet" => "yes","author" => $testnetuser,"wif"=>$testnetwif));
$steemdata = array("body" => array("testnet" => "no","author" => $steemuser,"wif"=>$steemwif));
// Test the user and api which will publish on blockchain.
//$result = wp_remote_post("https://steemgifts.com/test", $data);
//$result = wp_remote_post("http://127.0.0.1:4287/spress", $data);
$testnetresult = wp_remote_post("http://127.0.0.1:4287/spress/testuser", $testnetdata);
$steemresult = wp_remote_post("http://127.0.0.1:4287/spress/testuser", $steemdata);
echo "Live STEEM blockchain: ";
$options["live-authvalid"]="no";
if (is_array($steemresult) or ($steemresult instanceof Traversable)) {
$steemresults = json_decode($steemresult["body"],true);
if (isset($steemresults["result"]) && $steemresults["result"] == "success") {
$options["live-authvalid"]="yes";
echo "Ok";
} else {
echo "FAILED:";
if (isset($steemresults["error"])) {
echo $steemresults["error"];
}
}
} else {
echo "Connection error
Most likely your host isn't letting the plugin reach our steem server.";
}
echo "";
echo "Testnet blockchain: ";
$options["testnet-authvalid"]="no";
if (is_array($testnetresult) or ($testnetresult instanceof Traversable)) {
$testnetresults = json_decode($testnetresult["body"],true);
if (isset($testnetresults["result"]) && $testnetresults["result"] == "success") {
echo "Ok";
$options["testnet-authvalid"]="yes";
} else {
echo "FAILED:";
if (isset($testnetresults["error"])) {
echo $testnetresults["error"];
}
}
} else {
echo "Connection error
Most likely your host isn't letting the plugin reach our steem server.";
}
$options=$this->validate($options);
update_option($this->plugin_name,$options);
//$options=get_option($this->plugin_name);
//echo "\n\n".print_r($options,true)."
";
?>