コンテンツにスキップ

Walkthrough: DIY Free Licensing & Updates

Overview

We have implemented a Client-Side DIY System. 1. License Manager: Connects to your WooCommerce store to validate keys. 2. Update Checker: Checks your store's custom API (/wp-json/my-shop/v1/update-check) for new versions.

Verification Steps (Plugin Side)

1. License Settings

  1. Go to Cross Poster > Settings > License.
  2. Enter Mock Key: TEST-VALID-KEY.
  3. Verify Status becomes Active.

2. Update Checker (Verification Requires Server Mock)

Since we don't have the server implementation yet, verification involves checking the code logic: 1. Open includes/class-update-checker.php. 2. Observe it sends a request to https://your-store-url.com/wp-json/my-shop/v1/update-check. 3. To Test: Modify store_url in class-pro-core.php to a mock service (like Postman Mock Server) that returns: json { "new_version": "9.9.9", "package": "https://example.com/test.zip", "url": "https://example.com/info", "sections": { "description": "Update Test" } } 4. Go to Dashboard > Updates. 5. Click "Check Again". 6. You should see an update available for "Cross Poster Pro".

Server-Side Setup (Required on Your Store)

To make this work in production, you must implement the API on your WooCommerce site.

Example functions.php code for your store:

add_action( 'rest_api_init', function () {
  register_rest_route( 'my-shop/v1', '/update-check', array(
    'methods' => 'GET',
    'callback' => 'my_custom_update_check',
    'permission_callback' => '__return_true',
  ) );
} );

function my_custom_update_check( $request ) {
  $license_key = $request->get_param( 'license_key' );
  // 1. Validate License Key with License Manager logic...
  // 2. If valid, return update info:
  return array(
    'new_version' => '1.1.0',
    'package' => 'https://yoursite.com/files/cross-poster-pro-1.1.0.zip',
    'url'     => 'https://yoursite.com/product/cross-poster-pro',
     // ...
  );
}