Wallet shortcodes display forms to the front-end that let the users access their cryptocurrency accounts.

All the operations accessible via shortcodes are only relevant to logged in users. The shortcodes will only display if:

  1. the user is logged in, and
  2. the user has the has_wallets capability, and
  3. there is at least one coin adapter online.

Note: The same set of UI elements is also available as widgets to be inserted in your theme’s widget area. Navigate to AppearanceWidgets to configure, or set via the Customizer.

wallet shortcodes reference

deposit funds

Deposit UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_deposit] shortcode to display a UI that will let the user know which address they can send coins to if they wish to make a deposit.

As of version 3.6.2, this UI accepts an optional qrsize argument: If set to an integer, determines the size (width and height) of the deposit QR code, in pixels. For example, to display a deposit UI with a QR code sized at 120×120 pixels:

[wallets_deposit qrsize="120"]

If the argument is left empty, no explicit size is set. The qrsize argument is also available when the UI is used as a Widget.

You can also use [wallets_deposit template="list"]:

Deposit addresses list UI in Bitcoin and Altcoin Wallets WordPress plugin

withdraw funds

Withdraw UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_withdraw] shortcode to display a form that will let the user withdraw funds. The user will be notified by email when the withdrawal succeeds.

transfer funds to other users

Internal transfer UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_move] shortcode to display a form that lets the user transfer coins to other users on your site. Both users will be notified by email when the transaction succeeds.

display user balance(s)

Banance UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_balance] shortcode to show the current user’s balances.

You can also use [wallets_balance template="list"]:

Balances list UI in Bitcoin and Altcoin Wallets WordPress plugin

view past transactions

Transactions UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_transactions] shortcode to display an interactive table that shows past deposits, withdrawals and transfers that affect the user’s account. The table is paginated and data is loaded dynamically.

You can also use [wallets_transactions template="rows"]:

Transactions rows UI in Bitcoin and Altcoin Wallets WordPress plugin

 

display account value

Use the [wallets_account_value] shortcode to show the account's total value expressed in the default fiat currency.
Use the [wallets_account_value] shortcode to show the account’s total value expressed in the default fiat currency. Introduced in version 3.1.3.

display total user balances per coin

Use the [wallets_total_balances] shortcode to show the total user balances for each coin. Introduced in 3.6.0.

Unlike other UIs, this one is static. It is rendered as an HTML when the page loads, and it is not updated with the live polling mechanism (does not use the JSON API).

Display exchange rates for each coin

Exchange Rates UI in Bitcoin and Altcoin Wallets WordPress plugin

Use the [wallets_rates] shortcode to show the exchange rates between each coin and the default fiat currency.

Only currencies whose exchange rate is known will be listed.

The UI will not show, if the user set their default fiat currency to “none”. This can be done in the user profile admin screen.

 

capturing events on the front-side

Withdraw and move forms use JavaScript to emit bubbling DOM events to denote that a withdrawal or a transfer to another user has succeeded.

The event names are:

  • wallets_do_withdraw, and
  • wallets_do_move.

The default behavior is to display informative message boxes using the browser’s alert() function.

You can bind handlers to these DOM events to override, or to add to, this behavior.

The event handlers have access to the response of the JSON API, and to the form values entered by the user. Here’s some example JavaScript code:

Observing transfers between users:

jQuery('body').on( 'wallets_do_move', function( event, response, symbol, amount, toaccount, comment ) {
    if ( typeof(response.result) == 'string') {
        if ( response.result == 'success' ) {
            alert( 'Successfully sent ' + amount + ' ' + symbol );
        } else {
            alert( "Move failed: \n" + response.message );
        }
    } else {
        alert( "Move failed!" );
    }
    event.preventDefault();
});

Observing withdrawals:

jQuery('body').on( 'wallets_do_withdraw', function( event, response, symbol, amount, address, comment, commentto ) {
    if ( typeof(response.result) == 'string') {
        if ( response.result == 'success' ) {
            alert( 'Successfully withdrew ' + amount + ' ' + symbol + ' to ' + address );
        } else {
            alert( "Move failed: \n" + response.message );
        }
    } else {
        alert( "Move failed!" );
    }
    event.preventDefault();
});

The above examples override the default handlers. If you wish to add to the default behavior, simply delete the event.preventDefault() statements and let the events bubble up.

overriding the default UI

Using CSS

All the UI elements have the dashed-slug-wallets class to help you with CSS styling:

.dashed-slug-wallets.move { }
.dashed-slug-wallets.withdraw { }
.dashed-slug-wallets.balance { }
.dashed-slug-wallets.deposit { }
.dashed-slug-wallets.transactions { }

Using HTML and PHP and JavaScript and CSS and stuff!

If you are a developer, you can override the default forms provided to do much more than just change the styling.

All the UI elements are implemented as knockout.js forms that talk to the provided JSON API.

These forms live in the wp-content/plugins/wallets/includes/views directory of your WordPress installation:

wp-content/plugins/wallets/includes/views/balance.php
wp-content/plugins/wallets/includes/views/move.php
wp-content/plugins/wallets/includes/views/deposit.php
wp-content/plugins/wallets/includes/views/withdraw.php
wp-content/plugins/wallets/includes/views/transactions.php

You can copy these files to another directory of your choosing. Make sure to override the views directory using the wallets_views_dir filter, to let the plugin know where to look for the templates. Here’s sample code for how to do this:

function my_wallets_views_dir_override( $dir ) {
    return '/path/to/the/directory/where/the/new/templates/are/copied';
}
add_filter( 'wallets_views_dir', 'my_wallets_views_dir_override' );

download

Visit the download area to get this plugin!

Make sure to download the bundle to get the documentation too!

Wallet shortcodes

Updated on 2018-07-30T18:56:18+00:00, by alexg.