afragen / wp-dependency-installer

A lightweight class to add to WordPress plugins/themes to automatically install plugin dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New way to start and register configs

afragen opened this issue · comments

@Raruto I have an idea. Coding through it now. PR to follow to check logic etc.

It would enable the following.

// Load config from JSON file.
WP_Dependency_Installer::instance()->run( __DIR__ );

// Load config as array.
WP_Dependency_Installer::instance()->run( __DIR__, $config );

No need to call register().

Yes, this is slightly breaking.

No need to call register().

This is the main reason why I think it's still better to keep them separate:

// Register multiple configs.
WP_Dependency_Installer::instance()->register( $config1, __DIR__ );
WP_Dependency_Installer::instance()->register( $config2, __DIR__ );
WP_Dependency_Installer::instance()->register( $config3, __DIR__ );

// Run installer once.
WP_Dependency_Installer::instance()->run( __DIR__ );

In this way, I think, you can add much more complex logic without forcing to execute the run / load_hooks functions

Yes, this is slightly breaking.

BTW, didn't we already code it? #44 #45

I'm resurrecting this with a separate function to register the JSON file.

I'm resurrecting this with a separate function to register the JSON file.

Ok, but now i really need a bed...