Changeset 1878349
- Timestamp:
- 05/21/2018 11:15:05 AM (8 years ago)
- Location:
- total-cryptos
- Files:
-
- 8 added
- 8 edited
-
tags/1.0/css/admin-style.css (added)
-
tags/1.0/css/marquee.css (added)
-
tags/1.0/css/style.css (modified) (5 diffs)
-
tags/1.0/css/ticker.css (added)
-
tags/1.0/js/ticker.js (added)
-
tags/1.0/js/totalcryptos.js (modified) (2 diffs)
-
tags/1.0/readme.txt (modified) (1 diff)
-
tags/1.0/totalcryptos.php (modified) (10 diffs)
-
trunk/css/admin-style.css (added)
-
trunk/css/marquee.css (added)
-
trunk/css/style.css (modified) (5 diffs)
-
trunk/css/ticker.css (added)
-
trunk/js/ticker.js (added)
-
trunk/js/totalcryptos.js (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/totalcryptos.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
total-cryptos/tags/1.0/css/style.css
r1853947 r1878349 2668 2668 } 2669 2669 /* New Timeline style */ 2670 2670 2671 .vertical-container { 2671 2672 /* this class is used to give a max-width to the element it is applied to, and center it horizontally when it reaches that max-width */ … … 3734 3735 border: 1px solid #EBEBEB; 3735 3736 } 3737 .tc100{ 3738 width:auto !important; 3739 } 3740 .tc100 .col3{ 3741 width:33%; 3742 } 3743 .table-striped{ 3744 width:100%; 3745 display:inline-block; 3746 overflow-x: scroll; 3747 } 3736 3748 .table-bordered > thead > tr > th, 3737 3749 .table-bordered > thead > tr > td { … … 3761 3773 padding: 8px; 3762 3774 vertical-align: top; 3763 } 3775 width: 23%; 3776 } 3777 3764 3778 /* PANELS */ 3765 3779 .panel.blank-panel { … … 8451 8465 display: none; 8452 8466 } 8467 8468 .gainers_losers_div{ 8469 height:30px !important; 8470 background:#eaeaea; 8471 position:fixed; 8472 z-index:1; 8473 bottom:0; 8474 width:100%; 8475 } 8476 .news-item img{ 8477 margin:0; 8478 display:inline-block; 8479 vertical-align: text-bottom; 8480 } 8481 span.gainers_name{ 8482 font-size:18px; 8483 font-weight:bold; 8484 } 8485 span.losers_name{ 8486 font-size:18px; 8487 font-weight:bold; 8488 } 8489 span.gainers_price{ 8490 font-size:15px; 8491 font-weight:bold; 8492 display:inline-block; 8493 } 8494 span.losers_price{ 8495 font-size:15px; 8496 font-weight:bold; 8497 display:inline-block; 8498 } 8499 8500 span.gainers_perc { 8501 color: #027702; 8502 font-size:12px; 8503 font-weight:bold; 8504 } 8505 span.losers_perc { 8506 color: #f90c0c; 8507 font-size:12px; 8508 font-weight:bold; 8509 } 8453 8510 @media (min-width: 768px) { 8454 8511 #page-wrapper { … … 8578 8635 } 8579 8636 } 8637 8638 /*********** marquee slider css **********************/ 8639 .news-item{z-index:9; text-decoration:none;display:inline-block !important;} 8640 .news-item p, .gainers_texts{display:inline-block;} 8641 -
total-cryptos/tags/1.0/js/totalcryptos.js
r1853947 r1878349 1 1 jQuery(document).ready(function($){ 2 $("#totalcryptos ").children('tr').each(function(){2 $("#totalcryptos_market_cap").children('tr').each(function(){ 3 3 var val=$("#hidden_"+this.id).val(); 4 4 $("#chart_"+this.id).html(''); … … 8 8 }); 9 9 10 $("#totalcryptos_usd").children('tr').each(function(){ 11 var val=$("#hidden_"+this.id).val(); 12 $("#chart_"+this.id).html(''); 13 if(val){ 14 $("#chart_"+this.id).sparkline(val.split(","), {type: 'line',width: '100%',height: '20',lineColor: '#1ab394',fillColor: "transparent"}); 15 } 16 }); 17 18 $(".default-ticker").ticker(); 19 var newsTicker = $(".news").ticker({ 20 speed: 50, 21 pauseOnHover: !0, 22 item: ".news-item" 23 }).data("ticker"); 24 $("#news-toggle").on("click", function() { 25 newsTicker.toggle() 26 }), $(".speed-test").each(function() { 27 $(this).ticker({ 28 speed: $(this).data("speed") || 60 29 }) 30 }); 10 31 }); -
total-cryptos/tags/1.0/readme.txt
r1855166 r1878349 32 32 33 33 To display biggest Gainers and Losers, use the shortcode [tc_gainers_losers] 34 35 To display marquee slider on any place excpept footer, use the shortcode [tc_market_marqueeshort] 36 37 To display index price, use the shortcode [tc_tc100] 34 38 35 39 == Frequently Asked Questions == -
total-cryptos/tags/1.0/totalcryptos.php
r1853947 r1878349 9 9 License: GPL 10 10 */ 11 12 13 14 11 define('TC_PATH','https://totalcryptos.com/'); 12 //define('TC_PATH','http://localhost:1337/'); 15 13 /************************** To Include JS Files ******************************/ 16 14 … … 21 19 wp_register_style( 'tc_c3min_css', plugins_url( 'css/c3.min.css', __FILE__), array(),null, false); 22 20 wp_register_style( 'tc_style_css', plugins_url( 'css/style.css', __FILE__), array(),null, false); 21 wp_register_style( 'tc_ticker_css', plugins_url( 'css/ticker.css', __FILE__), array(),null, false); 23 22 24 23 wp_enqueue_style('tc_c3min_css'); 25 24 wp_enqueue_style('tc_style_css'); 25 wp_enqueue_style('tc_ticker_css'); 26 26 27 27 28 //LOAD JS … … 31 32 wp_register_script('tc_sparkline_js', plugins_url('js/jquery.sparkline.min.js', __FILE__), array(),null, true); 32 33 wp_register_script('tc_js', plugins_url('js/totalcryptos.js', __FILE__), array(),null, true); 33 34 wp_register_script('tc_ticker_js', plugins_url('js/ticker.js', __FILE__), array(),null, true); 35 34 36 wp_enqueue_script('tc_c3min_js'); 35 37 wp_enqueue_script('tc_d3min_js'); 36 38 wp_enqueue_script('tc_datatable_js'); 37 39 wp_enqueue_script('tc_sparkline_js'); 40 wp_enqueue_script('tc_ticker_js'); 41 38 42 wp_enqueue_script('tc_js'); 39 } 43 44 } 45 add_action( 'admin_enqueue_scripts', 'load_tc_admin_styles' ); 46 function load_tc_admin_styles() { 47 wp_register_style( 'tc_admin_style', plugins_url( 'css/admin-style.css', __FILE__), array(),null, false); 48 wp_enqueue_style('tc_admin_style'); 49 } 40 50 41 51 /************************* To Get Top Product's Prices *************************/ 42 52 43 53 function tc_top_products(){ 44 $response=file_get_contents( 'http://totalcryptos.com/api/topProductsPrices');54 $response=file_get_contents(TC_PATH.'api/biggestGainers'); 45 55 $response=json_decode($response); 56 echo '<div class="row">'; 57 echo '<h2>Top Products Based On Market Capitalization</h2>'; 46 58 echo '<table class="table table-striped table-bordered table-hover">'; 47 echo '<caption>Top Products</caption>';48 59 echo '<thead>'; 49 60 echo '<tr>'; … … 58 69 echo '</tr>'; 59 70 echo '</thead>'; 60 echo '<tbody id="totalcryptos">'; 71 echo '<tbody id="totalcryptos_market_cap">'; 72 $i=0; 61 73 if($response->errCode==1){ 62 foreach($response->data as $key =>$value){74 foreach($response->data->products as $value){ 63 75 echo '<tr id="'.$value->product.'_totalcryptos">'; 64 echo '<td>'.($ key+1).'</td>';76 echo '<td>'.($i+1).'</td>'; 65 77 echo '<td>'.strtoupper($value->base_currency).'</td>'; 66 78 echo '<td>'.strtoupper(str_replace("_","",$value->product)).'</td>'; … … 77 89 echo '</td>'; 78 90 echo '</tr>'; 91 $i++; 79 92 } 80 93 } … … 86 99 echo '</tbody>'; 87 100 echo '</table>'; 101 echo '</div>'; 102 echo '<div class="row">'; 103 echo '<h2>Top Products Based On USD Price</h2>'; 104 echo '<table class="table table-striped table-bordered table-hover">'; 105 echo '<thead>'; 106 echo '<tr>'; 107 echo '<th>#</th>'; 108 echo '<th>Name</th>'; 109 echo '<th>Market</th>'; 110 echo '<th>Price</th>'; 111 echo '<th>Market Cap</th>'; 112 echo '<th>% Change (24h)</th>'; 113 echo '<th>Chart 1d</th>'; 114 echo '</tr>'; 115 echo '</thead>'; 116 echo '<tbody id="totalcryptos_usd">'; 117 $i=0; 118 if($response->errCode==1){ 119 foreach($response->data->gainers as $value){ 120 echo '<tr id="'.$value->id.'_totalcryptos">'; 121 echo '<td>'.($i+1).'</td>'; 122 echo '<td>'.strtoupper($value->name).'</td>'; 123 echo '<td>'.strtoupper($value->name.'USD').'</td>'; 124 echo '<td>$'.number_format($value->price_usd,8).'</td>'; 125 echo '<td>$'.number_format($value->market_cap_usd,0).'</td>'; 126 echo '<td>'.$value->percent_change_24h.'</td>'; 127 echo '<td>'; 128 echo '<div class="row">'; 129 echo '<div class="col-md-12" id="chart_'.$value->id.'_totalcryptos">'; 130 echo '<input type="hidden" id="hidden_'.$value->id.'_totalcryptos" value="'.implode($value->chart,',').'" />'; 131 echo '</div>'; 132 echo '</div>'; 133 echo '</td>'; 134 echo '</tr>'; 135 $i++; 136 } 137 } 138 else{ 139 echo '<tr>'; 140 echo '<td>'.$response->message.'</td>'; 141 echo '</tr>'; 142 } 143 echo '</tbody>'; 144 echo '</table>'; 145 echo '</div>'; 88 146 } 89 147 … … 91 149 92 150 function tc_gainers_losers(){ 93 $response=file_get_contents('http://totalcryptos.com/api/topGainersLosers'); 151 $time='1h'; 152 $gainers_losers_data = get_option( 'tc_gainers_losers_tables' ); 153 if(!empty($gainers_losers_data)){ 154 $time=$gainers_losers_data; 155 } 156 $response=file_get_contents(TC_PATH.'api/topGainersLosers/'.$time); 94 157 $response=json_decode($response); 95 158 echo '<div class="row">'; 96 159 echo '<div class="col-lg-12">'; 160 echo '<h2>Gainers</h2>'; 97 161 echo '<table class="table table-striped table-bordered table-hover">'; 98 echo '<caption>Gainers</caption>';99 162 echo '<thead>'; 100 163 echo '<tr>'; … … 109 172 if($response->errCode==1){ 110 173 foreach($response->data->gainers as $key => $value){ 111 echo '<tr>'; 174 echo '<tr>'; 112 175 echo '<td>'.($key+1).'</td>'; 113 176 echo '<td>'.strtoupper($value->name).'</td>'; … … 127 190 echo '</div>'; 128 191 echo '<div class="col-lg-12">'; 192 echo '<h2>Losers</h2>'; 129 193 echo '<table class="table table-striped table-bordered table-hover">'; 130 echo '<caption>Losers</caption>';131 194 echo '<thead>'; 132 195 echo '<tr>'; … … 163 226 add_shortcode('tc_top_products', 'tc_top_products'); 164 227 add_shortcode('tc_gainers_losers','tc_gainers_losers'); 165 228 229 /************************ Add plugin menu for admin section ****************************/ 230 add_action('admin_menu', 'tc_menu_pages'); 231 function tc_menu_pages(){ 232 add_menu_page('Totalcryptos', 'Totalcryptos', 'manage_options', 'totalcryptos', 'tc_settings' ); 233 add_submenu_page( 'totalcryptos', 'Help', 'Help', 'manage_options', 'my-admin-slug', 'tc_help' ); 234 235 } 236 237 function tc_settings(){ 238 //GET CHECKBOX DATA 239 $option_name = 'tc_currency_slider'; 240 $currency_data = get_option($option_name); 241 if($currency_data=='1'){ 242 $checked = "checked='checked'"; 243 } 244 else{ 245 $checked =""; 246 } 247 248 //GET DROPDOWN DATA FOR SLIDER 249 $option_name2 = 'tc_history_slider'; 250 $data_slider = get_option( $option_name2 ); 251 if(empty($history_slider)){ 252 $history_slider=''; 253 } 254 255 //GET DROPDOWN DATA FOR TABLE 256 $option_name3 = 'tc_gainers_losers_tables'; 257 $gainers_losers_tables = get_option( $option_name3 ); 258 if(empty($gainers_losers_tables)){ 259 $gainers_losers_tables=''; 260 } 261 262 //GET CURRENCIES DATA 263 $option_name4 = 'tc_currencies'; 264 $tc_currencies = get_option( $option_name4 ); 265 if(empty($tc_currencies)){ 266 $tc_currencies=''; 267 } 268 269 $html=""; 270 $html.="<div class='wrap'> <h1 class='wp-heading-inline'> Settings </h1>"; 271 if(isset($_POST["save_settings"])){ 272 $html.="<div class='updated notice'><p>Saved successfully.</p></div>"; 273 } 274 $html.="<div class='admin_settings'><form name='tc_admin' method='POST'>"; 275 276 $html.="<table>"; 277 278 $html.="<tr>"; 279 $html.="<td>"; 280 $html.="<label> Disable Currency Slider: </label>"; 281 $html.="</td>"; 282 $html.="<td>"; 283 $html.="<input type='hidden' name='page' value='totalcryptos'><input type='checkbox' class='currency_slider' name='tc_currency_slider' $checked value='1'>"; 284 $html.="</td>"; 285 $html.="</tr>"; 286 287 $html.="<tr>"; 288 $html.="<td>"; 289 $html.="<label> Show Data On Slider: </label>"; 290 $html.="</td>"; 291 $html.="<td>"; 292 $html.="<select name='tc_history_slider' style='width:300px;'>"; 293 $html.="<option value='1h'"; 294 if($history_slider=='1h'){ 295 $html.="selected='selected'"; 296 } 297 $html.=" >1 Hour (default)</option>"; 298 $html.="<option value='24h'"; 299 if($history_slider=='24h'){ 300 $html.="selected='selected'"; 301 } 302 $html.=" >24 Hour</option>"; 303 $html.="<option value='7d'"; 304 if($history_slider=='7d'){ 305 $html.="selected='selected'"; 306 } 307 $html.=" >7 Days</option>"; 308 $html.="</select>"; 309 $html.="</td>"; 310 $html.="</tr>"; 311 312 $html.="<tr>"; 313 $html.="<td>"; 314 $html.="<label> Enter Currencies To Display On slider:<br/>(Leave blank to show default data) </label>"; 315 $html.="</td>"; 316 $html.="<td>"; 317 $html.="<textarea name='tc_currencies' style='width:300px;'>".$tc_currencies."</textarea><br/>Enter comma seperated lists of currencies(eg btc, eth etc)."; 318 $html.="</td>"; 319 $html.="</tr>"; 320 321 $html.="<tr>"; 322 $html.="<td>"; 323 $html.="<label> Show Gainers/Losers Data In Tables: </label>"; 324 $html.="</td>"; 325 $html.="<td>"; 326 $html.="<select name='tc_gainers_losers_tables' style='width:300px;'>"; 327 $html.="<option value='1h'"; 328 if($gainers_losers_tables=='1h'){ 329 $html.="selected='selected'"; 330 } 331 $html.=" >1 Hour (default)</option>"; 332 $html.="<option value='24h'"; 333 if($gainers_losers_tables=='24h'){ 334 $html.="selected='selected'"; 335 } 336 $html.=" >24 Hour</option>"; 337 $html.="<option value='7d'"; 338 if($gainers_losers_tables=='7d'){ 339 $html.="selected='selected'"; 340 } 341 $html.=" >7 Days</option>"; 342 $html.="</select>"; 343 $html.="</td>"; 344 $html.="</tr>"; 345 346 $html.="</table>"; 347 $html.="<div class='form_footer'>"; 348 $html.="<input type='submit' name='save_settings' class='button button-primary' value='Save settings'>"; 349 $html.="</div>"; 350 $html.="</form>"; 351 $html.="</div>"; 352 $html.="</div>"; 353 echo $html; 354 } 355 356 function save_settings() 357 { 358 if(isset($_POST["save_settings"])){ 359 //SAVE CURRENCY SLIDER DATA 360 $option_name = 'tc_currency_slider'; 361 $new_value = $_POST["tc_currency_slider"]; 362 if(get_option($option_name)!==false){ 363 update_option($option_name,$new_value); 364 } 365 else{ 366 $deprecated = null; 367 $autoload = 'no'; 368 add_option($option_name, $new_value, $deprecated, $autoload); 369 } 370 //SAVE GAINERS/LOSERS SLIDER DATA 371 $option_name2 = 'tc_history_slider'; 372 $new_value2 = $_POST["tc_history_slider"]; 373 if(get_option($option_name2)!==false){ 374 update_option($option_name2,$new_value2); 375 } 376 else{ 377 $deprecated = null; 378 $autoload = 'no'; 379 add_option($option_name2, $new_value2, $deprecated, $autoload); 380 } 381 //SAVE GAINERS/LOSERS TABLES DATA 382 $option_name3 = 'tc_gainers_losers_tables'; 383 $new_value3 = $_POST["tc_gainers_losers_tables"]; 384 if(get_option($option_name3)!==false){ 385 update_option($option_name3,$new_value3); 386 } 387 else{ 388 $deprecated = null; 389 $autoload = 'no'; 390 add_option($option_name3, $new_value3, $deprecated, $autoload); 391 } 392 //SAVE CURRENCIES DATA 393 $option_name4 = 'tc_currencies'; 394 $new_value4 = $_POST["tc_currencies"]; 395 $new_value4 = preg_replace('/\s+/', '', $new_value4); 396 if(get_option($option_name4)!==false){ 397 update_option($option_name4,$new_value4); 398 } 399 else{ 400 $deprecated = null; 401 $autoload = 'no'; 402 add_option($option_name4, $new_value4, $deprecated, $autoload); 403 } 404 } 405 } 406 407 add_action( 'admin_init', 'save_settings' ); 408 409 function tc_help() 410 { 411 $html=""; 412 $html.="<div class='wrap'><h1 class='wp-heading-inline'> Help </h1><div class='admin_help'><h4>Please read following instructions to use this plugin.</h4><p><b>1.</b> Use shortcode [tc_top_products] to show top products.</p><p><b>2.</b> Use shortcode [tc_gainers_losers] to show top gainers/losers.</p><p><b>3.</b> Use shortcode [tc_tc100] to show TC index.</p><p><b>4.</b> By default ticker displays at footer. You can disable ticker by going into 'Settings' section. You can use shortcode [tc_market_marquee] to display this at any other place.</p></div></div>"; 413 414 echo $html; 415 } 416 417 /************************ Showing market marquee ****************************/ 418 419 function tc_market_marquee() 420 { 421 $time='1h'; 422 $history_slider = get_option( 'tc_history_slider' ); 423 if(!empty($history_slider)){ 424 $time=$history_slider; 425 } 426 427 $tc_currencies = get_option( 'tc_currencies' ); 428 if(empty($tc_currencies)){ 429 $data=array('time'=>$time,'currencies'=>array()); 430 } 431 else{ 432 $data=array('time'=>$time,'currencies'=>explode(',',$tc_currencies)); 433 } 434 $ch = curl_init(); 435 curl_setopt($ch, CURLOPT_URL, TC_PATH.'api/sliderData'); 436 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 437 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 438 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 439 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 440 'Content-Length: ' . strlen(json_encode($data))) 441 ); 442 443 $response = curl_exec($ch); 444 $response=json_decode($response); 445 if($response->errCode==1){ 446 $option_name = 'tc_currency_slider'; 447 if(empty(get_option( $option_name ))){ 448 if(empty($tc_currencies)){ 449 $Gainers_ApiData = $response->data->gainers; 450 $losers_ApiData = $response->data->losers; 451 $html = ""; 452 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 453 foreach($Gainers_ApiData as $key=>$val) 454 { 455 $g_currency = $val->name; 456 $g_symbol = $val->symbol; 457 $g_price = $val->price_usd; 458 $g_percentage = $val->percent_change_24h; 459 if(empty($g_percentage)){ $g_percentage = "0";} 460 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($g_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$g_currency."(".$g_symbol.")</span> <span class='gainers_price'>$".$g_price."</span> <span class='gainers_perc'>".$g_percentage."%</span> |</p></div>"; 461 } 462 463 foreach($losers_ApiData as $key=>$val2) 464 { 465 $l_currency = $val2->name; 466 $l_symbol = $val2->symbol; 467 $l_price = $val2->price_usd; 468 $l_percentage = $val2->percent_change_24h; 469 if(empty($l_percentage)){ $l_percentage = "0";} 470 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($l_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='losers_name'>".$l_currency."(".$l_symbol.")</span> <b> <span class='losers_price'> $".$l_price."</span> <span class='losers_perc'>".$l_percentage."%</span> </p></div>"; 471 } 472 $html.="</span></div>"; 473 return $html; 474 } 475 else{ 476 $ApiData = $response->data; 477 $html = ""; 478 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 479 foreach($ApiData as $key=>$val) 480 { 481 $currency = $val->name; 482 $symbol = $val->symbol; 483 $price = $val->price_usd; 484 $percentage = $val->percent_change_24h; 485 if(empty($percentage)){ $percentage = "0";} 486 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /> <span class='gainers_name'>".$currency."(".$symbol.")</span> "; 487 if($percentage>0){ 488 $html.= "<span class='gainers_price'>$".$price."</span> <span class='gainers_perc'>".$percentage."%</span> </p></div>"; 489 } 490 else{ 491 $html.= "<span class='losers_price'>$".$price."</span> <span class='losers_perc'>".$percentage."%</span> </p></div>"; 492 } 493 } 494 return $html; 495 } 496 } 497 } 498 else{ 499 return $response->message; 500 } 501 } 502 503 function tc_market_marquee_footer() { 504 echo tc_market_marquee(); 505 } 506 add_action( 'wp_footer', 'tc_market_marquee_footer', 100 ); 507 508 add_shortcode("tc_market_marquee","tc_market_marqueeshort"); 509 510 /************************ Marquee Shortcode ****************************/ 511 512 function tc_market_marqueeshort() 513 { 514 $time='1h'; 515 $history_slider = get_option( 'tc_history_slider' ); 516 if(!empty($history_slider)){ 517 $time=$history_slider; 518 } 519 520 $tc_currencies = get_option( 'tc_currencies' ); 521 if(empty($tc_currencies)){ 522 $data=array('time'=>$time,'currencies'=>array()); 523 } 524 else{ 525 $data=array('time'=>$time,'currencies'=>explode(',',$tc_currencies)); 526 } 527 $ch = curl_init(); 528 curl_setopt($ch, CURLOPT_URL, TC_PATH.'api/sliderData'); 529 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 530 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 531 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 532 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 533 'Content-Length: ' . strlen(json_encode($data))) 534 ); 535 536 $response = curl_exec($ch); 537 $response=json_decode($response); 538 if($response->errCode==1){ 539 $option_name = 'tc_currency_slider'; 540 if(!empty(get_option( $option_name ))){ 541 if(empty($tc_currencies)){ 542 $Gainers_ApiData = $response->data->gainers; 543 $losers_ApiData = $response->data->losers; 544 $html = ""; 545 $html.="<div class='news'><span class='news-item'>"; 546 foreach($Gainers_ApiData as $key=>$val) 547 { 548 $g_currency = $val->name; 549 $g_symbol = $val->symbol; 550 $g_price = $val->price_usd; 551 $g_percentage = $val->percent_change_24h; 552 if(empty($g_percentage)){ $g_percentage = "0";} 553 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($g_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$g_currency."(".$g_symbol.")</span> </b> <span class='gainers_price'>$".$g_price."</span> <span class='gainers_perc'>".$g_percentage."%</span> </p></div>"; 554 } 555 556 foreach($losers_ApiData as $key=>$val2) 557 { 558 $l_currency = $val2->name; 559 $l_symbol = $val2->symbol; 560 $l_price = $val2->price_usd; 561 $l_percentage = $val2->percent_change_24h; 562 if(empty($l_percentage)){ $l_percentage = "0";} 563 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($l_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='losers_name'>".$l_currency."(".$l_symbol.")</span> <span class='losers_price'> $".$l_price."</span> <span class='losers_perc'>".$l_percentage."%</span> </p></div>"; 564 } 565 $html.="</span></div>"; 566 return $html; 567 } 568 else{ 569 $ApiData = $response->data; 570 $html = ""; 571 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 572 foreach($ApiData as $key=>$val) 573 { 574 $currency = $val->name; 575 $symbol = $val->symbol; 576 $price = $val->price_usd; 577 $percentage = $val->percent_change_24h; 578 if(empty($percentage)){ $percentage = "0";} 579 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$currency."(".$symbol.")</span> "; 580 if($percentage>0){ 581 $html.= "<span class='gainers_price'>$".$price."</span> <span class='gainers_perc'>".$percentage."%</span> </p></div>"; 582 } 583 else{ 584 $html.= "<span class='losers_price'>$".$price."</span> <span class='losers_perc'>".$percentage."%</span> </p></div>"; 585 } 586 } 587 return $html; 588 } 589 } 590 } 591 else{ 592 return $response->message; 593 } 594 } 595 /************************ Showing TC100 Prices ****************************/ 596 597 function tc_tc100(){ 598 $response=file_get_contents(TC_PATH.'api/tcPrices'); 599 $response=json_decode($response); 600 if($response->errCode==1){ 601 echo "<div class='row'>"; 602 echo "<table class='tc100 table table-striped table-bordered table-hover' width='100%'>"; 603 echo '<thead>'; 604 echo "<tr>"; 605 echo "<th width='33.33%' style='text-align:center;'>"; 606 echo "TC100"; 607 echo "</th>"; 608 echo "<th width='33.33%' style='text-align:center;'>"; 609 echo "TCw100"; 610 echo "</th>"; 611 echo "<th width='33.33%' style='text-align:center;'>"; 612 echo "Total Market Cap"; 613 echo "</th>"; 614 echo "</tr>"; 615 echo '</thead>'; 616 echo "<td width='33.33%' style='text-align:center;'>"; 617 echo '$'.$response->data->tc100; 618 echo "</td>"; 619 echo "<td width='33.33%' style='text-align:center;'>"; 620 echo $response->data->tc100; 621 echo "</td>"; 622 echo "<td width='33.33%' style='text-align:center;'>"; 623 echo '$'.$response->data->total_usd_market_cap; 624 echo "</td>"; 625 echo "</tr>"; 626 echo "</table>"; 627 echo "</div>"; 628 } 629 else{ 630 echo $response->message; 631 } 632 633 } 634 add_shortcode('tc_tc100', 'tc_tc100'); -
total-cryptos/trunk/css/style.css
r1853947 r1878349 2668 2668 } 2669 2669 /* New Timeline style */ 2670 2670 2671 .vertical-container { 2671 2672 /* this class is used to give a max-width to the element it is applied to, and center it horizontally when it reaches that max-width */ … … 3734 3735 border: 1px solid #EBEBEB; 3735 3736 } 3737 .tc100{ 3738 width:auto !important; 3739 } 3740 .tc100 .col3{ 3741 width:33%; 3742 } 3743 .table-striped{ 3744 width:100%; 3745 display:inline-block; 3746 overflow-x: scroll; 3747 } 3736 3748 .table-bordered > thead > tr > th, 3737 3749 .table-bordered > thead > tr > td { … … 3761 3773 padding: 8px; 3762 3774 vertical-align: top; 3763 } 3775 width: 23%; 3776 } 3777 3764 3778 /* PANELS */ 3765 3779 .panel.blank-panel { … … 8451 8465 display: none; 8452 8466 } 8467 8468 .gainers_losers_div{ 8469 height:30px !important; 8470 background:#eaeaea; 8471 position:fixed; 8472 z-index:1; 8473 bottom:0; 8474 width:100%; 8475 } 8476 .news-item img{ 8477 margin:0; 8478 display:inline-block; 8479 vertical-align: text-bottom; 8480 } 8481 span.gainers_name{ 8482 font-size:18px; 8483 font-weight:bold; 8484 } 8485 span.losers_name{ 8486 font-size:18px; 8487 font-weight:bold; 8488 } 8489 span.gainers_price{ 8490 font-size:15px; 8491 font-weight:bold; 8492 display:inline-block; 8493 } 8494 span.losers_price{ 8495 font-size:15px; 8496 font-weight:bold; 8497 display:inline-block; 8498 } 8499 8500 span.gainers_perc { 8501 color: #027702; 8502 font-size:12px; 8503 font-weight:bold; 8504 } 8505 span.losers_perc { 8506 color: #f90c0c; 8507 font-size:12px; 8508 font-weight:bold; 8509 } 8453 8510 @media (min-width: 768px) { 8454 8511 #page-wrapper { … … 8578 8635 } 8579 8636 } 8637 8638 /*********** marquee slider css **********************/ 8639 .news-item{z-index:9; text-decoration:none;display:inline-block !important;} 8640 .news-item p, .gainers_texts{display:inline-block;} 8641 -
total-cryptos/trunk/js/totalcryptos.js
r1853947 r1878349 1 1 jQuery(document).ready(function($){ 2 $("#totalcryptos ").children('tr').each(function(){2 $("#totalcryptos_market_cap").children('tr').each(function(){ 3 3 var val=$("#hidden_"+this.id).val(); 4 4 $("#chart_"+this.id).html(''); … … 8 8 }); 9 9 10 $("#totalcryptos_usd").children('tr').each(function(){ 11 var val=$("#hidden_"+this.id).val(); 12 $("#chart_"+this.id).html(''); 13 if(val){ 14 $("#chart_"+this.id).sparkline(val.split(","), {type: 'line',width: '100%',height: '20',lineColor: '#1ab394',fillColor: "transparent"}); 15 } 16 }); 17 18 $(".default-ticker").ticker(); 19 var newsTicker = $(".news").ticker({ 20 speed: 50, 21 pauseOnHover: !0, 22 item: ".news-item" 23 }).data("ticker"); 24 $("#news-toggle").on("click", function() { 25 newsTicker.toggle() 26 }), $(".speed-test").each(function() { 27 $(this).ticker({ 28 speed: $(this).data("speed") || 60 29 }) 30 }); 10 31 }); -
total-cryptos/trunk/readme.txt
r1855166 r1878349 32 32 33 33 To display biggest Gainers and Losers, use the shortcode [tc_gainers_losers] 34 35 To display marquee slider on any place excpept footer, use the shortcode [tc_market_marqueeshort] 36 37 To display index price, use the shortcode [tc_tc100] 34 38 35 39 == Frequently Asked Questions == -
total-cryptos/trunk/totalcryptos.php
r1853947 r1878349 9 9 License: GPL 10 10 */ 11 12 13 14 11 define('TC_PATH','https://totalcryptos.com/'); 12 //define('TC_PATH','http://localhost:1337/'); 15 13 /************************** To Include JS Files ******************************/ 16 14 … … 21 19 wp_register_style( 'tc_c3min_css', plugins_url( 'css/c3.min.css', __FILE__), array(),null, false); 22 20 wp_register_style( 'tc_style_css', plugins_url( 'css/style.css', __FILE__), array(),null, false); 21 wp_register_style( 'tc_ticker_css', plugins_url( 'css/ticker.css', __FILE__), array(),null, false); 23 22 24 23 wp_enqueue_style('tc_c3min_css'); 25 24 wp_enqueue_style('tc_style_css'); 25 wp_enqueue_style('tc_ticker_css'); 26 26 27 27 28 //LOAD JS … … 31 32 wp_register_script('tc_sparkline_js', plugins_url('js/jquery.sparkline.min.js', __FILE__), array(),null, true); 32 33 wp_register_script('tc_js', plugins_url('js/totalcryptos.js', __FILE__), array(),null, true); 33 34 wp_register_script('tc_ticker_js', plugins_url('js/ticker.js', __FILE__), array(),null, true); 35 34 36 wp_enqueue_script('tc_c3min_js'); 35 37 wp_enqueue_script('tc_d3min_js'); 36 38 wp_enqueue_script('tc_datatable_js'); 37 39 wp_enqueue_script('tc_sparkline_js'); 40 wp_enqueue_script('tc_ticker_js'); 41 38 42 wp_enqueue_script('tc_js'); 39 } 43 44 } 45 add_action( 'admin_enqueue_scripts', 'load_tc_admin_styles' ); 46 function load_tc_admin_styles() { 47 wp_register_style( 'tc_admin_style', plugins_url( 'css/admin-style.css', __FILE__), array(),null, false); 48 wp_enqueue_style('tc_admin_style'); 49 } 40 50 41 51 /************************* To Get Top Product's Prices *************************/ 42 52 43 53 function tc_top_products(){ 44 $response=file_get_contents( 'http://totalcryptos.com/api/topProductsPrices');54 $response=file_get_contents(TC_PATH.'api/biggestGainers'); 45 55 $response=json_decode($response); 56 echo '<div class="row">'; 57 echo '<h2>Top Products Based On Market Capitalization</h2>'; 46 58 echo '<table class="table table-striped table-bordered table-hover">'; 47 echo '<caption>Top Products</caption>';48 59 echo '<thead>'; 49 60 echo '<tr>'; … … 58 69 echo '</tr>'; 59 70 echo '</thead>'; 60 echo '<tbody id="totalcryptos">'; 71 echo '<tbody id="totalcryptos_market_cap">'; 72 $i=0; 61 73 if($response->errCode==1){ 62 foreach($response->data as $key =>$value){74 foreach($response->data->products as $value){ 63 75 echo '<tr id="'.$value->product.'_totalcryptos">'; 64 echo '<td>'.($ key+1).'</td>';76 echo '<td>'.($i+1).'</td>'; 65 77 echo '<td>'.strtoupper($value->base_currency).'</td>'; 66 78 echo '<td>'.strtoupper(str_replace("_","",$value->product)).'</td>'; … … 77 89 echo '</td>'; 78 90 echo '</tr>'; 91 $i++; 79 92 } 80 93 } … … 86 99 echo '</tbody>'; 87 100 echo '</table>'; 101 echo '</div>'; 102 echo '<div class="row">'; 103 echo '<h2>Top Products Based On USD Price</h2>'; 104 echo '<table class="table table-striped table-bordered table-hover">'; 105 echo '<thead>'; 106 echo '<tr>'; 107 echo '<th>#</th>'; 108 echo '<th>Name</th>'; 109 echo '<th>Market</th>'; 110 echo '<th>Price</th>'; 111 echo '<th>Market Cap</th>'; 112 echo '<th>% Change (24h)</th>'; 113 echo '<th>Chart 1d</th>'; 114 echo '</tr>'; 115 echo '</thead>'; 116 echo '<tbody id="totalcryptos_usd">'; 117 $i=0; 118 if($response->errCode==1){ 119 foreach($response->data->gainers as $value){ 120 echo '<tr id="'.$value->id.'_totalcryptos">'; 121 echo '<td>'.($i+1).'</td>'; 122 echo '<td>'.strtoupper($value->name).'</td>'; 123 echo '<td>'.strtoupper($value->name.'USD').'</td>'; 124 echo '<td>$'.number_format($value->price_usd,8).'</td>'; 125 echo '<td>$'.number_format($value->market_cap_usd,0).'</td>'; 126 echo '<td>'.$value->percent_change_24h.'</td>'; 127 echo '<td>'; 128 echo '<div class="row">'; 129 echo '<div class="col-md-12" id="chart_'.$value->id.'_totalcryptos">'; 130 echo '<input type="hidden" id="hidden_'.$value->id.'_totalcryptos" value="'.implode($value->chart,',').'" />'; 131 echo '</div>'; 132 echo '</div>'; 133 echo '</td>'; 134 echo '</tr>'; 135 $i++; 136 } 137 } 138 else{ 139 echo '<tr>'; 140 echo '<td>'.$response->message.'</td>'; 141 echo '</tr>'; 142 } 143 echo '</tbody>'; 144 echo '</table>'; 145 echo '</div>'; 88 146 } 89 147 … … 91 149 92 150 function tc_gainers_losers(){ 93 $response=file_get_contents('http://totalcryptos.com/api/topGainersLosers'); 151 $time='1h'; 152 $gainers_losers_data = get_option( 'tc_gainers_losers_tables' ); 153 if(!empty($gainers_losers_data)){ 154 $time=$gainers_losers_data; 155 } 156 $response=file_get_contents(TC_PATH.'api/topGainersLosers/'.$time); 94 157 $response=json_decode($response); 95 158 echo '<div class="row">'; 96 159 echo '<div class="col-lg-12">'; 160 echo '<h2>Gainers</h2>'; 97 161 echo '<table class="table table-striped table-bordered table-hover">'; 98 echo '<caption>Gainers</caption>';99 162 echo '<thead>'; 100 163 echo '<tr>'; … … 109 172 if($response->errCode==1){ 110 173 foreach($response->data->gainers as $key => $value){ 111 echo '<tr>'; 174 echo '<tr>'; 112 175 echo '<td>'.($key+1).'</td>'; 113 176 echo '<td>'.strtoupper($value->name).'</td>'; … … 127 190 echo '</div>'; 128 191 echo '<div class="col-lg-12">'; 192 echo '<h2>Losers</h2>'; 129 193 echo '<table class="table table-striped table-bordered table-hover">'; 130 echo '<caption>Losers</caption>';131 194 echo '<thead>'; 132 195 echo '<tr>'; … … 163 226 add_shortcode('tc_top_products', 'tc_top_products'); 164 227 add_shortcode('tc_gainers_losers','tc_gainers_losers'); 165 228 229 /************************ Add plugin menu for admin section ****************************/ 230 add_action('admin_menu', 'tc_menu_pages'); 231 function tc_menu_pages(){ 232 add_menu_page('Totalcryptos', 'Totalcryptos', 'manage_options', 'totalcryptos', 'tc_settings' ); 233 add_submenu_page( 'totalcryptos', 'Help', 'Help', 'manage_options', 'my-admin-slug', 'tc_help' ); 234 235 } 236 237 function tc_settings(){ 238 //GET CHECKBOX DATA 239 $option_name = 'tc_currency_slider'; 240 $currency_data = get_option($option_name); 241 if($currency_data=='1'){ 242 $checked = "checked='checked'"; 243 } 244 else{ 245 $checked =""; 246 } 247 248 //GET DROPDOWN DATA FOR SLIDER 249 $option_name2 = 'tc_history_slider'; 250 $data_slider = get_option( $option_name2 ); 251 if(empty($history_slider)){ 252 $history_slider=''; 253 } 254 255 //GET DROPDOWN DATA FOR TABLE 256 $option_name3 = 'tc_gainers_losers_tables'; 257 $gainers_losers_tables = get_option( $option_name3 ); 258 if(empty($gainers_losers_tables)){ 259 $gainers_losers_tables=''; 260 } 261 262 //GET CURRENCIES DATA 263 $option_name4 = 'tc_currencies'; 264 $tc_currencies = get_option( $option_name4 ); 265 if(empty($tc_currencies)){ 266 $tc_currencies=''; 267 } 268 269 $html=""; 270 $html.="<div class='wrap'> <h1 class='wp-heading-inline'> Settings </h1>"; 271 if(isset($_POST["save_settings"])){ 272 $html.="<div class='updated notice'><p>Saved successfully.</p></div>"; 273 } 274 $html.="<div class='admin_settings'><form name='tc_admin' method='POST'>"; 275 276 $html.="<table>"; 277 278 $html.="<tr>"; 279 $html.="<td>"; 280 $html.="<label> Disable Currency Slider: </label>"; 281 $html.="</td>"; 282 $html.="<td>"; 283 $html.="<input type='hidden' name='page' value='totalcryptos'><input type='checkbox' class='currency_slider' name='tc_currency_slider' $checked value='1'>"; 284 $html.="</td>"; 285 $html.="</tr>"; 286 287 $html.="<tr>"; 288 $html.="<td>"; 289 $html.="<label> Show Data On Slider: </label>"; 290 $html.="</td>"; 291 $html.="<td>"; 292 $html.="<select name='tc_history_slider' style='width:300px;'>"; 293 $html.="<option value='1h'"; 294 if($history_slider=='1h'){ 295 $html.="selected='selected'"; 296 } 297 $html.=" >1 Hour (default)</option>"; 298 $html.="<option value='24h'"; 299 if($history_slider=='24h'){ 300 $html.="selected='selected'"; 301 } 302 $html.=" >24 Hour</option>"; 303 $html.="<option value='7d'"; 304 if($history_slider=='7d'){ 305 $html.="selected='selected'"; 306 } 307 $html.=" >7 Days</option>"; 308 $html.="</select>"; 309 $html.="</td>"; 310 $html.="</tr>"; 311 312 $html.="<tr>"; 313 $html.="<td>"; 314 $html.="<label> Enter Currencies To Display On slider:<br/>(Leave blank to show default data) </label>"; 315 $html.="</td>"; 316 $html.="<td>"; 317 $html.="<textarea name='tc_currencies' style='width:300px;'>".$tc_currencies."</textarea><br/>Enter comma seperated lists of currencies(eg btc, eth etc)."; 318 $html.="</td>"; 319 $html.="</tr>"; 320 321 $html.="<tr>"; 322 $html.="<td>"; 323 $html.="<label> Show Gainers/Losers Data In Tables: </label>"; 324 $html.="</td>"; 325 $html.="<td>"; 326 $html.="<select name='tc_gainers_losers_tables' style='width:300px;'>"; 327 $html.="<option value='1h'"; 328 if($gainers_losers_tables=='1h'){ 329 $html.="selected='selected'"; 330 } 331 $html.=" >1 Hour (default)</option>"; 332 $html.="<option value='24h'"; 333 if($gainers_losers_tables=='24h'){ 334 $html.="selected='selected'"; 335 } 336 $html.=" >24 Hour</option>"; 337 $html.="<option value='7d'"; 338 if($gainers_losers_tables=='7d'){ 339 $html.="selected='selected'"; 340 } 341 $html.=" >7 Days</option>"; 342 $html.="</select>"; 343 $html.="</td>"; 344 $html.="</tr>"; 345 346 $html.="</table>"; 347 $html.="<div class='form_footer'>"; 348 $html.="<input type='submit' name='save_settings' class='button button-primary' value='Save settings'>"; 349 $html.="</div>"; 350 $html.="</form>"; 351 $html.="</div>"; 352 $html.="</div>"; 353 echo $html; 354 } 355 356 function save_settings() 357 { 358 if(isset($_POST["save_settings"])){ 359 //SAVE CURRENCY SLIDER DATA 360 $option_name = 'tc_currency_slider'; 361 $new_value = $_POST["tc_currency_slider"]; 362 if(get_option($option_name)!==false){ 363 update_option($option_name,$new_value); 364 } 365 else{ 366 $deprecated = null; 367 $autoload = 'no'; 368 add_option($option_name, $new_value, $deprecated, $autoload); 369 } 370 //SAVE GAINERS/LOSERS SLIDER DATA 371 $option_name2 = 'tc_history_slider'; 372 $new_value2 = $_POST["tc_history_slider"]; 373 if(get_option($option_name2)!==false){ 374 update_option($option_name2,$new_value2); 375 } 376 else{ 377 $deprecated = null; 378 $autoload = 'no'; 379 add_option($option_name2, $new_value2, $deprecated, $autoload); 380 } 381 //SAVE GAINERS/LOSERS TABLES DATA 382 $option_name3 = 'tc_gainers_losers_tables'; 383 $new_value3 = $_POST["tc_gainers_losers_tables"]; 384 if(get_option($option_name3)!==false){ 385 update_option($option_name3,$new_value3); 386 } 387 else{ 388 $deprecated = null; 389 $autoload = 'no'; 390 add_option($option_name3, $new_value3, $deprecated, $autoload); 391 } 392 //SAVE CURRENCIES DATA 393 $option_name4 = 'tc_currencies'; 394 $new_value4 = $_POST["tc_currencies"]; 395 $new_value4 = preg_replace('/\s+/', '', $new_value4); 396 if(get_option($option_name4)!==false){ 397 update_option($option_name4,$new_value4); 398 } 399 else{ 400 $deprecated = null; 401 $autoload = 'no'; 402 add_option($option_name4, $new_value4, $deprecated, $autoload); 403 } 404 } 405 } 406 407 add_action( 'admin_init', 'save_settings' ); 408 409 function tc_help() 410 { 411 $html=""; 412 $html.="<div class='wrap'><h1 class='wp-heading-inline'> Help </h1><div class='admin_help'><h4>Please read following instructions to use this plugin.</h4><p><b>1.</b> Use shortcode [tc_top_products] to show top products.</p><p><b>2.</b> Use shortcode [tc_gainers_losers] to show top gainers/losers.</p><p><b>3.</b> Use shortcode [tc_tc100] to show TC index.</p><p><b>4.</b> By default ticker displays at footer. You can disable ticker by going into 'Settings' section. You can use shortcode [tc_market_marquee] to display this at any other place.</p></div></div>"; 413 414 echo $html; 415 } 416 417 /************************ Showing market marquee ****************************/ 418 419 function tc_market_marquee() 420 { 421 $time='1h'; 422 $history_slider = get_option( 'tc_history_slider' ); 423 if(!empty($history_slider)){ 424 $time=$history_slider; 425 } 426 427 $tc_currencies = get_option( 'tc_currencies' ); 428 if(empty($tc_currencies)){ 429 $data=array('time'=>$time,'currencies'=>array()); 430 } 431 else{ 432 $data=array('time'=>$time,'currencies'=>explode(',',$tc_currencies)); 433 } 434 $ch = curl_init(); 435 curl_setopt($ch, CURLOPT_URL, TC_PATH.'api/sliderData'); 436 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 437 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 438 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 439 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 440 'Content-Length: ' . strlen(json_encode($data))) 441 ); 442 443 $response = curl_exec($ch); 444 $response=json_decode($response); 445 if($response->errCode==1){ 446 $option_name = 'tc_currency_slider'; 447 if(empty(get_option( $option_name ))){ 448 if(empty($tc_currencies)){ 449 $Gainers_ApiData = $response->data->gainers; 450 $losers_ApiData = $response->data->losers; 451 $html = ""; 452 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 453 foreach($Gainers_ApiData as $key=>$val) 454 { 455 $g_currency = $val->name; 456 $g_symbol = $val->symbol; 457 $g_price = $val->price_usd; 458 $g_percentage = $val->percent_change_24h; 459 if(empty($g_percentage)){ $g_percentage = "0";} 460 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($g_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$g_currency."(".$g_symbol.")</span> <span class='gainers_price'>$".$g_price."</span> <span class='gainers_perc'>".$g_percentage."%</span> |</p></div>"; 461 } 462 463 foreach($losers_ApiData as $key=>$val2) 464 { 465 $l_currency = $val2->name; 466 $l_symbol = $val2->symbol; 467 $l_price = $val2->price_usd; 468 $l_percentage = $val2->percent_change_24h; 469 if(empty($l_percentage)){ $l_percentage = "0";} 470 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($l_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='losers_name'>".$l_currency."(".$l_symbol.")</span> <b> <span class='losers_price'> $".$l_price."</span> <span class='losers_perc'>".$l_percentage."%</span> </p></div>"; 471 } 472 $html.="</span></div>"; 473 return $html; 474 } 475 else{ 476 $ApiData = $response->data; 477 $html = ""; 478 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 479 foreach($ApiData as $key=>$val) 480 { 481 $currency = $val->name; 482 $symbol = $val->symbol; 483 $price = $val->price_usd; 484 $percentage = $val->percent_change_24h; 485 if(empty($percentage)){ $percentage = "0";} 486 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /> <span class='gainers_name'>".$currency."(".$symbol.")</span> "; 487 if($percentage>0){ 488 $html.= "<span class='gainers_price'>$".$price."</span> <span class='gainers_perc'>".$percentage."%</span> </p></div>"; 489 } 490 else{ 491 $html.= "<span class='losers_price'>$".$price."</span> <span class='losers_perc'>".$percentage."%</span> </p></div>"; 492 } 493 } 494 return $html; 495 } 496 } 497 } 498 else{ 499 return $response->message; 500 } 501 } 502 503 function tc_market_marquee_footer() { 504 echo tc_market_marquee(); 505 } 506 add_action( 'wp_footer', 'tc_market_marquee_footer', 100 ); 507 508 add_shortcode("tc_market_marquee","tc_market_marqueeshort"); 509 510 /************************ Marquee Shortcode ****************************/ 511 512 function tc_market_marqueeshort() 513 { 514 $time='1h'; 515 $history_slider = get_option( 'tc_history_slider' ); 516 if(!empty($history_slider)){ 517 $time=$history_slider; 518 } 519 520 $tc_currencies = get_option( 'tc_currencies' ); 521 if(empty($tc_currencies)){ 522 $data=array('time'=>$time,'currencies'=>array()); 523 } 524 else{ 525 $data=array('time'=>$time,'currencies'=>explode(',',$tc_currencies)); 526 } 527 $ch = curl_init(); 528 curl_setopt($ch, CURLOPT_URL, TC_PATH.'api/sliderData'); 529 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 530 curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 531 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 532 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 533 'Content-Length: ' . strlen(json_encode($data))) 534 ); 535 536 $response = curl_exec($ch); 537 $response=json_decode($response); 538 if($response->errCode==1){ 539 $option_name = 'tc_currency_slider'; 540 if(!empty(get_option( $option_name ))){ 541 if(empty($tc_currencies)){ 542 $Gainers_ApiData = $response->data->gainers; 543 $losers_ApiData = $response->data->losers; 544 $html = ""; 545 $html.="<div class='news'><span class='news-item'>"; 546 foreach($Gainers_ApiData as $key=>$val) 547 { 548 $g_currency = $val->name; 549 $g_symbol = $val->symbol; 550 $g_price = $val->price_usd; 551 $g_percentage = $val->percent_change_24h; 552 if(empty($g_percentage)){ $g_percentage = "0";} 553 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($g_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$g_currency."(".$g_symbol.")</span> </b> <span class='gainers_price'>$".$g_price."</span> <span class='gainers_perc'>".$g_percentage."%</span> </p></div>"; 554 } 555 556 foreach($losers_ApiData as $key=>$val2) 557 { 558 $l_currency = $val2->name; 559 $l_symbol = $val2->symbol; 560 $l_price = $val2->price_usd; 561 $l_percentage = $val2->percent_change_24h; 562 if(empty($l_percentage)){ $l_percentage = "0";} 563 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($l_symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='losers_name'>".$l_currency."(".$l_symbol.")</span> <span class='losers_price'> $".$l_price."</span> <span class='losers_perc'>".$l_percentage."%</span> </p></div>"; 564 } 565 $html.="</span></div>"; 566 return $html; 567 } 568 else{ 569 $ApiData = $response->data; 570 $html = ""; 571 $html.="<div class='news gainers_losers_div'><span class='news-item'>"; 572 foreach($ApiData as $key=>$val) 573 { 574 $currency = $val->name; 575 $symbol = $val->symbol; 576 $price = $val->price_usd; 577 $percentage = $val->percent_change_24h; 578 if(empty($percentage)){ $percentage = "0";} 579 $html.= "<div class='gainers_texts'><img src='".TC_PATH."images/currencies/".strtolower($symbol).".png' width='20px' height='20px' onError=\"this.src='".TC_PATH."images/currency.png'\" /><p> <span class='gainers_name'>".$currency."(".$symbol.")</span> "; 580 if($percentage>0){ 581 $html.= "<span class='gainers_price'>$".$price."</span> <span class='gainers_perc'>".$percentage."%</span> </p></div>"; 582 } 583 else{ 584 $html.= "<span class='losers_price'>$".$price."</span> <span class='losers_perc'>".$percentage."%</span> </p></div>"; 585 } 586 } 587 return $html; 588 } 589 } 590 } 591 else{ 592 return $response->message; 593 } 594 } 595 /************************ Showing TC100 Prices ****************************/ 596 597 function tc_tc100(){ 598 $response=file_get_contents(TC_PATH.'api/tcPrices'); 599 $response=json_decode($response); 600 if($response->errCode==1){ 601 echo "<div class='row'>"; 602 echo "<table class='tc100 table table-striped table-bordered table-hover' width='100%'>"; 603 echo '<thead>'; 604 echo "<tr>"; 605 echo "<th width='33.33%' style='text-align:center;'>"; 606 echo "TC100"; 607 echo "</th>"; 608 echo "<th width='33.33%' style='text-align:center;'>"; 609 echo "TCw100"; 610 echo "</th>"; 611 echo "<th width='33.33%' style='text-align:center;'>"; 612 echo "Total Market Cap"; 613 echo "</th>"; 614 echo "</tr>"; 615 echo '</thead>'; 616 echo "<td width='33.33%' style='text-align:center;'>"; 617 echo '$'.$response->data->tc100; 618 echo "</td>"; 619 echo "<td width='33.33%' style='text-align:center;'>"; 620 echo $response->data->tc100; 621 echo "</td>"; 622 echo "<td width='33.33%' style='text-align:center;'>"; 623 echo '$'.$response->data->total_usd_market_cap; 624 echo "</td>"; 625 echo "</tr>"; 626 echo "</table>"; 627 echo "</div>"; 628 } 629 else{ 630 echo $response->message; 631 } 632 633 } 634 add_shortcode('tc_tc100', 'tc_tc100');
Note: See TracChangeset
for help on using the changeset viewer.