Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This example code adds some fixed exchange rates to the Bitcoin and Altcoin Wallets WordPress plugin version 3.4.0 or later.
<?php
/*
* Plugin Name: Bitcoin and Altcoin Wallets: Fixed exchange rates extension
* Description: Example of how to add fixed exchange rates to Bitcoin and Altcoin Wallets.
* Version: 1.0.0
* Plugin URI: https://gist.github.com/alex-georgiou/492196184f206002c864225180ca8fbb
* Author: Alexandros Georgiou <info@dashed-slug.net>
* Author URI: http://dashed-slug.net
* License: GPLv2 or later
*
*/
/**
* This example code adds some fixed exchange rates to the Bitcoin and Altcoin Wallets WordPress plugin.
*
* This script showcases how to provide fixed exchange rates for a coin manually.
* You can extend it to provide exchange rates from any source.
* Make sure to include your code before the WordPress init action fires.
* You could wrap it into a plugin for convenience.
*
* @author Alexandros Georgiou <info@dashed-slug.net>
* @since 3.4.0
*/
/**
* Adds two new cryptocurrency coins with symbols ABC and XYZ
* @param array $cryptos
* @param string $provider
* @return array
*/
function wallets_rates_cryptos_fixed( $cryptos ) {
$cryptos[] = 'ABC';
$cryptos[] = 'XYZ';
return $cryptos;
}
add_filter( 'wallets_rates_cryptos', 'wallets_rates_cryptos_fixed' );
/**
* Specifies some exchange rates manually
* @param array $rates
* @param string $provider
* @return array
*/
function wallets_rates_fixed( $rates ) {
$rates['ABC_XYZ'] = 0.1;
$rates['XYZ_USD'] = 1.23;
return $rates;
}
add_filter( 'wallets_rates', 'wallets_rates_fixed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.