get_posted_data() : array(); $r = NBots_Client::check( $data, 'cf7' ); return empty( $r['ok'] ) ? true : $skip; } /** * WPForms: do not send notification emails for spam, confirmation stays the same. * * @param bool $send Send emails. * @param array $fields Fields. * @param array $entry Entry. * @param array $form_data Form. * @return bool */ public static function wpforms( $send, $fields, $entry, $form_data ) { if ( ! $send ) { return $send; } $data = array(); foreach ( (array) $fields as $f ) { if ( is_array( $f ) && isset( $f['name'], $f['value'] ) ) { $data[ $f['name'] ] = $f['value']; } } $r = NBots_Client::check( $data, 'wpforms' ); return empty( $r['ok'] ) ? false : $send; } /** * Elementor Pro forms: answer with the usual success message and stop before actions (email, webhooks). * * @param object $record Form record. * @param object $ajax_handler Ajax handler. */ public static function elementor( $record, $ajax_handler ) { if ( ! is_object( $record ) || ! method_exists( $record, 'get' ) ) { return; } $data = array(); foreach ( (array) $record->get( 'fields' ) as $id => $f ) { $label = is_array( $f ) && ! empty( $f['title'] ) ? $f['title'] : $id; $data[ $label ] = is_array( $f ) && isset( $f['value'] ) ? $f['value'] : ''; } $r = NBots_Client::check( $data, 'elementor' ); if ( ! empty( $r['ok'] ) ) { return; } $settings = $record->get( 'form_settings' ); $message = is_array( $settings ) && ! empty( $settings['success_message'] ) ? $settings['success_message'] : __( 'The form was sent successfully.', 'nbots' ); wp_send_json_success( array( 'message' => $message, 'data' => isset( $ajax_handler->data ) ? $ajax_handler->data : array(), ) ); } /** * Comments: spam goes to the Spam folder, as WordPress itself does. * * @param int|string $approved Approval status. * @param array $commentdata Comment. * @return int|string */ public static function comment( $approved, $commentdata ) { if ( 'spam' === $approved || 'trash' === $approved || is_admin() || current_user_can( 'moderate_comments' ) ) { return $approved; } $c = (array) $commentdata; $r = NBots_Client::check( array( 'name' => isset( $c['comment_author'] ) ? $c['comment_author'] : '', 'email' => isset( $c['comment_author_email'] ) ? $c['comment_author_email'] : '', 'url' => isset( $c['comment_author_url'] ) ? $c['comment_author_url'] : '', 'message' => isset( $c['comment_content'] ) ? $c['comment_content'] : '', ), 'comments' ); return empty( $r['ok'] ) ? 'spam' : $approved; } }