simplify control structures

* extract common parts from if-else branches
* convert redundante elseif to else
This commit is contained in:
Stefan Kalscheuer 2024-03-24 17:39:25 +01:00
parent c88d716dfc
commit 9903a6163d
Signed by: stefan
GPG Key ID: 3887EC2A53B55430
2 changed files with 5 additions and 6 deletions

View File

@ -8,7 +8,7 @@
* @since 1.7.0
*/
// Quit if accessed directly..
// Quit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
@ -575,14 +575,13 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
* @since 1.7.0
*/
private static function sanitize_target_options( &$options ) {
$target_given = $options['blacklist'];
$target_invalid = array();
$target_given = $options['blacklist'];
$target_sanitized = $target_given;
if ( StatifyBlacklist::MODE_REGEX === $options['regexp'] || StatifyBlacklist::MODE_REGEX_CI === $options['regexp'] ) {
$target_sanitized = $target_given;
// Check regular expressions.
$target_invalid = self::sanitize_regex( $target_given );
} else {
$target_sanitized = $target_given;
$target_invalid = array();
}
$options['blacklist'] = $target_sanitized;

View File

@ -186,7 +186,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
);
} elseif ( ! isset( $options['ua']['blacklist'] ) ) {
$options['ua']['blacklist'] = array();
} elseif ( isset( $options['ua'] ) ) {
} else {
// User agent strings got stored incorrectly in 1.6.0 - luckily the version was not updated, either.
$options['ua']['blacklist'] = array_flip( $options['ua']['blacklist'] );
}