Skip to content

Commit 99cebab

Browse files
committed
updates
1 parent e7dde2c commit 99cebab

File tree

6 files changed

+117
-85
lines changed

6 files changed

+117
-85
lines changed

assets/css/admin.css

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/admin.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/src/scss/admin.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ a.zerospam-dashboard__menu-link {
477477
}
478478
}
479479

480+
select {
481+
padding-right: 33px;
482+
}
483+
480484
.button {
481485
@extend %button;
482486
}
@@ -550,6 +554,12 @@ a.zerospam-dashboard__menu-link {
550554
}
551555
}
552556

557+
.check-column {
558+
input[type="checkbox"] {
559+
display: block;
560+
}
561+
}
562+
553563
.zerospam-form-field-container {
554564
align-items: center;
555565
column-gap: 10px;

core/admin/tables/class-logtable.php

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,49 @@ public function __construct() {
3131
parent::__construct( $args );
3232
}
3333

34+
/**
35+
* Define table columns
36+
*/
37+
public function get_columns() {
38+
$columns = array(
39+
'cb' => '<input type="checkbox" />',
40+
'date_recorded' => __( 'Date', 'zero-spam' ),
41+
'log_type' => __( 'Type', 'zero-spam' ),
42+
'user_ip' => __( 'IP Address', 'zero-spam' ),
43+
'country' => __( 'Country', 'zero-spam' ),
44+
'region' => __( 'Region', 'zero-spam' ),
45+
'actions' => __( 'Actions', 'zero-spam' ),
46+
);
47+
48+
return $columns;
49+
}
50+
51+
/**
52+
* Sortable columns
53+
*/
54+
public function get_sortable_columns() {
55+
$sortable_columns = array(
56+
'date_recorded' => array( 'date_recorded', false ),
57+
'log_type' => array( 'log_type', false ),
58+
'user_ip' => array( 'user_ip', false ),
59+
'country' => array( 'country', false ),
60+
'region' => array( 'region', false ),
61+
);
62+
63+
return $sortable_columns;
64+
}
65+
66+
/**
67+
* Checkbox column
68+
*/
69+
public function column_cb( $item ) {
70+
return sprintf(
71+
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
72+
/*$1%s*/ 'ids',
73+
/*$2%s*/ $item['log_id']
74+
);
75+
}
76+
3477
/**
3578
* Column values
3679
*/
@@ -322,72 +365,29 @@ public function extra_tablenav( $which ) {
322365
<?php
323366
}
324367

325-
/**
326-
* Define table columns
327-
*/
328-
public function get_columns() {
329-
$columns = array(
330-
'cb' => '<input type="checkbox" />',
331-
'date_recorded' => __( 'Date', 'zero-spam' ),
332-
'log_type' => __( 'Type', 'zero-spam' ),
333-
'user_ip' => __( 'IP Address', 'zero-spam' ),
334-
'country' => __( 'Country', 'zero-spam' ),
335-
'region' => __( 'Region', 'zero-spam' ),
336-
'actions' => __( 'Actions', 'zero-spam' ),
337-
);
338-
339-
return $columns;
340-
}
341-
342-
/**
343-
* Sortable columns
344-
*/
345-
public function get_sortable_columns() {
346-
$sortable_columns = array(
347-
'date_recorded' => array( 'date_recorded', false ),
348-
'log_type' => array( 'log_type', false ),
349-
'user_ip' => array( 'user_ip', false ),
350-
'country' => array( 'country', false ),
351-
'region' => array( 'region', false ),
352-
);
353-
354-
return $sortable_columns;
355-
}
356-
357-
/**
358-
* Column contact
359-
*/
360-
public function column_cb( $item ) {
361-
return sprintf(
362-
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
363-
/*$1%s*/ 'ids',
364-
/*$2%s*/ $item['log_id']
365-
);
366-
}
367-
368368
/**
369369
* Process bulk actions
370370
*/
371371
public function process_bulk_action() {
372372
global $wpdb;
373373

374-
$ids = ( isset( $_REQUEST['ids'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['ids'] ) ) : '';
374+
$nonce = ( isset( $_REQUEST['zerospam_nonce'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['zerospam_nonce'] ) ) : '';
375+
if ( ! wp_verify_nonce( $nonce, 'zerospam_nonce' ) || empty( $_REQUEST['ids'] ) ) {
376+
return false;
377+
}
378+
379+
$ids = array_map( 'sanitize_text_field', $_REQUEST['ids'] );
375380

376381
switch ( $this->current_action() ) {
377382
case 'delete':
378-
$nonce = ( isset( $_REQUEST['zerospam_nonce'] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST['zerospam_nonce'] ) ) : '';
379-
if ( ! wp_verify_nonce( $nonce, 'zerospam_nonce' ) ) {
380-
return false;
381-
}
382-
383383
if ( ! empty ( $ids ) && is_array( $ids ) ) {
384384
foreach ( $ids as $k => $log_id ) {
385-
ZeroSpam\Includes\DB::delete( 'log', 'log_id', $log_id );
385+
\ZeroSpam\Includes\DB::delete( 'log', 'log_id', $log_id );
386386
}
387387
}
388388
break;
389389
case 'delete_all':
390-
ZeroSpam\Includes\DB::delete_all( 'log' );
390+
\ZeroSpam\Includes\DB::delete_all( 'log' );
391391
break;
392392
}
393393
}

modules/class-security.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,24 @@ class Security {
2020
* Constructor
2121
*/
2222
public function __construct() {
23-
// It can be considered a security risk to make your WP version visible &
24-
// public you should hide it.
23+
// It can be considered a security risk to make your WP version visible &
24+
// public you should hide it.
2525
remove_action( 'wp_head', 'wp_generator' );
2626

27-
// XML-RPC can significantly amplify the brute-force attacks.
28-
add_filter( 'xmlrpc_enabled', '__return_false' );
27+
// XML-RPC can significantly amplify the brute-force attacks.
28+
add_filter( 'xmlrpc_enabled', '__return_false' );
29+
30+
// Fired on detections.
31+
add_action( 'zero_spam_detection', array( $this, 'handle_detection' ), 10, 2 );
32+
}
33+
34+
/**
35+
* Handles detections.
36+
*
37+
* @param array $validation_errors Array of validation errors.
38+
*/
39+
public function handle_detection( $details, $validation_errors ) {
40+
print_r($details);
41+
print_r($validation_errors);die();
2942
}
3043
}

modules/gravityforms/class-gravityforms.php

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ public function init() {
5151
}
5252
}
5353

54+
/**
55+
* Add to the types array
56+
*
57+
* @param array $types Array of available detection types.
58+
*/
59+
public function types( $types ) {
60+
$types['gravityforms'] = array(
61+
'label' => __( 'Gravity Forms', 'zero-spam' ),
62+
'color' => '#f15a29',
63+
);
64+
65+
return $types;
66+
}
67+
68+
/**
69+
* Admin section
70+
*
71+
* @param array $sections Array of available setting sections.
72+
*/
73+
public function sections( $sections ) {
74+
$sections['gravityforms'] = array(
75+
'title' => __( 'Gravity Forms', 'zero-spam' ),
76+
'icon' => 'modules/gravityforms/icon-gravity-forms.svg',
77+
'supports' => array( 'honeypot', 'email' ),
78+
);
79+
80+
return $sections;
81+
}
82+
5483
/**
5584
* Load the scripts
5685
*
@@ -119,6 +148,7 @@ public function process_form( $do_abort, $form ) {
119148
}
120149

121150
if ( ! empty( $validation_errors ) ) {
151+
do_action( 'zero_spam_detection', $details, $validation_errors );
122152
$do_abort = true;
123153

124154
// Failed validations, log & send details if enabled.
@@ -140,35 +170,6 @@ public function process_form( $do_abort, $form ) {
140170
return $do_abort;
141171
}
142172

143-
/**
144-
* Add to the types array
145-
*
146-
* @param array $types Array of available detection types.
147-
*/
148-
public function types( $types ) {
149-
$types['gravityforms'] = array(
150-
'label' => __( 'Gravity Forms', 'zero-spam' ),
151-
'color' => '#f15a29',
152-
);
153-
154-
return $types;
155-
}
156-
157-
/**
158-
* Admin section
159-
*
160-
* @param array $sections Array of available setting sections.
161-
*/
162-
public function sections( $sections ) {
163-
$sections['gravityforms'] = array(
164-
'title' => __( 'Gravity Forms', 'zero-spam' ),
165-
'icon' => 'modules/gravityforms/icon-gravity-forms.svg',
166-
'supports' => array( 'honeypot', 'email' ),
167-
);
168-
169-
return $sections;
170-
}
171-
172173
/**
173174
* Admin settings
174175
*

0 commit comments

Comments
 (0)