DOCUMENTATION

Initial Setup: Connecting to Cloudflare R2

Before you can use the plugin, you must connect it to your Cloudflare R2 bucket.

  1. Navigate to CloudSecure Downloads -> Settings in your WordPress dashboard.
  2. Go to your Cloudflare Dashboard and create an R2 bucket if you haven't already.
  3. In Cloudflare, go to R2 -> Manage R2 API Tokens and create a new API token with "Object Read & Write" permissions.
  4. Copy the credentials from Cloudflare and paste them into the plugin's settings page:
    • Access Key ID: Your Cloudflare R2 Access Key ID.
    • Secret Access Key: Your Cloudflare R2 Secret Access Key. (This will be encrypted and stored securely in your database).
    • Account ID: Your Cloudflare Account ID. You can find this in the main dashboard URL or the R2 overview page.
    • Bucket Name: The exact name of your R2 bucket.
  5. Click the Test Connection button. You should see a success message. If not, double-check that all credentials have been copied correctly.
  6. Click Save Settings.

Selling Digital Products with WooCommerce

This is the core functionality for both the Standard and Pro versions of the plugin.

  1. Edit or create a new Product in WooCommerce.
  2. In the product data section, check the box for Downloadable.
  3. In the "CloudSecure Downloads Pro" panel that appears, check the box for Use Cloudflare R2 Storage.
  4. A new field will appear: R2 Object Key. Enter the path to your file within your R2 bucket (e.g., courses/my-video-course.zip or ebooks/my-guide.pdf).
  5. (Optional) For Pro users, you can configure the License Type for this product. If a license type other than "none" is selected, a unique license key will be generated and emailed to the customer upon purchase completion.
  6. Update or Publish the product.

Now, when a customer purchases this product, they will receive a secure, expiring download link that points directly to your file in R2, instead of a link to a file on your local server.

Using Shortcodes for Content Display

You can display secure content anywhere on your site using shortcodes.

csd_video

Embeds a secure, streaming video player.

  • key (required): The R2 object key for the video file. (e.g., videos/intro.mp4)
  • access: Who can see the video. Options: public, loggedin. (Default: public)
  • width: Player width. (Default: 100%)
  • controls: Show player controls. (Default: true)
  • autoplay: Autoplay the video (often requires muted=true). (Default: false)
  • loop: Loop the video. (Default: false)
  • muted: Mute the video. (Default: false)

Example: csd_video key="training/module-1.mp4" access="loggedin" autoplay="true"

csd_download_link

Creates a download link for a specific product, only visible to users who have purchased it.

  • product_id (required): The WooCommerce product ID.
  • text: The link text. (Default: Download Now)
  • class: CSS class for the link. (Default: button csd-download-button)

Example: csd_download_link product_id="123" text="Download Your E-book"

csd_secure_asset (Pro)

The most powerful shortcode for delivering any type of asset with advanced controls.

  • key (required): The R2 object key for the asset.
  • type: How to deliver the asset. Options: download, stream, embed. (Default: download)
  • access: Access level. Options: public, loggedin, role:administrator. (Default: public)
  • text: Text for download links. (Default: Download Asset)
  • ...and all attributes from the csd_video shortcode (width, controls, etc.).

Example: csd_secure_asset key="blueprints/project-files.zip" type="download" access="loggedin" text="Download Project Files"

The Software Licensing Platform (Pro)

This section is for Pro users who want to sell and manage licenses for their own software (e.g., WordPress plugins, themes, desktop apps).

Creating Software Products

Before you can generate licenses, you must define your software products.

  1. Navigate to CloudSecure Downloads -> Software Products.

  2. Fill out the "Add New Software Product" form:

    • Product Name: The public name of your software (e.g., "My Awesome Plugin").

    • Product Slug: A unique, URL-friendly identifier (e.g., my-awesome-plugin). This is what you will use in your API calls.

    • Version: The current version of your software (e.g., 1.0.0).

    • Product Type: Helps you categorize your products (e.g., WordPress Plugin, Desktop Application).

  3. Click Add Product.

Managing Licenses & Activations

You can generate licenses automatically through WooCommerce sales (see section 2) or manually.

  1. Navigate to CloudSecure Downloads -> Software Licenses.

  2. To create a license manually, fill out the "Generate New License" form.

  3. From the "Existing Software Licenses" table, you can view all licenses, see their activation counts, status, and expiry dates.

Developer Guide (Pro)

This section is for developers using the REST API or integrating license checks into their own PHP-based products.

Using the REST API

The REST API allows any external application to communicate with your WordPress site to validate, activate, and deactivate licenses.

  • Authentication: All API requests must include your API key in a header: X-API-Key: YOUR_API_KEY. You can generate API keys in the plugin's settings.

  • Base URL: https://yoursite.com/wp-json/cloudsecure/v1/

Endpoints:

  1. Validate License

    • Endpoint: POST /validate-license

    • Description: Checks if a license key is valid for a given product, has not expired, and has available activations.

    • Body Parameters: product_slug (string), license_key (string), machine_id (string, optional).

  2. Activate License

    • Endpoint: POST /activate-license

    • Description: Activates a license for a specific machine, decrementing the available activation count.

    • Body Parameters: product_slug (string), license_key (string), machine_id (string, required).

  3. Deactivate License

    • Endpoint: POST /deactivate-license

    • Description: Deactivates a license from a specific machine, incrementing the available activation count.

    • Body Parameters: product_slug (string), license_key (string), machine_id (string, required).

cURL Example (Activate License):

BASH
curl -X POST https://yoursite.com/wp-json/cloudsecure/v1/activate-license \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "product_slug": "my-awesome-plugin", "license_key": "CSD-XXXX-XXXX-XXXX", "machine_id": "UNIQUE-MACHINE-IDENTIFIER" }'

PHP Integration for Plugin/Theme Devs

If you are developing a WordPress plugin or theme, you can use this helper method for easy, secure license validation.

PHP
function my_plugin_check_license() { // Check if CloudSecure Downloads Pro is active if ( ! class_exists( 'CloudSecure_Downloads' ) ) { // Handle case where licensing plugin is not active return; } $product_slug = 'my-awesome-plugin'; $license_key = get_option( 'my_plugin_license_key' ); // Get key from user's options $result = CloudSecure_Downloads::instance()->check_developer_license( $product_slug, $license_key ); if ( ! $result['valid'] ) { // License is invalid, show a notice or disable features add_action( 'admin_notices', function() use ( $result ) { echo '

Your license for My Awesome Plugin is invalid. Reason: ' . esc_html( $result['message'] ) . '

'; }); } } add_action( 'admin_init', 'my_plugin_check_license' );

Frequently Asked Questions (FAQ)

Q: My R2 Connection test is failing. What should I do?
A: 99% of the time, this is due to a typo. Carefully re-copy your Access Key ID, Secret Access Key, and Account ID from Cloudflare. Ensure there are no leading or trailing spaces.

Q: Can I use a private R2 bucket?
A: Yes, absolutely. The plugin uses your secure API credentials to generate temporary signed URLs, so your bucket does not need to be public. A private bucket is the recommended setup for maximum security.

Q: Why don't my download links show up on the Thank You page?
A: WooCommerce only grants download permissions when an order is marked as "Completed". If you are using a payment gateway that holds orders in "Processing," the links will not appear until the order is manually or automatically completed.

cart