diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..66e7712 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,50 @@ +version: 2 +updates: + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + target-branch: "main" + allow: + - dependency-type: direct + schedule: + interval: "daily" + commit-message: + prefix: "GitHub Actions" + include: "scope" + labels: + - "dependencies" + + # Maintain dependencies for npm + - package-ecosystem: "npm" + directory: "/" + target-branch: "main" + allow: + - dependency-type: direct + schedule: + interval: "daily" + versioning-strategy: increase + commit-message: + prefix: "NPM" + prefix-development: "NPM Dev" + include: "scope" + labels: + - "dependencies" + - "javascript" + + # Maintain dependencies for Composer + - package-ecosystem: "composer" + directory: "/" + target-branch: "main" + schedule: + interval: "daily" + allow: + - dependency-type: direct + versioning-strategy: increase + commit-message: + prefix: "Composer" + prefix-development: "Composer Dev" + include: "scope" + labels: + - "dependencies" + - "php" \ No newline at end of file diff --git a/includes/Migration.php b/includes/Migration.php index a5b5729..8625dbf 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -17,6 +17,8 @@ class Migration { protected $container; /** + * To create insta service instance + * * @var insta_service */ protected $insta_service; @@ -30,6 +32,11 @@ class Migration { 'NewfoldLabs\\WP\\Module\\Migration\\RestApi\\MigrateController', ); + /** + * Migration constructor. + * + * @param Container $container Container loaded from the brand plugin. + */ public function __construct( Container $container ) { $this->container = $container; $this->insta_service = new InstaMigrateService(); diff --git a/includes/RestApi/MigrateController.php b/includes/RestApi/MigrateController.php index 5312cdd..bb59c07 100644 --- a/includes/RestApi/MigrateController.php +++ b/includes/RestApi/MigrateController.php @@ -4,14 +4,30 @@ use NewfoldLabs\WP\Module\Migration\Services\InstaMigrateService; - +/** + * Class MigrateController + */ class MigrateController { - + /** + * REST namespace + * + * @var string + */ protected $namespace = 'newfold-migration/v1'; + /** + * REST base + * + * @var string + */ protected $rest_base = '/migrate'; + /** + * Registers rest routes for MigrateController. + * + * @return void + */ public function register_routes() { register_rest_route( $this->namespace, @@ -20,12 +36,17 @@ public function register_routes() { array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array( $this, 'connectInstawp' ), - 'permission_callback' => array($this, 'rest_is_authorized_admin') + 'permission_callback' => array( $this, 'rest_is_authorized_admin' ), ), ) ); } + /** + * Initiates the connnection with instawp plugin + * + * @return array + */ public function connectInstawp() { $instaService = new InstaMigrateService(); $response = $instaService->InstallInstaWpConnect(); @@ -33,9 +54,13 @@ public function connectInstawp() { return $response; } - public static function rest_is_authorized_admin() - { + /** + * Confirm REST API caller has ADMIN user capabilities. + * + * @return boolean + */ + public static function rest_is_authorized_admin() { $admin = 'manage_options'; - return \is_user_logged_in() && \current_user_can($admin); + return \is_user_logged_in() && \current_user_can( $admin ); } } diff --git a/includes/Services/InstaMigrateService.php b/includes/Services/InstaMigrateService.php index edcdc55..ce8b750 100644 --- a/includes/Services/InstaMigrateService.php +++ b/includes/Services/InstaMigrateService.php @@ -5,7 +5,7 @@ use InstaWP\Connect\Helpers\Installer; /** - * InstaWP migrate service + * Class InstaMigrateService */ class InstaMigrateService { @@ -17,7 +17,7 @@ class InstaMigrateService { private $connect_plugin_slug = 'instawp-connect'; /** - * Set required api keys for insta to start the migration + * Set required api keys for insta to initiate the migration */ function __construct() { Helper::set_api_domain( INSTAWP_API_DOMAIN );