Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling and linting #85

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 4 additions & 10 deletions admin/CF7_AntiSpam_Admin_Customizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class CF7_AntiSpam_Admin_Customizations {
* The class `CF7_Antispam_geoip` is instantiated.
*/
public function __construct() {

if ( ! current_user_can( 'manage_options' ) ) {
return esc_html__( 'Administrators only', 'cf7-antispam' );
}
Expand All @@ -50,7 +49,6 @@ public function __construct() {
$this->options = CF7_AntiSpam::get_options();

add_action( 'admin_init', array( $this, 'cf7a_options_init' ) );

}

/**
Expand All @@ -65,7 +63,6 @@ public function cf7a_options_init() {
array( $this, 'cf7a_sanitize_options' )
);


/* Section Bot Fingerprint */
add_settings_section(
'cf7a_subtitle',
Expand Down Expand Up @@ -464,7 +461,7 @@ public function cf7a_options_init() {
/* Honeyform excluded pages */
add_settings_field(
'honeyform_excluded_pages',
__( 'Add pages you wish shouldn\'t have a Honeyform', 'cf7-antispam' ),
__( 'Exclude pages', 'cf7-antispam' ),
array( $this, 'cf7a_honeyform_excluded_pages_callback' ),
'cf7a-settings',
'cf7a_honeyform'
Expand Down Expand Up @@ -688,7 +685,6 @@ public function cf7a_options_init() {
* @return string a random tip from the array of tips.
*/
public function cf7a_get_a_random_tip() {

$tips = array(
__( 'Do you know,that you can save settings simply using the shortcut [Ctrl + S].', 'cf7-antispam' ),
__( 'In the CF7-Antispam settings page you can enter values in textarea using the comma-separated format and, on saving, the strings will be split up into one per line format.', 'cf7-antispam' ),
Expand All @@ -710,7 +706,6 @@ public function cf7a_get_a_random_tip() {
);

return $tips[ round( wp_rand( 0, count( $tips ) - 1 ) ) ];

}

/**
Expand Down Expand Up @@ -845,7 +840,7 @@ public function cf7a_print_honeypot() {

/** It prints the honeyform info text */
public function cf7a_print_honeyform() {
printf( '<p>%s</p>', esc_html__( "I'm actually going to propose the honey-form for the first time! Instead of serving the bot a form with trap fields we directly serve it a form that is entirely a trap", 'cf7-antispam' ) );
printf( '<p>%s</p>', esc_html__( "Instead of relying on trap fields, we utilize honeyforms, that are forms specifically designed as deceptive 'trap' forms. Similar to honeypots, these forms are crafted to mislead and catch potential threats.", 'cf7-antispam' ) );
}

/** It prints the user protection info text */
Expand Down Expand Up @@ -1515,7 +1510,6 @@ public function cf7a_honeyform_position_callback() {
* The user can add pages from the first dropdown to the second dropdown and remove pages from the second dropdown.
* The selected pages are saved as options in the WordPress database.
*/

public function cf7a_honeyform_excluded_pages_callback() {
$args = array(
'post_type' => 'page', // change this to the post type you're querying
Expand All @@ -1533,7 +1527,7 @@ public function cf7a_honeyform_excluded_pages_callback() {
}

$admin_options = get_option( 'cf7a_options' );
$excluded = $admin_options['honeyform_excluded_pages'];
$excluded = isset( $admin_options['honeyform_excluded_pages'] ) ? $admin_options['honeyform_excluded_pages'] : array();
$str_excluded = '';
if ( is_array( $excluded ) ) {
foreach ( $excluded as $entry ) {
Expand Down Expand Up @@ -1561,7 +1555,7 @@ public function cf7a_honeyform_excluded_pages_callback() {
$options,
__( 'Add', 'cf7-antispam' ),
$str_excluded,
__( 'Remove', 'cf7-antispam' ),
__( 'Remove', 'cf7-antispam' )
);
}

Expand Down
13 changes: 1 addition & 12 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 All @@ -45,7 +44,7 @@ public function display_dashboard() {
?>
<div class="wrap">
<div class="cf7-antispam">
<h1><span class="icon"><?php echo wp_rand( 0, 1 ) > .5 ? '☂ ' : '☔'; ?></span> Contact Form 7 AntiSpam</h1>
<h1><span class="icon"><?php echo wp_rand( 0, 1 ) > .5 ? '☂' : '☔'; ?></span> Contact Form 7 AntiSpam</h1>
<?php
add_action( 'cf7a_dashboard', array( $this, 'cf7a_display_content' ), 22 );
?>
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
Loading