https://github.com/bumi/wp-lightning
https://github.com/bumi/wp-lightning
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bumi/wp-lightning
- Owner: bumi
- License: mit
- Created: 2020-06-01T13:08:42.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-05T21:22:38.000Z (almost 4 years ago)
- Last Synced: 2025-03-21T22:03:12.880Z (about 1 year ago)
- Language: PHP
- Size: 2.46 MB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lightning Publisher for WordPress
Lightning Publisher is a Bitcoin Lightning Paywall and Donation plugin for Wordpress. It allows you to receive Bitcoin Lightning payments with your WordPress website.
## Demo
Here quick Demo videos showing how to setup and use the plugin:
+ [Quck Start - setup + paywall setup](https://www.loom.com/share/095b49a87e444442ac7b297f9483dfa7)
+ [Admin Panel](https://www.loom.com/share/dbe501fe9d91445082a2c5c07a1a8ce8)
## Installation
Clone the repository and install the dependency
```bash
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:
```bash
./build.sh # this builds a `wordpress-lightning-publisher.zip`
```
Then upload and activate the plugin.
## Paywall
### Paywall options
* Fixed amount
* Free once a certrain amount is collected
* Free after a certain time
* Free until a certain time
#### Paywall Hook to have custom logic when to enable/disable the paywall
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.
##### Example
```php
// 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.
```php
function wp_lnp_has_paid_for_post($show_full_content, $post_id) {
return true; // show full content - disable the paywall
}
```
### Usage
Use the plugin as a shortcode/widget/block.
## Plugin Folder Structure
Folder structure is based on https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
- `wp-lightning.php` is the entrypoint of the plugin
- `includes` is where functionality shared between the admin area and the public-facing parts of the site reside
- `admin` is for all admin-specific functionality
- `public` is for all public-facing functionality
- `includes/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.
## REST API
The plugin also provides a set of REST API Endpoints for handling payments and donations.
#### Intiate Payment for Paywall
- URL: `/lnp-alby/v1/paywall/pay`
- Method: `POST`
- Auth Required: No
- Data example
```
{
post_id: "xxx"
}
```
#### Verify Payment for Paywall
- URL: `/lnp-alby/v1/paywall/verify`
- Method: `POST`
- Auth Required: No
- Data example
```
{
post_id: "xxx",
token: "xxx",
preimage: "xxx"
}
```
#### Initiate Donation
- URL: `/lnp-alby/v1/donate`
- Method: `POST`
- Auth Required: No
- Data example
```
{
post_id: "xxx",
amount: "xxx"
}
```
#### Verify Donation
- URL: `/lnp-alby/v1/verify`
- Method: `POST`
- Auth Required: No
- Data example
```
{
amount: "xxx",
token: "xxx",
preimage: "xxx"
}
```
## License
MIT