How to Add a Bitcoin Donation Button to WordPress
Use a Custom HTML block with a link to a merchant-controlled donation page. The PHP helper generates the markup for a theme or plugin. Replace the example URL in both the allowlist and caller. Do not embed wallet credentials in HTML. A static link does not track individual donations.
Source code
1<?php
2function btc_button(string $url): string {
3 if ($url !== 'https://example.org/donate') throw new InvalidArgumentException('Unapproved URL');
4 return '<a href="'.htmlspecialchars($url, ENT_QUOTES, 'UTF-8').'">Donate Bitcoin</a>';
5}
6if (PHP_SAPI === 'cli') { if (!str_contains(btc_button('https://example.org/donate'), 'Donate Bitcoin')) exit(1); }Validation and deployment
Use a staging site and testnet first. Verify the destination, test duplicate payment notifications and keep fulfillment separate from browser requests. This example was checked locally, not inside a live CMS.
Related documentation
https://thamer.org/api
