diff --git a/inc/class-statifyblacklist-admin.php b/inc/class-statifyblacklist-admin.php index ef1b6b6..e807ef9 100644 --- a/inc/class-statifyblacklist-admin.php +++ b/inc/class-statifyblacklist-admin.php @@ -52,7 +52,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { } // 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 ); } else { update_option( 'statify-blacklist', $options ); diff --git a/inc/class-statifyblacklist-system.php b/inc/class-statifyblacklist-system.php index cb1e20b..a9160b1 100644 --- a/inc/class-statifyblacklist-system.php +++ b/inc/class-statifyblacklist-system.php @@ -132,7 +132,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { // Flip referer array to make domains keys. $options = self::$_options; $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 ); } else { update_option( 'statify-blacklist', $options ); @@ -161,7 +161,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { ), '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 ); } else { update_option( 'statify-blacklist', $options ); @@ -174,7 +174,7 @@ class StatifyBlacklist_System extends StatifyBlacklist { // Merge default options with current config, assuming only additive changes. $options = array_merge_recursive( self::default_options(), self::$_options ); $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 ); } else { update_option( 'statify-blacklist', $options ); diff --git a/inc/class-statifyblacklist.php b/inc/class-statifyblacklist.php index cb14cfa..319752f 100644 --- a/inc/class-statifyblacklist.php +++ b/inc/class-statifyblacklist.php @@ -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() ); } /**