Automattic / Automattic/newspack-migration-tools

Need Dependency Validator Util

Open
#136 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
20
Forks
5
PR merge metrics
No merged PRs in 30d

Description

It would be cool to create a util that can be re-used to "validate helper dependencies". For helpers that need to check if a plugin is installed or not, it would be cool to have a standard approach to this.

```
class DependencyValidator {

static function our_normal_plugin_checker( $plugin_name ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

if ( ! is_plugin_active( $plugin_name ) ) {
return new WP_Error( 'ERROR_PLUGIN_MISSING', 'Plugin not found. Install and activate it before using this function.' );
}
}

static function validate_co_authors_plus() { ... }
static function validate_newspack_guest_contributors() { ... }
}
```

The current code for all this is spread out in the different helpers ( [example](https://github.com/Automattic/newspack-migration-tools/pull/130), [example](https://github.com/Automattic/newspack-migration-tools/blob/42a9f29772e3b564f8bf54746318e576cdfb46dd/src/Logic/GuestContributorsHelper.php#L278) ) , but we should put this into a sharable Util so different helpers that need the same plugin can just call the shared validator.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/Logic/GuestContributorsHelper.php around the dependency-checking code referenced in the issue, and compare it with the examples in pull request 130. Identify the repeated plugin validation used by the helpers; done means a shared validator exists and the relevant helpers can reuse it consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.