dashed-slug.net › Forums › General discussion › Use of the plugin’s front end without the need for JavaScript › Reply To: Use of the plugin’s front end without the need for JavaScript
Thank you for this, it helped a lot, I was able to display the customer’s balance on the customer’s page through a plugin using your documentation, but now I’m having difficulty generating an address, I used the parameter described in this topic: https://wallets- phpdoc.dashed-slug.net/wallets/classes/DSWallets-Wallet-Adapter.html#method_get_new_address but I was not successful in returning the wallet adapter, is there any topic that helps in communicating with the bitcoin wallet adapter?
but thank you for your attention
Here is the plugin code, just for testing I left the code with both features together
add_shortcode(‘exibir_saldos’, ‘exibir_saldos_usuario’);
function exibir_saldos_usuario() {
if (!function_exists(‘DSWallets\get_all_currencies’) || !function_exists(‘DSWallets\get_balance_for_user_and_currency_id’)) {
return ‘As funções necessárias do plugin não estão disponíveis.’;
}
$user_id = get_current_user_id();
if (!$user_id) {
return ‘Usuário não identificado.’;
}
$currencies = DSWallets\get_all_currencies();
$output = ‘<div class=”saldos-de-moedas”>’;
foreach ($currencies as $currency) {
// Certifique-se de que o objeto $currency tem a propriedade ou método esperado para obter o currency_id
// Esta linha é um palpite sobre como você poderia acessar o currency_id corretamente
$currency_id = property_exists($currency, ‘post_id’) ? $currency->post_id : 0; // Ajuste conforme necessário
$saldo = DSWallets\get_balance_for_user_and_currency_id($user_id, $currency_id);
$formatted_balance = number_format($saldo * pow(10, -$currency->decimals), $currency->decimals, ‘.’, ”);
$output .= ‘<div class=”moeda”>’;
$output .= ‘<span class=”nome-moeda”>’ . esc_html($currency->name) . ‘</span>: ‘;
$output .= ‘<span class=”saldo-moeda”>’ . esc_html($formatted_balance) . ‘ ‘ . esc_html($currency->symbol) . ‘</span>’;
$output .= ‘</div>’;
}
$output .= ‘</div>’;
return $output;
}
function gerar_novo_endereco() {
$currency = null;
$wallets = new Wallets();
$new_address = $wallets->get_new_address($currency);
return $new_address->get_address();
}
add_shortcode(‘gerar_endereco’, ‘gerar_novo_endereco’);