Lightning Publisher is a Bitcoin Lightning Paywall and Donation plugin for Wordpress. It allows you to receive Bitcoin Lightning payments with your WordPress website.
Here quick Demo videos showing how to setup and use the plugin:
Clone the repository and install the dependency
git clone https://github.com/getAlby/lightning-publisher-wordpress.git
cd lightning-publisher-wordpress
composer install # (maybe you need to add `--ignore-platform-reqs`)
To build a .zip file of the WordPress plugin run:
./build.sh # this builds a `wordpress-lightning-publisher.zip`
Then upload and activate the plugin.
- Fixed amount
- Free once a certrain amount is collected
- Free after a certain time
- Free until a certain time
To integrate with other plugins or to write custom conditions on when the paywall should be enabled a hook can be used. This means you can use a custom PHP function to decide if content should be behind the paywall or not.
This for example allows you to make the content available for all users/subscribers but enable the paywall for all other users.
// your function receives two arguments:
// 1. a boolean with the current check (true if the full content would be shown)
// 2. the ID of the post the user accesses
//
// return true if the full content should be shown or false to enable the paywall
function show_full_content_for_post($show_full_content, $post_id) {
// Add your logic to check if the current user can see the post with ID $post_id
return true; // return true to show the full content (disable the paywall)
}
// Check out the `add_filter` documentation for more information: https://developer.wordpress.org/reference/functions/add_filter/
add_filter('wp_lnp_has_paid_for_post', 'show_full_content_for_post', 10, 2);
Alternatively you can define a global function wp_lnp_has_paid_for_post
which gets called. Return true
to disable the paywall and show the full content.
function wp_lnp_has_paid_for_post($show_full_content, $post_id) {
return true; // show full content - disable the paywall
}
Use the plugin as a shortcode/widget/block.
Folder structure is based on https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
wp-lightning.php
is the entrypoint of the pluginincludes
is where functionality shared between the admin area and the public-facing parts of the site resideadmin
is for all admin-specific functionalitypublic
is for all public-facing functionalityincludes/class-wp-lightning.php
is the main plugin class which handles including all the related classes.includes/class-wp-lightning-loader.php
is responsible for registering the action and filter hooks, and shortcodes.
The plugin also provides a set of REST API Endpoints for handling payments and donations.
- URL:
/lnp-alby/v1/paywall/pay
- Method:
POST
- Auth Required: No
- Data example
{
post_id: "xxx"
}
- URL:
/lnp-alby/v1/paywall/verify
- Method:
POST
- Auth Required: No
- Data example
{
post_id: "xxx",
token: "xxx",
preimage: "xxx"
}
- URL:
/lnp-alby/v1/donate
- Method:
POST
- Auth Required: No
- Data example
{
post_id: "xxx",
amount: "xxx"
}
- URL:
/lnp-alby/v1/verify
- Method:
POST
- Auth Required: No
- Data example
{
amount: "xxx",
token: "xxx",
preimage: "xxx"
}
MIT