Closed mcguffin closed 8 months ago
This is super interesting and definitively and oversight on my part (had no idea it worked like that, but also makes perfect sense)!
Luckily it's an easy fix because I believe I can detect the plugin is network activated... let me work on a fix for that!
I've created a PR (#171) I would love to hear your thoughts about the revised approach!
Apologies for my non-responsiveness ... years' end is a mess in IT-land.
On a different system (Multisite, network-active, WP_SENTRY_VERSION
not defined) I'm getting a fatal:
Fatal error: Uncaught Error: Call to undefined function is_plugin_active_for_network() in <REDACTED>/httpdocs/wp-content/plugins/wp-sentry-integration/wp-sentry.php:86
After poking around a bit, I think that this one should do it:
if ( ! defined( 'WP_SENTRY_VERSION' ) && function_exists( 'did_action' ) ) {
if ( did_action( 'muplugins_loaded' ) && function_exists( 'wp_get_theme' ) ) {
// regular plugin activation
define( 'WP_SENTRY_VERSION', wp_get_theme()->get( 'Version' ) ?: 'unknown' );
} else {
// must-use or network activation – WP's theme directories are not yet set,
define( 'WP_SENTRY_VERSION', 'unknown' );
}
}
What do you think?
No worries, life is life, also what a mess is WordPress and networks 😅
I'll check it out and make a new release later today!
Fixed with df3cb4e793eba78cc5da1cfc39f7254375c3a364, think a function_exists
should be fine for now 👍
Thanks for reporting and for checking out the fix and reporting it was broken again 😅
Hi Alex,
First a big thank you for your plugin. It is a really big help in many projects.
I stumbled upon a weird issue with a child theme on a multisite. Steps to reproduce:
After some poking around I found these lines to be the culprit: https://github.com/stayallive/wp-sentry/blob/db27d2ab059f6ce5b5ec931a67257adabcbe83ab/wp-sentry.php#L82-L84 (Okay – the main culprit is me being too lazy to set a constant.)
Network activated plugins are included before WP is registering the theme directory. If
wp_get_theme()
is called for the first time, it will scan the (yet unknown) theme directory and cache the (empty) result for later use.