Skip to content
Andy Fragen edited this page Nov 20, 2021 · 10 revisions

The following is a small list of useful functions that other third-party developers can use to follow their best installation strategy:

Dependency Installer.

$wpdi = WP_Dependency_Installer::instance( __DIR__ );

Dependencies status.

$wpdi->is_installed( "git-updater/git-updater.php" );
$wpdi->is_active( "git-updater/git-updater.php" );
$wpdi->is_required( "git-updater/git-updater.php" );
$wpdi->is_required( [
  "name"     => "Git Updater",
  "host"     => "github",
  "slug"     => "git-updater/git-updater.php",
  "uri"      => "afragen/git-updater",
  "branch"   => "develop",
  "required" => true, // To be required,
  "optional" => true, // or not to be required, what is the answer? 😨 
  "token"    => null
] );

Dependencies config.

$wpdi->get_config( );                                             // retrieve all registered / running configs.
$wpdi->get_config( "git-updater/git-updater.php" );         // retrieve registered plugin configuration array.
$wpdi->get_config( "git-updater/git-updater.php", 'name' ); // retrieve specific plugin configs.
$wpdi->get_config( "git-updater/git-updater.php", 'host' );
$wpdi->get_config( "git-updater/git-updater.php", 'token' );

Custom dependencies.

$wpdi->install( "git-updater/git-updater.php" );
$wpdi->active( "git-updater/git-updater.php" );

For more information refer to the source code