Commit 9e424407 authored by Martin Lees's avatar Martin Lees
Browse files

Update the post_meta to also get the primary tag

parent c3cc1926
......@@ -301,9 +301,12 @@ class Steempress_sp_Admin {
if ($test['tags'] != "" && $test['author'] != "" && $test['wif'] != "") {
// Post to the api who will publish it on the steem blockchain.
$result = wp_remote_post($this->api_url, $data);
$permlink = $result['body'];
$data = $result['body'];
$primary_tag = explode("/",$data)[0];
$permlink= explode("/",$data)[1];
add_post_meta($id, "steempress_sp_username", $username);
add_post_meta($id, "steempress_sp_permlink", $permlink);
add_post_meta($id, "steempress_sp_tag", $primary_tag);
}
}
......
......@@ -100,32 +100,15 @@ class Steempress_sp_Public {
}
private function steempress_sp_steem_comments($id, $username, $permlink)
{
$data = array(
"jsonrpc" => "2.0",
"method" => "get_content_replies",
"params" => [$username,$permlink]
);
$result = wp_remote_post("https://api.steemit.com", array(
'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
'body' => json_encode($data),
'method' => 'POST'
));
return $result['body'];
}
public function steempress_sp_comments($content)
public function steempress_sp_comments($content)
{
$id = get_the_ID();
$username = get_post_meta($id, "steempress_sp_username");
$permlink = get_post_meta($id, "steempress_sp_permlink");
$tag = get_post_meta($id, "steempress_sp_tag");
......@@ -133,20 +116,22 @@ class Steempress_sp_Public {
$data = "";
if (sizeof($username) == 1 and sizeof($permlink) == 1)
if (sizeof($username) == 1 and sizeof($permlink) == 1 and sizeof($tag) == 1)
{
$username = $username[0];
$permlink = $permlink[0];
$tag = $tag[0];
$data = "<div id=\"steempress_sp_username\" style=\"display: none;\">".$username."</div>";
$data .= "<div id=\"steempress_sp_permlink\" style=\"display: none;\">".$permlink."</div>";
$data .= "<div id=\"steempress_sp_tag\" style=\"display: none;\">".$tag."</div>";
$payout = "<div id='steempress_sp_price'>0.000$</div>";
// comment zone
echo ($this->steempress_sp_steem_comments($id, $username, $permlink));
//echo ($this->steempress_sp_steem_comments($id, $username, $permlink));
}
return $content.$data.$payout;
......
......@@ -35,14 +35,36 @@
const username = $("#steempress_sp_username")[0].innerText;
const permlink = $("#steempress_sp_permlink")[0].innerText;
const tag = $("#steempress_sp_tag")[0].innerText;
console.log(permlink);
steem.api.getContent(username, permlink, function(err, response){
console.log($("#steempress_sp_price")[0]);
$("#steempress_sp_price")[0].innerHTML=response.total_payout_value.replace("SBD","$")
// grab value
steem.api.getContent(username, permlink, function(err, response) {
if (!err) {
if (response.total_payout_value !== "0.000 SBD")
$("#steempress_sp_price")[0].innerHTML = response.total_payout_value.replace("SBD", "$")
else
$("#steempress_sp_price")[0].innerHTML = response.pending_payout_value.replace("SBD", "$")
}
});
steem.api.getState("steempress/@petanque/testcomments-xylmwuwi6p", function(err, result) {
console.log(err, result);
});
})
})( jQuery );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment