Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from inozemtsev-roman:master #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Waves Asset Price
Waves Asset Price - это плагин, чтобы показывать информацию о ценах токенов, созданных на Waves Platform
# Digital Asset Price
Digital Asset Price - это плагин, чтобы показывать информацию о ценах токенов, созданных в блокчейн-сетях на базе протокола Waves

![Скриншот](https://github.com/inozemtsev-roman/Waves-Asset-Price/blob/master/screenshot.png)

Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions wap.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php

function waves_asset( $atts ) {
function wavestp_token( $atts ) {
extract( shortcode_atts( array(
'id' => '',
'priceid' => '',
'fiat' => '',
), $atts, 'asset' ) );
), $atts, 'token' ) );

$demolph_output = waves_show( $id,$fiat,$priceid );
$demolph_output = wavestp_show( $id,$fiat,$priceid );
return $demolph_output;
}
add_shortcode( "asset", "waves_asset" );
add_shortcode( "token", "wavestp_token" );

function waves_show( $id,$fiat,$priceid ) {
function wavestp_show( $id,$fiat,$priceid ) {
$response = wp_remote_get( "http://marketdata.wavesplatform.com/api/ticker/$id/$priceid" );
$body = wp_remote_retrieve_body( $response );
$data = json_decode($body, TRUE);
$cmcap = wp_remote_get("https://api.coinmarketcap.com/v1/ticker/waves/?convert=EUR");
$cmbody = wp_remote_retrieve_body($cmcap);
$cmdata = json_decode($cmbody, TRUE);
$asset = array_search("$id", array_column($data, 'amountAssetID'));
$token = array_search("$id", array_column($data, 'amountAssetID'));
$price = $data['24h_close'];
$pricein = $data["priceAssetID"];
$pricename = $data["priceAssetName"];
Expand All @@ -28,34 +28,34 @@ function waves_show( $id,$fiat,$priceid ) {
$eurprice = $cmdata[0]["price_eur"];
if ($pricein == "WAVES"){
if($fiat == "waves"){
return $price;
return round($price,5);
} elseif ($fiat == "btc"){
return number_format($price*$btcprice, 10);
return number_format($price*$btcprice, 4);
} elseif ($fiat == "eur"){
return number_format($price*$eurprice, 10);
return number_format($price*$eurprice, 4);
}
else{
return number_format($price*$wprice, 10);
return number_format($price*$wprice, 4);

}
} else {
return "$price $pricename";
}
}

function waves_tinfo( $atts ) {
function wavestp_tinfo( $atts ) {
extract( shortcode_atts( array(
'id' => '',
'priceid' => '',
'type' => '',
), $atts, 'tinfo' ) );

$demolph_output = waves_shinfo( $id,$type,$priceid );
$demolph_output = wavestp_shinfo( $id,$type,$priceid );
return $demolph_output;
}
add_shortcode( "tinfo", "waves_tinfo" );
add_shortcode( "tinfo", "wavestp_tinfo" );

function waves_shinfo( $id,$type,$priceid ) {
function wavestp_shinfo( $id,$type,$priceid ) {
$rinfo = wp_remote_get( "http://marketdata.wavesplatform.com/api/ticker/$id/$priceid" );
$binfo = wp_remote_retrieve_body( $rinfo );
$dinfo = json_decode($binfo, TRUE);
Expand All @@ -82,4 +82,4 @@ function waves_shinfo( $id,$type,$priceid ) {
return $high24h;
}
}
?>
?>