Fixing that did seem to get it to no longer kill WP CLI, however there are still other issues with paths causing fatals.
this -> $plugin_meta seems to be getting referenced in places it’s not actually available.
Anyway, I refactored all the path references.
https://github.com/jb510/wp-comment-fields
Also note:
config.php:10 reads
$plugin_dir = 'wp-comment-fields';
It is generally considered bad practice to hard code slugs, as people can and will change a plugins folder/slug. The preferred method is:
$plugin_dir = plugin_basename( __DIR__ );
ref: https://developer.wordpress.org/reference/functions/plugin_basename/
Personally I don’t set it to a var, I use a get_ function to retrieve it as needed.
As for the initial problem though while I presume the the file exists check and die was intended for nice error reporting, I really think it’d be better to just use require_once() and then allow that to report to the logs what file doesn’t exist.
If you really do want use include_once + die(), you could still use wp_die() and get a bit better info output, but again seems redundant to just using require. https://developer.wordpress.org/reference/functions/wp_die/
-
This reply was modified 2 years, 12 months ago by Jon Brown.
Hi Jon,
Thanks for this, we will update our plugin and release with new version 🙂
Hi,
we just updated our plugin with your suggestion and now updated to version 2.0