Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"prefer-stable": true,
"require": {
"php": ">=5.6",
"afragen/wp-dismiss-notice": "*"
"afragen/wp-dismiss-notice": "*",
"ext-json": "*"
},
"support": {
"issues": "https://github.com/afragen/wp-dependency-installer/issues",
Expand Down
17 changes: 15 additions & 2 deletions wp-dependency-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
* Class WP_Dependency_Installer
*/
class WP_Dependency_Installer {

/**
* Config files to take into account.
*
* @var string[]
*/
public static $config_files = ['wp-dependencies.json'];

/**
* Holds the JSON file contents.
*
Expand Down Expand Up @@ -116,7 +124,7 @@ function( $notices, $slug ) {

/**
* Let's get going.
* First load data from wp-dependencies.json if present.
* First load data from config files if present.
* Then load hooks needed to run.
*
* @param string $caller Path to plugin or theme calling the framework.
Expand All @@ -125,7 +133,12 @@ function( $notices, $slug ) {
*/
public function run( $caller = false ) {
$caller = ! $caller ? self::$caller : $caller;
$config = $this->json_file_decode( $caller . '/wp-dependencies.json' );

$config = [];
foreach ( self::$config_files as $file ) {
$config = array_merge( $config, $this->json_file_decode( $caller . '/' . $file ) ?: [] );
}

if ( ! empty( $config ) ) {
$this->register( $config, $caller );
}
Expand Down