Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/blocksy-companion-pro/framework/cli/license.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + namespace Blocksy;
4 +
5 + /**
6 + * Manages Blocksy theme license.
7 + *
8 + * ## EXAMPLES
9 + *
10 + * # Activate license
11 + * $ wp blocksy license activate your-license-key
12 + */
13 + class LicenseCli {
14 + public function __construct() {
15 + \WP_CLI::add_command('blocksy license', $this);
16 + }
17 +
18 + /**
19 + * Activate a license key.
20 + *
21 + * ## OPTIONS
22 + *
23 + * <key>
24 + * : The license key to activate.
25 + *
26 + * ## EXAMPLES
27 + *
28 + * wp blocksy license activate your-license-key
29 + *
30 + * @subcommand activate
31 + */
32 + public function license_activate($args, $assoc_args) {
33 + $fs = blc_fs();
34 +
35 + if (empty($fs)) {
36 + \WP_CLI::error('Freemius instance not found.');
37 + return;
38 + }
39 +
40 + if (false === $fs->has_api_connectivity()) {
41 + \WP_CLI::error('No API connectivity.');
42 + return;
43 + }
44 +
45 + if ($fs->is_registered()) {
46 + \WP_CLI::warning('The user is already registered with Freemius.');
47 + }
48 +
49 + $key = $args[0];
50 +
51 + try {
52 + $next_page = $fs->activate_migrated_license($key);
53 + } catch (Exception $e) {
54 + \WP_CLI::error('Error: ' . $e->getMessage());
55 + return;
56 + }
57 +
58 + if ($fs->can_use_premium_code()) {
59 + \WP_CLI::success('License key activated successfully.');
60 + } else {
61 + \WP_CLI::error('License key activation failed.');
62 + }
63 + }
64 + }
65 +