Closed ocean90 closed 2 years ago
@stayallive Do you have any thoughts on this idea? Is there something I can help to move this forward?
@ocean90, I have been thinking about this one and slightly modified this PR into #106.
WDYT?
Implemented in #106, thanks for kicking this off and doing the research!
The readme already mentions that you can load the plugin file with a must-use plugin to catch more errors. I'd like to go a step further and load the plugin file as part of
wp-config.php
to also catch errors during the WordPress bootstrap process.Loading the plugin that early means that some WordPress functions may not exist yet. Luckily, the plugin doesn't depend on so many functions and each used function can be adjusted to make it work.
The simplified code for
wp-config.php
may look like this:We first have to require the WordPress plugin API to make functions like
add_action()
available. That's not a big deal and fully supported by WordPress, see here and here).For the plugin itself we only have to make sure that two functions exist:
is_admin()
andget_bloginfo()
.is_admin()
I added a simplefunction_exists()
check in https://github.com/stayallive/wp-sentry/commit/1829c45acd50250f57fa8964e793bcecdc65e131.get_bloginfo( 'version' )
can (and should) be replaced with using the version fromversion.php
. This makes sure we use an unmodified WordPress version which is always available. Done in https://github.com/stayallive/wp-sentry/commit/2b00f96fc4f39e05023c2dd9c0dadc1774cac9d8.get_bloginfo( 'language' )
so I used afunction_exist()
check in https://github.com/stayallive/wp-sentry/commit/b370b8d66a92f762e3eee45acea243fd20bc44a0 too.I'm aware that this is some advanced usage but since the changes are minimal I thought I submit this PR anyway. Let me know what you think!