I've create a really small plugin. This plugin add one filter :
add_filter('the_content', 'BlueSteelAPI', 5);
BlueSteelAPI is calling my API. I've create an admin page for register the secret key password. That's Ok.
But, in my plugin directory, i've this other page :
<?php
include('class.api.v1.php');
$blapi = new blapi($secretKey);
$call = $blapi->MakeRequest("addCommand", $_POST);
if ($blapi->IsThereAnError() == 0){
header("location:" . $call->urlpaiement . "?bl_methode=" . $call->methode . "&bl_refcmd=" . $call->refcmd);
}
else //Error...
{
print_r("Description : " . $call->description . " / Code : ". $blapi->getCode());
}
?>
The goal of this page is to receive some Post Data and send it to my API for get a reference for a command.
But, "$secretKey" is in the "Options" table of wordpress. How can I get this data?
I can make a query like "select option_value from options where option_name = 'secretKey'"
But, is there a better way to get this data?
EDIT :
I've find this solution but i think, it's not really nice. I've put it in the top my other page...
//include('class.api.v1.php');
require( '../../../wp-blog-header.php');
$option = $wpdb->get_results('SELECT * FROM '. $wpdb->prefix.'options where option_name in (\'bluesteel_secretkey\', \'bluesteel_sitekey\')');
$secretKey = $option[0]->option_value;
$apiKey = $option[1]->option_value;
get_option()
function used to getoption_value
stored inoptions
table byoption_name
.