Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed Jan 2, 2024
1 parent 310a8fc commit 3e0e83e
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 279 deletions.
4 changes: 0 additions & 4 deletions admin/CF7_AntiSpam_Admin_Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ public function enqueue_styles() {
*/

wp_enqueue_style( $this->plugin_name, CF7ANTISPAM_PLUGIN_URL . '/build/admin-scripts.css', array(), $this->version );

}

/**
Expand Down Expand Up @@ -199,7 +198,6 @@ public function enqueue_scripts() {
'alertMessage' => esc_html__( 'Are you sure?', 'cf7-antispam' ),
)
);

}

/**
Expand Down Expand Up @@ -233,7 +231,6 @@ public function cf7a_dashboard_widget() {
* emails received per day, and one with the number of emails received per type (ham or spam)
*/
public function cf7a_flamingo_recap() {

$max_mail_count = apply_filters( 'cf7a_dashboard_max_mail_count', 25 );

$args = array(
Expand Down Expand Up @@ -296,7 +293,6 @@ public function cf7a_flamingo_recap() {
}
$mail_collection['by_type'][ $is_ham ? 'ham' : 'spam' ]++;
$mail_collection['by_date'][ $today ][] = array( 'status' => $is_ham ? 'ham' : 'spam' );

endwhile;

wp_reset_postdata();
Expand Down
11 changes: 0 additions & 11 deletions admin/CF7_AntiSpam_Admin_Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class CF7_AntiSpam_Admin_Display {
* Init the class and get the options stored in the database.
*/
public function __construct() {

$this->options = CF7_AntiSpam::get_options();
}

Expand Down Expand Up @@ -135,12 +134,10 @@ public function cf7a_display_debug() {
* It gets the blacklisted IPs from the database and displays them in a table
*/
public static function cf7a_get_blacklisted_table() {

global $wpdb;
$blacklisted = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}cf7a_blacklist ORDER BY `status` DESC LIMIT 1000" );

if ( $blacklisted ) {

$count = count( $blacklisted );
$rows = '';

Expand Down Expand Up @@ -261,14 +258,12 @@ public static function cf7a_advanced_settings() {
$html .= printf( '</div>' );

return $html;

}

/**
* It outputs a debug panel if WP_DEBUG or CF7ANTISPAM_DEBUG are true
*/
public function cf7a_get_debug_info() {

if ( WP_DEBUG || CF7ANTISPAM_DEBUG ) {

/* the header */
Expand Down Expand Up @@ -323,7 +318,6 @@ public function cf7a_get_debug_info() {
* @return void the HTML for the debug info options.
*/
private function cf7a_get_debug_info_options() {

printf( '<hr/><h3>%s</h3>', esc_html__( 'Options debug', 'cf7-antispam' ) );
printf(
'<p>%s</p><pre>%s</pre>',
Expand All @@ -340,17 +334,13 @@ private function cf7a_get_debug_info_options() {
* It checks if the GeoIP database is enabled, and if so, it checks the next update date and displays it
*/
private function cf7a_get_debug_info_dnsbl() {

$remote_ip = cf7a_get_real_ip();

$performance_test = array();

if ( filter_var( $remote_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 ) ) {

$reverse_ip = CF7_AntiSpam_Filters::cf7a_reverse_ipv4( $remote_ip );

} elseif ( filter_var( $remote_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 ) ) {

$reverse_ip = CF7_AntiSpam_Filters::cf7a_reverse_ipv6( $remote_ip );
} else {
$reverse_ip = false;
Expand Down Expand Up @@ -394,7 +384,6 @@ private function cf7a_get_debug_info_dnsbl() {
*/
private static function cf7a_get_debug_info_geoip() {
try {

$cf7a_geo = new CF7_Antispam_Geoip();

$geoip_update = $cf7a_geo->next_update ? esc_html( date_i18n( get_option( 'date_format' ), $cf7a_geo->next_update ) ) : esc_html__( 'not set', 'cf7-antispam' );
Expand Down
9 changes: 0 additions & 9 deletions admin/CF7_AntiSpam_Admin_Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public static function cf7a_push_notice( $message = 'generic', $type = 'error',
* It handles the actions that are triggered by the user
*/
public function cf7a_handle_actions() {

$action = isset( $_REQUEST['action'] ) ? sanitize_key( wp_unslash( $_REQUEST['action'] ) ) : false;
$url = esc_url( menu_page_url( 'cf7-antispam', false ) );

Expand All @@ -59,7 +58,6 @@ public function cf7a_handle_actions() {

/* Ban a single ID (related to ip) */
if ( 'unban_' === substr( $action, 0, 6 ) ) {

$unban_id = intval( substr( $action, 6 ) );

$filter = new CF7_AntiSpam_Filters();
Expand All @@ -80,7 +78,6 @@ public function cf7a_handle_actions() {

/* Ban forever a single ID */
if ( 'ban_forever_' === substr( $action, 0, 12 ) ) {

$filter = new CF7_AntiSpam_Filters();

$plugin_options = CF7_AntiSpam::get_options();
Expand All @@ -89,7 +86,6 @@ public function cf7a_handle_actions() {
$ban_ip = $filter->cf7a_blacklist_get_id( $ban_id );

if ( $ban_ip && ! empty( $plugin_options ) ) {

if ( CF7_AntiSpam::update_plugin_option( 'bad_ip_list', array_merge( $plugin_options['bad_ip_list'], array( $ban_ip->ip ) ) ) ) {
$filter->cf7a_unban_by_id( $ban_id );
}
Expand All @@ -102,7 +98,6 @@ public function cf7a_handle_actions() {
! empty( $ban_ip->ip ) ? $ban_ip->ip : 'not available'
)
);

} else {
self::cf7a_push_notice(
sprintf(
Expand Down Expand Up @@ -167,7 +162,6 @@ public function cf7a_handle_actions() {

/* Rebuild Dictionary */
if ( 'rebuild-dictionary' === $action ) {

$r = CF7_AntiSpam_Flamingo::cf7a_rebuild_dictionary();

if ( $r ) {
Expand All @@ -182,13 +176,11 @@ public function cf7a_handle_actions() {

/* Resend an email */
if ( 'cf7a_resend_' === substr( $action, 0, 12 ) ) {

$mail_id = (int) substr( $action, 12 );

$refer = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : false;

if ( $mail_id > 1 ) {

$cf7a_flamingo = new CF7_AntiSpam_Flamingo();
$r = $cf7a_flamingo->cf7a_resend_mail( $mail_id );

Expand All @@ -213,6 +205,5 @@ public function cf7a_handle_actions() {
exit();
}
}

}
}
1 change: 0 additions & 1 deletion cf7-antispam.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function cf7_antispam_register_service() {


function run_cf7a() {

$options = get_option( 'cf7a_options' );

if ( ! empty( $options['cf7a_enable'] ) ) {
Expand Down
21 changes: 4 additions & 17 deletions core/CF7_AntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ class CF7_AntiSpam {
* The constructor function is called when the plugin is loaded. It sets the version, plugin name, and options. It loads
* the dependencies, sets the locale, updates the plugin, and loads the admin and frontend areas
*/



public function __construct() {
if ( defined( 'CF7ANTISPAM_VERSION' ) ) {
$this->version = CF7ANTISPAM_VERSION;
Expand Down Expand Up @@ -123,10 +120,8 @@ public function __construct() {
* @access protected
*/
protected function update() {

do_action( 'cf7a_update' );
CF7_AntiSpam_Activator::update_options();

}

/**
Expand All @@ -146,11 +141,9 @@ private function load_dependencies() {
* @access private
*/
private function set_locale() {

$plugin_i18n = new CF7_AntiSpam_i18n();

$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );

}

/**
Expand All @@ -172,7 +165,6 @@ private function load_antispam() {
add_action( 'cf7a_cron', array( $plugin_antispam, 'cf7a_cron_unban' ) );

if ( defined( 'FLAMINGO_VERSION' ) ) {

$cf7a_flamingo = new CF7_AntiSpam_Flamingo();

/* if flamingo is defined the mail will be analyzed after flamingo has stored */
Expand All @@ -183,7 +175,6 @@ private function load_antispam() {
}

if ( ! empty( $this->options['enable_geoip_download'] ) ) {

$geo = new CF7_Antispam_Geoip();

add_action( 'cf7a_geoip_update_db', array( $geo, 'cf7a_geoip_download_database' ) );
Expand All @@ -202,7 +193,6 @@ private function load_antispam() {
* @access private
*/
private function load_admin() {

if ( is_admin() ) {

/* It handles the actions that are triggered by the user */
Expand Down Expand Up @@ -403,11 +393,9 @@ public static function update_plugin_options( $options ) {
* @return bool
*/
public static function update_plugin_option( $option, $value ) {

$plugin_options = self::get_options();

if ( isset( $plugin_options[ $option ] ) ) {

if ( is_string( $value ) ) {
/* if the value is a string sanitize and replace the option */
$plugin_options[ $option ] = sanitize_text_field( trim( $value ) );
Expand All @@ -427,19 +415,18 @@ public static function update_plugin_option( $option, $value ) {
}

public function spam_mail_report( $mail_body, $last_report_timestamp ) {

global $wpdb;

$all = $wpdb->get_var(
"SELECT COUNT(*) AS cnt
"SELECT COUNT(*) AS cnt
FROM {$wpdb->prefix}posts
WHERE post_status = 'flamingo-spam';"
WHERE post_status = 'flamingo-spam';"
);
$last = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) AS cnt
FROM {$wpdb->prefix}posts
WHERE post_date_gmt >= FROM_UNIXTIME( %d )
FROM {$wpdb->prefix}posts
WHERE post_date_gmt >= FROM_UNIXTIME( %d )
AND post_status = 'flamingo-spam';",
$last_report_timestamp
)
Expand Down
1 change: 0 additions & 1 deletion core/CF7_AntiSpam_B8.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private function cf7a_b8_init() {
* @return float The rating of the message.
*/
public function cf7a_b8_classify( $message, $verbose = false ) {

if ( empty( $message ) ) {
return false;
}
Expand Down
8 changes: 1 addition & 7 deletions core/CF7_AntiSpam_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use WP_Query;
use WPCF7_ContactForm;
use WPCF7_Submission;

/**
* A class that handles front end related function
Expand Down Expand Up @@ -53,7 +54,6 @@ class CF7_AntiSpam_Frontend {
* @param string $version The current version number of the plugin.
*/
public function __construct( $plugin_name, $version ) {

$this->plugin_name = $plugin_name;
$this->version = $version;

Expand Down Expand Up @@ -160,8 +160,6 @@ public function cf7a_honeyform( $content ) {
return $content;
}



/* $html will store the honeyform html */
$html = '';

Expand Down Expand Up @@ -256,7 +254,6 @@ public function cf7a_honeyform( $content ) {
);

$html = html_entity_decode( $html, ENT_COMPAT, 'UTF-8' );

endwhile;

wp_reset_postdata();
Expand Down Expand Up @@ -337,7 +334,6 @@ public function cf7a_add_hidden_fields( $fields ) {
* @return array The array of fields is being returned.
*/
public function cf7a_add_bot_fingerprinting( $fields ) {

$prefix = sanitize_html_class( $this->options['cf7a_customizations_prefix'] );

return array_merge(
Expand All @@ -356,7 +352,6 @@ public function cf7a_add_bot_fingerprinting( $fields ) {
* @return array The $fields array is being merged with the $prefix . 'bot_fingerprint_extras' => false array.
*/
public function cf7a_add_bot_fingerprinting_extras( $fields ) {

$prefix = sanitize_html_class( $this->options['cf7a_customizations_prefix'] );

return array_merge(
Expand All @@ -375,7 +370,6 @@ public function cf7a_add_bot_fingerprinting_extras( $fields ) {
* @return array The array of fields.
*/
public function cf7a_append_on_submit( $fields ) {

$prefix = sanitize_html_class( $this->options['cf7a_customizations_prefix'] );

return array_merge(
Expand Down
3 changes: 0 additions & 3 deletions core/CF7_AntiSpam_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public function add_filter( $hook, $component, $callback, $priority = 10, $accep
* @return array The collection of actions and filters registered with WordPress.
*/
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {

$hooks[] = array(
'hook' => $hook,
'component' => $component,
Expand All @@ -106,7 +105,6 @@ private function add( $hooks, $hook, $component, $callback, $priority, $accepted
);

return $hooks;

}

/**
Expand All @@ -115,7 +113,6 @@ private function add( $hooks, $hook, $component, $callback, $priority, $accepted
* @since 0.1.0
*/
public function run() {

foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
Expand Down
1 change: 0 additions & 1 deletion core/CF7_AntiSpam_i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CF7_AntiSpam_i18n {
* @since 0.1.0
*/
public function load_plugin_textdomain() {

load_plugin_textdomain(
'cf7-antispam',
false,
Expand Down
Loading

0 comments on commit 3e0e83e

Please sign in to comment.