Skip to content

Commit

Permalink
linting / wpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed Jan 26, 2024
1 parent 7f75b43 commit fb010f3
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 41 deletions.
5 changes: 2 additions & 3 deletions admin/CF7_AntiSpam_Admin_Customizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,9 +1050,9 @@ private function cf7a_clean_recursive( $json_data ) {
public function cf7a_sanitize_options( $input ) {
/* get the import options */
$new_input = $this->options;
$import_data = isset( $_POST['to-import'] ) ? $_POST['to-import'] : false;
$import_data = isset( $_POST['to-import'] ) ? sanitize_text_field( $_POST['to-import'] ) : false;
if ( ! empty( $import_data ) ) {
$json_data = json_decode( wp_unslash( $_POST['to-import'] ) );
$json_data = json_decode( wp_unslash( $import_data ) );
$input = $this->cf7a_clean_recursive( $json_data );
// monkey pathing arrays that needs to be imploded
$input['bad_ip_list'] = implode( ',', $input['bad_ip_list'] );
Expand All @@ -1068,7 +1068,6 @@ public function cf7a_sanitize_options( $input ) {
$input['cf7a_enable'] = 1;
$input['cf7a_version'] = CF7ANTISPAM_VERSION;
}
error_log( print_r( $input, true ) );

$new_input['cf7a_enabled'] = isset( $input['cf7a_enabled'] ) ? 1 : 0;

Expand Down
2 changes: 1 addition & 1 deletion admin/CF7_AntiSpam_Admin_Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private function cf7a_export_options() {
?>
<div id="cf7a_export_import" class="cf7-antispam card">
<h3><?php esc_html_e( 'Export/Import Options', 'cf7-antispam' ); ?></h3>
<form id="import-export-options" method="post" action="<?php echo admin_url( 'options.php' ); ?>">
<form id="import-export-options" method="post" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
<?php
$option_group = 'cf7_antispam_options';
wp_nonce_field( "$option_group-options" );
Expand Down
47 changes: 25 additions & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions core/CF7_AntiSpam_Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ public function cf7a_cron_unban() {
public function cf7a_check_length_exclusive( $el, $n ) {
if ( strlen( $el ) >= 5 ) {
$l = explode( '-', $el );
if ( $n == 0 ) {
if ( 0 == $n ) {
return strtolower( $l[0] );
} elseif ( $n == 1 ) {
} elseif ( 1 == $n ) {
return strtoupper( $l[1] );
}
} elseif ( strlen( $el ) === 2 && ctype_alpha( $el ) ) {
if ( $n == 0 && ctype_lower( $el ) ) {
if ( 0 == $n && ctype_lower( $el ) ) {
return $el;
} elseif ( $n == 1 && ctype_upper( $el ) ) {
} elseif ( 1 == $n && ctype_upper( $el ) ) {
return $el;
}
}
Expand All @@ -270,9 +270,9 @@ public function cf7a_check_length_exclusive( $el, $n ) {
public function cf7a_get_languages_or_locales( $option, $key ) {
$languages = array();
foreach ( $option as $item ) {
if ( $key == 'languages' ) {
if ( 'languages' === $key ) {
$l = $this->cf7a_check_length_exclusive( $item, 0 );
} elseif ( $key == 'locales' ) {
} elseif ( 'locales' === $key ) {
$l = $this->cf7a_check_length_exclusive( $item, 1 );
}
if ( ! empty( $l ) ) {
Expand Down
4 changes: 2 additions & 2 deletions core/CF7_AntiSpam_Flamingo.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public function cf7a_resend_mail( $mail_id ) {
$recipient = $form_props['mail']['recipient'];
if ( $form_props['mail']['recipient'] || ! empty( $flamingo_data->meta['recipient'] ) ) {
if ( ! filter_var( $recipient, FILTER_VALIDATE_EMAIL ) || ! empty( $recipient ) ) {
if ( $recipient === '[_site_admin_email]' ) {
if ( '[_site_admin_email]' === $recipient ) {
$recipient = $flamingo_data->meta['site_admin_email'];
} elseif ( $recipient === '[_post_author]' ) {
} elseif ( '[_post_author]' === $recipient ) {
$recipient = get_option( 'post_author_email' ); // check this, not sure 🤔
} else {
$recipient = get_option( 'admin_email' );
Expand Down
4 changes: 2 additions & 2 deletions core/CF7_AntiSpam_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ function generateHash( $length = 12 ) {

for ( $i = 0; $i < $length; $i++ ) {
// TODO: after upgrade to PHP>7.x, use random_int()
$randIndex = rand( 0, strlen( $characters ) - 1 );
$hash .= $characters[ $randIndex ];
$rand_index = wp_rand( 0, strlen( $characters ) - 1 );
$hash .= $characters[ $rand_index ];
}

return $hash;
Expand Down
10 changes: 5 additions & 5 deletions core/CF7_Antispam_Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ public function load( $action = '' ) {
/**
* The `display` function is used to display information about the Antispam plugin and provide options for
* setup integration.
*
* @param string The "action" parameter is used to determine the specific action to be performed in the
* "display" function. It is a string that can have two possible values:
*/
public function display( $action = '' ) {
echo sprintf(
Expand Down Expand Up @@ -252,9 +249,12 @@ public function display( $action = '' ) {
// Display the form
echo '<div class="wrap">';
echo '<form method="post" action="">';
printf( '<input type="submit" name="cf7a_submit" class="button button-primary" value="%s">', $checked ? __( 'Disable', 'cf7-antispam' ) : __( 'Enable', 'cf7-antispam' ) );
printf(
'<input type="submit" name="cf7a_submit" class="button button-primary" value="%s">',
$checked ? esc_html__( 'Disable', 'cf7-antispam' ) : esc_html__( 'Enable', 'cf7-antispam' )
);
if ( $checked ) {
echo '<a class="button" href="' . esc_url_raw( admin_url( 'admin.php?page=cf7-antispam' ) ) . '">Settings Page</a>';
printf( '<a class="button" href="%s">Settings Page</a>', esc_url_raw( admin_url( 'admin.php?page=cf7-antispam' ) ) );
}
echo '</form>';
echo '</div>';
Expand Down

0 comments on commit fb010f3

Please sign in to comment.