-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from newfold-labs/solutions
Solutions
- Loading branch information
Showing
8 changed files
with
176 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
namespace NewfoldLabs\WP\Module\PLS\Utilities; | ||
|
||
use NewfoldLabs\WP\Module\Data\HiiveConnection; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
namespace NewfoldLabs\WP\Module\PLS\WPCLI\Handlers; | ||
|
||
use NewfoldLabs\WP\Module\PLS\Utilities\PLSUtility; | ||
use WP_CLI; | ||
|
||
/** | ||
* Class PLSCommandHandler | ||
* | ||
* Handles WP-CLI custom commands for the PLS module, including provisioning | ||
*/ | ||
class PLSCommandHandler { | ||
|
||
/** | ||
* Provisions a new license for the given plugin. | ||
* | ||
* ## OPTIONS | ||
* | ||
* <plugin_slug> | ||
* : The slug of the plugin for which to provision the license. | ||
* | ||
* ## EXAMPLES | ||
* | ||
* wp pls provision <plugin_slug> | ||
* | ||
* @param array $args Positional arguments, where the first element is the plugin slug. | ||
* @return void | ||
*/ | ||
public function provision( $args ) { | ||
$plugin_slug = $args[0]; | ||
|
||
$result = PLSUtility::provision_license( $plugin_slug ); | ||
|
||
if ( is_wp_error( $result ) ) { | ||
WP_CLI::error( $result->get_error_message() ); | ||
} else { | ||
WP_CLI::success( 'License provisioned: ' . wp_json_encode( $result ) ); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves the current license status for the given plugin. | ||
* | ||
* ## OPTIONS | ||
* | ||
* <plugin_slug> | ||
* : The slug of the plugin for which to retrieve the license status. | ||
* | ||
* ## EXAMPLES | ||
* | ||
* wp pls status <plugin_slug> | ||
* | ||
* @param array $args Positional arguments, where the first element is the plugin slug. | ||
* @return void | ||
*/ | ||
public function status( $args ) { | ||
$plugin_slug = $args[0]; | ||
|
||
$result = PLSUtility::retrieve_license_status( $plugin_slug ); | ||
|
||
if ( is_wp_error( $result ) ) { | ||
WP_CLI::error( $result->get_error_message() ); | ||
} else { | ||
WP_CLI::success( "License status: $result" ); | ||
} | ||
} | ||
|
||
/** | ||
* Activates a license for the given plugin. | ||
* | ||
* ## OPTIONS | ||
* | ||
* <plugin_slug> | ||
* : The slug of the plugin for which to activate the license. | ||
* | ||
* ## EXAMPLES | ||
* | ||
* wp pls activate <plugin_slug> | ||
* | ||
* @param array $args Positional arguments, where the first element is the plugin slug. | ||
* @return void | ||
*/ | ||
public function activate( $args ) { | ||
$plugin_slug = $args[0]; | ||
|
||
$result = PLSUtility::activate_license( $plugin_slug ); | ||
|
||
if ( is_wp_error( $result ) ) { | ||
WP_CLI::error( $result->get_error_message() ); | ||
} else { | ||
WP_CLI::success( 'License activated: ' . wp_json_encode( $result ) ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace NewfoldLabs\WP\Module\PLS\WPCLI; | ||
|
||
use NewfoldLabs\WP\Module\PLS\WPCLI\Handlers\PLSCommandHandler; | ||
use WP_CLI; | ||
|
||
/** | ||
* Class WPCLI | ||
* | ||
* Handles registering WP-CLI commands for the PLS module. | ||
*/ | ||
class WPCLI { | ||
/** | ||
* Constructor for WPCLI class. | ||
*/ | ||
public function __construct() { | ||
if ( defined( 'WP_CLI' ) && WP_CLI ) { | ||
WP_CLI::add_command( 'pls', PLSCommandHandler::class ); | ||
} | ||
} | ||
} |