0

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;
  • did you tried get_option('secretKey') ? get_option() function used to get option_value stored in options table by option_name. – Shazzad Feb 25 '14 at 22:42
  • I don't have any function of WP in this page, you see? All the code is in my question. – Portekoi Feb 25 '14 at 22:45
  • Use the AJAX API – s_ha_dum Feb 26 '14 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.