PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationSpam / Akismet / DataTransferObjects / CommentCheckArgs.php

CommentCheckArgs.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationSpam/Akismet/DataTransferObjects/CommentCheckArgs.php

63 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationSpam\Akismet\DataTransferObjects;
4
5 /**
6 * @since 4.9.0 add #[AllowDynamicProperties]
7 * @since 3.15.0
8 */
9 #[\AllowDynamicProperties]
10 class CommentCheckArgs
11 {
12 public $blog;
13 public $blog_lang;
14 public $blog_charset;
15 public $user_ip;
16 public $user_agent;
17 public $referrer;
18 public $comment_type;
19 public $comment_content;
20 public $comment_author;
21 public $comment_author_email;
22
23 /**
24 * @since 4.16.0 handle undefined server variables gracefully
25 * @since 3.22.0 updated params to receive
26 * @since 3.15.0
27 */
28 public static function make(string $comment, string $email, string $firstName): CommentCheckArgs
29 {
30 $self = new self();
31
32 $self->comment_type = 'contact-form';
33 $self->comment_content = $comment;
34 $self->comment_author = $firstName;
35 $self->comment_author_email = $email;
36
37 $self->blog = get_option('home');
38 $self->blog_lang = get_locale();
39 $self->blog_charset = get_option('blog_charset');
40
41 $self->user_ip = $_SERVER['REMOTE_ADDR'] ?? '';
42 $self->user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
43 $self->referrer = $_SERVER['HTTP_REFERER'] ?? '';
44
45 // Append additional server variables.
46 foreach ( $_SERVER as $key => $value ) {
47 if ( ! in_array( $key, [ 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ], true ) ) {
48 $self->$key = $value;
49 }
50 }
51
52 return $self;
53 }
54
55 /**
56 * @since 3.15.0
57 */
58 public function toHttpQuery(): string
59 {
60 return http_build_query(get_object_vars($this));
61 }
62 }
63