PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / admin / store-license.php

store-license.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.13.0, at includes/admin/store-license.php

109 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * StoreEngine License Management Client SDK bootstrap for aBlocks (free).
4 *
5 * aBlocks (free) OWNS the shared, version-managed SDK — it is the Composer
6 * package `storeengine/wordpress-sdk`, loaded via `vendor/autoload.php` in
7 * `ABlocks::load_dependency()`. Here we simply register the free product so the
8 * SDK provides:
9 *
10 * - The deactivation-reason popup + anonymous opt-in (`init_insights`). This
11 * replaces aBlocks' previous homegrown Insights dialog (includes/admin/insights.php).
12 *
13 * `use_update` is intentionally OFF: aBlocks (free) is distributed through
14 * wp.org, so the SDK is used here only for uninstall-tracking/analytics, not to
15 * serve updates. aBlocks Pro reuses this same SDK for its own license + updater.
16 *
17 * @package ABlocks
18 */
19
20 namespace ABlocks\Admin;
21
22 use SE_License_SDK_Client;
23
24 if ( ! defined( 'ABSPATH' ) ) {
25 exit;
26 }
27
28 class StoreLicense {
29
30 /**
31 * aBlocks (free) product ID on https://store.kodezen.com/.
32 */
33 const PRODUCT_ID = 331;
34
35 protected static ?SE_License_SDK_Client $sdk_client = null;
36
37 public static function init(): void {
38 if ( ! did_action( 'plugins_loaded' ) ) {
39 add_action( 'plugins_loaded', [ __CLASS__, 'load_sdk' ] );
40 } else {
41 self::load_sdk();
42 }
43 }
44
45 public static function load_sdk(): void {
46 if ( null !== self::$sdk_client ) {
47 return;
48 }
49
50 // The shared SDK is loaded by aBlocks (free) itself via load_dependency().
51 // Bail quietly if it is somehow unavailable rather than fataling.
52 if ( ! function_exists( 'se_license_init' ) ) {
53 return;
54 }
55
56 // The SDK requires a valid product ID to construct its client (it fatals
57 // otherwise). Guard against a misconfigured/empty ID so the site never
58 // white-screens.
59 if ( self::PRODUCT_ID <= 0 ) {
60 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
61 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
62 error_log( 'ABlocks: StoreEngine SDK not initialised — set StoreLicense::PRODUCT_ID to the free aBlocks product ID.' );
63 }
64 return;
65 }
66
67 $first_install = get_option( 'ablocks_first_install_time' );
68 if ( ! $first_install ) {
69 $first_install = time();
70 add_option( 'ablocks_first_install_time', $first_install, '', false );
71 }
72
73 self::$sdk_client = se_license_init( [
74 'package_file' => ABLOCKS_ROOT_DIR_PATH . 'ablocks.php',
75 'package_name' => 'aBlocks',
76 'product_id' => self::PRODUCT_ID,
77 'is_free' => true,
78 // wp.org-distributed: SDK is used only for insights/opt-in here, not
79 // as an update channel. Flip to true only if free aBlocks is deployed
80 // through the StoreEngine store instead of wp.org.
81 'use_update' => false,
82 'slug' => ABLOCKS_PLUGIN_SLUG,
83 'basename' => ABLOCKS_PLUGIN_BASENAME,
84 'package_type' => 'plugin',
85 'package_version' => ABLOCKS_VERSION,
86 // Keep local activation allowed so the deactivation popup + opt-in are
87 // not suppressed on local/dev sites (is_local_request() short-circuits
88 // to false when allow_local is true).
89 'allow_local' => true,
90 'init_insights' => true,
91 'license_server' => 'https://store.kodezen.com/',
92 'purchase_url' => 'https://store.kodezen.com/product/ablocks-pro/',
93 'product_logo' => defined( 'ABLOCKS_ASSETS_URL' ) ? ABLOCKS_ASSETS_URL . 'images/logo-shape.svg' : '',
94 'store_dashboard_url' => 'https://store.kodezen.com/dashboard/license-keys/',
95 'terms_url' => 'https://kodezen.com/terms-and-conditions/',
96 'privacy_policy_url' => 'https://store.kodezen.com/privacy-policy/',
97 'support_url' => 'https://community.kodezen.com/tickets',
98 'ticket_recipient' => 'support@kodezen.com',
99 'primary_color' => '#13191B',
100 'first_install_time' => $first_install,
101 'optin_notice_delay' => 3 * DAY_IN_SECONDS,
102 ] );
103 }
104
105 public static function get_client(): ?SE_License_SDK_Client {
106 return self::$sdk_client;
107 }
108 }
109