How to add a No-Fee InBrowser Monero Miner to your WordPress Site

In-Browser Cryptomining is the latest and greatest way to monetize your website and now it’s super simple to add it to any WordPress site. If you went to the Plugin directory, you’d see there are already WordPress plugins for in-browser mining, but you would notice that the developer takes a cut of your profits! Today I will teach you how to write a super simple plugin to add an inbrowser Monero miner to your WordPress site completely free of 3rd party developer fees!

If you haven’t thought about the ethics or your legal responsibilities regarding using your site users CPU for mining, you might want to check out our article on In-Browser Mining. Nobody is really sure of the legal ramifications of using this software, so please install it at your own risk.

Step Two – Create the Plug-in

By building our code into a WordPress plugin, we make it super simple to inject our Javascript code without touching the core WordPress files, meaning there is no chance of breaking our website. It also means we aren’t messing around with our themes and you will be able to Enable/Disable your mining code with a simple click of the button.

Extract the zip file into a directory by itself. We will be adding your public key to one of the files.

A more in-depth explanation of how the plugin works is provided below.

Open the Public folder

Open the JS folder.

Open monero-miner-wp-public.js in a text editor.

This is the function where we tell the miner to start working. You can see it already has a public key in the function call.

Replace this key with the public key you got earlier from the Coin-Hive Sites & API Keys page.

Save the file.

Zip the files back up into a .zip file

Open your WordPress Site and login to the admin dashboard.

Scroll over the Plugins Menu bar and select Add New

Click the Upload Plugin button

Find the zip file you earlier and Upload and Activate.

Done! Your Monero miner is now mining for you whenever somebody opens your website. You can test it is working by opening your Dashboard on Coin-Hive and watching the Hashes counter.

The Nuts & Bolts (Advanced users only)

nofee-monero-miner-wp.php

This file is the is the constructor for our WordPress Plugin. It contains the activate, deactivate and run functions required for WordPress plugins. It also contains the WordPress function we use to include the Coin-Hive script.

Public folder

This folder contains all the public content for the plugin to display. The only part of this that we have modified is where we call the Activate miner function in the public/js/nofee-monero-miner-wp-public.js file.

Simple as that =)

If you are interested in investing in cryptocurrencies like Monero, Bitcoin or others, you can find where they are listed at Where Can I Buy That Crypto or check out Coinspot.