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:
parent
c2ad908481
commit
5956059327
@ -52,7 +52,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update database on success.
|
// Update database on success.
|
||||||
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
if ( self::$multisite ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
||||||
} else {
|
} else {
|
||||||
update_option( 'statify-blacklist', $options );
|
update_option( 'statify-blacklist', $options );
|
||||||
|
@ -132,7 +132,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
// Flip referer array to make domains keys.
|
// Flip referer array to make domains keys.
|
||||||
$options = self::$_options;
|
$options = self::$_options;
|
||||||
$options['referer'] = array_flip( self::$_options['referer'] );
|
$options['referer'] = array_flip( self::$_options['referer'] );
|
||||||
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
if ( self::$multisite ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
||||||
} else {
|
} else {
|
||||||
update_option( 'statify-blacklist', $options );
|
update_option( 'statify-blacklist', $options );
|
||||||
@ -161,7 +161,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
),
|
),
|
||||||
'version' => 1.4,
|
'version' => 1.4,
|
||||||
);
|
);
|
||||||
if ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) {
|
if ( self::$multisite ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
||||||
} else {
|
} else {
|
||||||
update_option( 'statify-blacklist', $options );
|
update_option( 'statify-blacklist', $options );
|
||||||
@ -174,7 +174,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
// Merge default options with current config, assuming only additive changes.
|
// Merge default options with current config, assuming only additive changes.
|
||||||
$options = array_merge_recursive( self::default_options(), self::$_options );
|
$options = array_merge_recursive( self::default_options(), self::$_options );
|
||||||
$options['version'] = self::VERSION_MAIN;
|
$options['version'] = self::VERSION_MAIN;
|
||||||
if ( ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) ) ) {
|
if ( self::$multisite ) {
|
||||||
update_site_option( 'statify-blacklist', $options );
|
update_site_option( 'statify-blacklist', $options );
|
||||||
} else {
|
} else {
|
||||||
update_option( 'statify-blacklist', $options );
|
update_option( 'statify-blacklist', $options );
|
||||||
|
@ -73,12 +73,12 @@ class StatifyBlacklist {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin options.
|
|
||||||
self::update_options();
|
|
||||||
|
|
||||||
// Get multisite status.
|
// Get multisite status.
|
||||||
self::$multisite = ( is_multisite() && array_key_exists( STATIFYBLACKLIST_BASE, (array) get_site_option( 'active_sitewide_plugins' ) ) );
|
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.
|
// Add Filter to statify hook if enabled.
|
||||||
if ( 0 !== self::$_options['referer']['active'] || 0 !== self::$_options['target']['active'] || 0 !== self::$_options['ip']['active'] ) {
|
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' ) );
|
add_filter( 'statify__skip_tracking', array( 'StatifyBlacklist', 'apply_blacklist_filter' ) );
|
||||||
@ -127,10 +127,12 @@ class StatifyBlacklist {
|
|||||||
* @param array $options Optional. New options to save.
|
* @param array $options Optional. New options to save.
|
||||||
*/
|
*/
|
||||||
public static function update_options( $options = null ) {
|
public static function update_options( $options = null ) {
|
||||||
self::$_options = wp_parse_args(
|
if ( self::$multisite ) {
|
||||||
get_option( 'statify-blacklist' ),
|
$o = get_site_option( 'statify-blacklist' );
|
||||||
self::default_options()
|
} else {
|
||||||
);
|
$o = get_option( 'statify-blacklist' );
|
||||||
|
}
|
||||||
|
self::$_options = wp_parse_args( $o, self::default_options() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user