Skip to content

Commit

Permalink
simplify control structures
Browse files Browse the repository at this point in the history
* extract common parts from if-else branches
* convert redundante elseif to else
  • Loading branch information
stklcode committed Mar 24, 2024
1 parent c88d716 commit 9903a61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions inc/class-statifyblacklist-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @since 1.7.0
*/

// Quit if accessed directly..
// Quit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
Expand Down Expand Up @@ -575,14 +575,13 @@ private static function sanitize_referer_options( &$options ) {
* @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;

Expand Down
2 changes: 1 addition & 1 deletion inc/class-statifyblacklist-system.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function upgrade() {
);
} 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'] );
}
Expand Down

0 comments on commit 9903a61

Please sign in to comment.