Commit c204bba9 authored by Martin Lees's avatar Martin Lees
Browse files

Start of the two way integration with the price being pulled

parent a4338f14
......@@ -17,8 +17,6 @@
<?php
var_dump(get_post_meta(42));
//Grab all options
$options = get_option($this->plugin_name);
......
......@@ -193,6 +193,7 @@ class Steempress_sp {
$plugin_public = new Steempress_sp_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
$this->loader->add_filter('the_content',$plugin_public, 'steempress_sp_comments');
}
......
......@@ -95,8 +95,36 @@ class Steempress_sp_Public {
* class.
*/
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/steempress_sp-public.js', array( 'jquery' ), $this->version, false );
wp_enqueue_script( $this->plugin_name."steem", plugin_dir_url( __FILE__ ) . 'js/steem.min.js');
wp_enqueue_script( $this->plugin_name."public_js", plugin_dir_url( __FILE__ ) . 'js/steempress_sp-public.js', array( 'jquery' ), $this->version, false );
}
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");
$payout = "";
$data = "";
$comments = "";
if (sizeof($username) == 1 and sizeof($permlink) == 1)
{
$data = "<div id=\"steempress_sp_username\" style=\"display: none;\">".$username[0]."</div>";
$data .= "<div id=\"steempress_sp_permlink\" style=\"display: none;\">".$permlink[0]."</div>";
$payout = "<div id='steempress_sp_price'>0.000$</div>";
// comment zone
$comments = "<div id='steempress_sp_price'>0.000$</div>";
}
return $content.$data.$payout;
}
}
/**
* All of the CSS for your public-facing functionality should be
* included in this file.
*/
\ No newline at end of file
*/
#steempress_sp_price {
text-align: right;
}
\ No newline at end of file
This diff is collapsed.
(function( $ ) {
'use strict';
'use strict';
/**
* All of the code for your public-facing JavaScript source
* should reside in this file.
*
* Note: It has been assumed you will write jQuery code here, so the
* $ function reference has been prepared for usage within the scope
* of this function.
*
* This enables you to define handlers, for when the DOM is ready:
*
* $(function() {
/**
* All of the code for your admin-facing JavaScript source
* should reside in this file.
*
* Note: It has been assumed you will write jQuery code here, so the
* $ function reference has been prepared for usage within the scope
* of this function.
*
* This enables you to define handlers, for when the DOM is ready:
*
* $(function() {
*
* });
*
* When the window is loaded:
*
* $( window ).load(function() {
*
* When the window is loaded:
*
* $( window ).load(function() {
*
* });
*
* ...and/or other possibilities.
*
* Ideally, it is not considered best practise to attach more than a
* single DOM-ready or window-load handler for a particular page.
* Although scripts in the WordPress core, Plugins and Themes may be
* practising this, we should strive to set a better example in our own work.
*/
*
* ...and/or other possibilities.
*
* Ideally, it is not considered best practise to attach more than a
* single DOM-ready or window-load handler for a particular page.
* Although scripts in the WordPress core, Plugins and Themes may be
* practising this, we should strive to set a better example in our own work.
*/
$(window).load(function () {
const username = "howo"//$("#steempress_sp_username")[0].innerText;
const permlink = "my-steemniversary-one-year-going-from-oh-this-looks-cool-to-well-this-is-now-my-job"//$("#steempress_sp_permlink")[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","$")
});
})
})( 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