Adding Bitcoin URI to WordPress

I just came across a problem when i tried to add a Bitcoin Donation Button to my WordPress installation.

Always when i tried to add a link which started with „bitcoin:“ so it is recognized by the Wallet Software on my Desktop WordPress totally crippled the link, stripping out the „bitcoin:“ URI.

Would not have been a big deal but i wanted to have this resolved. It seems that WordPress filter that URI so that only „valid“ URI’s are accepted like http or ftp.

Now i searched for a solution where i don’t have to change core files (which is bad) or theme files so that it also would work after an updated. After researching a bit i found a solution using WordPress „Must-use-plugins“.

So what you have to do? Simply FTP to your WordPress install directory and add a directory called mu-plugins inside your wp-content folder.

Now create a textfile called bitcoin-uri-enabler.php and paste this content into it:

<?php
/**
 * Plugin Name: Bitcoin URI enabler
 * Plugin URI: http://blog.sengotta.net
 * Description: This plugin enables the Bitcoin URI on your WordPress installation
 * Author: Björn Sengotta
 * Author URI: http://blog.sengotta.net
 * Version: 0.1.0
 */

function ss_allow_bitcoin_protocol( $protocols ){
 $protocols[] = 'bitcoin';
 return $protocols;
}
add_filter( 'kses_allowed_protocols' , 'ss_allow_bitcoin_protocol' );
?>

Upload that file to the mu-plugins folder. The plugins is activated be default and you can find it in your Dashboard under Plugins- Must-Use.

The bitcoin URI should now be correctly recognized by WordPress.

To achieve the following infos were really helpful:

http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users

http://sevenspark.com/tutorials/skype-uri-link-wordpress-menu

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert