Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Danny Froberg
steempress_amn
Commits
9e424407
Commit
9e424407
authored
Aug 08, 2018
by
Martin Lees
Browse files
Update the post_meta to also get the primary tag
parent
c3cc1926
Changes
3
Hide whitespace changes
Inline
Side-by-side
admin/class-steempress_sp-admin.php
View file @
9e424407
...
...
@@ -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
);
}
}
...
...
public/class-steempress_sp-public.php
View file @
9e424407
...
...
@@ -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
;
...
...
public/js/steempress_sp-public.js
View file @
9e424407
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment