Closed seothemes closed 5 years ago
Is it really that much trouble to create an extra JSON file. Also, if there’s an error in the composer.json that doesn’t parse of something I’m not able to tell the user how to fix it.
From my (the developer) standpoint having one file that does one thing is simpler and safer.
I agree - the main reason I wanted to remove the wp-dependencies.json file was to keep it out of sight of customers. I was trying to make a child theme as minimal as possible and stick to just style.css, functions.php and screenshot.png. The vendor directory is hidden in the WordPress admin so that's not an issue.
I found a better solution by using the register()
method, and to avoid requiring a plugin path I called load_hooks()
first, instead of run()
:
$config = apply_filters( 'prefix_plugin_dependencies', [
[
'name' => 'One Click Demo Import',
'host' => 'wordpress',
'slug' => 'one-click-demo-import/one-click-demo-import.php',
'uri' => 'https://wordpress.org/plugins/one-click-demo-import/',
'optional' => false,
],
] );
// Install and active dependencies.
\WP_Dependency_Installer::instance()->load_hooks();
\WP_Dependency_Installer::instance()->register( $config );
I’m so sorry I didn’t understand what you were trying to accomplish. We could’ve found the solution a lot quicker.
I built that functionality in just in case and haven’t really thought about it as I always use a wp-dependencies.json
file.
I’m glad you found a solution.
It would be nice to have the option to place the config inside
composer.json
instead of a separate file. I was thinking it could go under the extra property. Something like this:If no
wp-dependencies.json
file is found, then check for the config incomposer.json
.