Cleaned up option handling for multisite

Multisite detection has been executed multiple times while the status is present in class variable after initialization.
This commit is contained in:
2018-01-07 16:17:27 +01:00
parent c2ad908481
commit 5956059327
3 changed files with 13 additions and 11 deletions

View File

@ -73,12 +73,12 @@ class StatifyBlacklist {
return;
}
// Plugin options.
self::update_options();
// Get multisite status.
self::$multisite = ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) );
// Plugin options.
self::update_options();
// Add Filter to statify hook if enabled.
if ( 0 !== self::$_options['referer']['active'] || 0 !== self::$_options['target']['active'] || 0 !== self::$_options['ip']['active'] ) {
add_filter( 'statify__skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
@ -127,10 +127,12 @@ class StatifyBlacklist {
* @param array $options Optional. New options to save.
*/
public static function update_options( $options = null ) {
self::$_options = wp_parse_args(
get_option( 'statify-blacklist' ),
self::default_options()
);
if ( self::$multisite ) {
$o = get_site_option( 'statify-blacklist' );
} else {
$o = get_option( 'statify-blacklist' );
}
self::$_options = wp_parse_args( $o, self::default_options() );
}
/**