PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / audit / options-audit.php

options-audit.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/component/audit/options-audit.php

231 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Author: Hoang Ngo
4 */
5
6 namespace WP_Defender\Component\Audit;
7
8 use WP_Defender\Traits\User;
9 use WP_Defender\Model\Audit_Log;
10
11 class Options_Audit extends Audit_Event {
12 use User;
13
14 public const CONTEXT_SETTINGS = 'ct_setting';
15
16 public function get_hooks() {
17
18 return array(
19 'update_option' => array(
20 'args' => array( 'option', 'old_value', 'value' ),
21 'callback' => array( self::class, 'process_options' ),
22 'event_type' => Audit_Log::EVENT_TYPE_SETTINGS,
23 'action_type' => self::ACTION_UPDATED,
24 ),
25 );
26 }
27
28 /**
29 * @return bool|string
30 */
31 public function process_options() {
32 $args = func_get_args();
33 $option = $args[1]['option'];
34 $old = $args[1]['old_value'];
35 $new = $args[1]['value'];
36 $option_human_read = self::key_to_human_name( $option );
37 // To avoid the recursive compare if both are nested array, convert all to string.
38 $check1 = is_array( $old ) ? serialize( $old ) : $old;
39 $check2 = is_array( $new ) ? serialize( $new ) : $new;
40
41 if ( $check1 === $check2 ) {
42 return false;
43 }
44 if ( false !== $option_human_read ) {
45 $user_name = $this->get_user_display( get_current_user_id() );
46 $blog_name = is_multisite() ? '[' . get_bloginfo( 'name' ) . ']' : '';
47 // We will need special case for reader.
48 switch ( $option ) {
49 case 'users_can_register':
50 if ( 0 === $new ) {
51 $text = sprintf(
52 /* translators: */
53 esc_html__( '%1$s %2$s disabled site registration', 'wpdef' ),
54 $blog_name,
55 $user_name
56 );
57 } else {
58 $text = sprintf(
59 /* translators: */
60 esc_html__( '%1$s %2$s opened site registration', 'wpdef' ),
61 $blog_name,
62 $user_name
63 );
64 }
65 break;
66 case 'start_of_week':
67 global $wp_locale;
68 $old_day = $wp_locale->get_weekday( $old );
69 $new_day = $wp_locale->get_weekday( $new );
70 $text = sprintf(
71 /* translators: */
72 esc_html__( '%1$s %2$s update option %3$s from %4$s to %5$s', 'wpdef' ),
73 $blog_name,
74 $user_name,
75 $option_human_read,
76 $old_day,
77 $new_day
78 );
79 break;
80 case 'WPLANG':
81 if ( '' !== $new ) {
82 $text = sprintf(
83 /* translators: */
84 esc_html__( '%1$s %2$s update option %3$s to %4$s', 'wpdef' ),
85 $blog_name,
86 $user_name,
87 $option_human_read,
88 $new
89 );
90 } else {
91 $text = sprintf(
92 /* translators: */
93 esc_html__( '%1$s %2$s update option %3$s from %4$s', 'wpdef' ),
94 $blog_name,
95 $user_name,
96 $option_human_read,
97 $old
98 );
99 }
100 break;
101 default:
102 $text = sprintf(
103 /* translators: */
104 esc_html__( '%1$s %2$s update option %3$s from %4$s to %5$s', 'wpdef' ),
105 $blog_name,
106 $user_name,
107 $option_human_read,
108 $old,
109 $new
110 );
111 break;
112 }
113
114 return array( $text, self::CONTEXT_SETTINGS );
115 }
116
117 return false;
118 }
119
120 private static function key_to_human_name( $key ) {
121 $human_read = apply_filters(
122 'wd_audit_settings_keys',
123 array(
124 'blogname' => esc_html__( 'Site Title', 'wpdef' ),
125 'blogdescription' => esc_html__( 'Tagline', 'wpdef' ),
126 'gmt_offset' => esc_html__( 'Timezone', 'wpdef' ),
127 'date_format' => esc_html__( 'Date Format', 'wpdef' ),
128 'time_format' => esc_html__( 'Time Format', 'wpdef' ),
129 'start_of_week' => esc_html__( 'Week Starts On', 'wpdef' ),
130 'timezone_string' => esc_html__( 'Timezone', 'wpdef' ),
131 'WPLANG' => esc_html__( 'Site Language', 'wpdef' ),
132 'siteurl' => esc_html__( 'WordPress Address (URL)', 'wpdef' ),
133 'home' => esc_html__( 'Site Address (URL)', 'wpdef' ),
134 'admin_email' => esc_html__( 'Email Address', 'wpdef' ),
135 'users_can_register' => esc_html__( 'Membership', 'wpdef' ),
136 'default_role' => esc_html__( 'New User Default Role', 'wpdef' ),
137 'default_pingback_flag' => esc_html__( 'Default article settings', 'wpdef' ),
138 'default_ping_status' => esc_html__( 'Default article settings', 'wpdef' ),
139 'default_comment_status' => esc_html__( 'Default article settings', 'wpdef' ),
140 'comments_notify' => esc_html__( 'Email me whenever', 'wpdef' ),
141 'moderation_notify' => esc_html__( 'Email me whenever', 'wpdef' ),
142 'comment_moderation' => esc_html__( 'Before a comment appears', 'wpdef' ),
143 'require_name_email' => esc_html__( 'Other comment settings', 'wpdef' ),
144 'comment_whitelist' => esc_html__( 'Before a comment appears', 'wpdef' ),
145 'comment_max_links' => esc_html__( 'Comment Moderation', 'wpdef' ),
146 'moderation_keys' => esc_html__( 'Comment Moderation', 'wpdef' ),
147 'blacklist_keys' => esc_html__( 'Comment Blocklist', 'wpdef' ),
148 'show_avatars' => esc_html__( 'Avatar Display', 'wpdef' ),
149 'avatar_rating' => esc_html__( 'Maximum Rating', 'wpdef' ),
150 'avatar_default' => esc_html__( 'Default Avatar', 'wpdef' ),
151 'close_comments_for_old_posts' => esc_html__( 'Other comment settings', 'wpdef' ),
152 'close_comments_days_old' => esc_html__( 'Other comment settings', 'wpdef' ),
153 'thread_comments' => esc_html__( 'Other comment settings', 'wpdef' ),
154 'thread_comments_depth' => esc_html__( 'Other comment settings', 'wpdef' ),
155 'page_comments' => esc_html__( 'Other comment settings', 'wpdef' ),
156 'comments_per_page' => esc_html__( 'Other comment settings', 'wpdef' ),
157 'default_comments_page' => esc_html__( 'Other comment settings', 'wpdef' ),
158 'comment_order' => esc_html__( 'Other comment settings', 'wpdef' ),
159 'comment_registration' => esc_html__( 'Other comment settings', 'wpdef' ),
160 'thumbnail_size_w' => esc_html__( 'Thumbnail size', 'wpdef' ),
161 'thumbnail_size_h' => esc_html__( 'Thumbnail size', 'wpdef' ),
162 'thumbnail_crop' => esc_html__( 'Thumbnail size', 'wpdef' ),
163 'medium_size_w' => esc_html__( 'Medium size', 'wpdef' ),
164 'medium_size_h' => esc_html__( 'Medium size', 'wpdef' ),
165 'medium_large_size_w' => esc_html__( 'Medium size', 'wpdef' ),
166 'medium_large_size_h' => esc_html__( 'Medium size', 'wpdef' ),
167 'large_size_w' => esc_html__( 'Large size', 'wpdef' ),
168 'large_size_h' => esc_html__( 'Large size', 'wpdef' ),
169 'image_default_size' => esc_html__( 'Default image size', 'wpdef' ),
170 'image_default_align' => esc_html__( 'Default image align', 'wpdef' ),
171 'image_default_link_type' => esc_html__( 'Default image link type', 'wpdef' ),
172 'uploads_use_yearmonth_folders' => esc_html__( 'Uploading Files', 'wpdef' ),
173 'posts_per_page' => esc_html__( 'Blog pages show at most', 'wpdef' ),
174 'posts_per_rss' => esc_html__( 'Syndication feeds show the most recent', 'wpdef' ),
175 'rss_use_excerpt' => esc_html__( 'For each article in a feed, show', 'wpdef' ),
176 'show_on_front' => esc_html__( 'Front page displays', 'wpdef' ),
177 'page_on_front' => esc_html__( 'Front page', 'wpdef' ),
178 'page_for_posts' => esc_html__( 'Posts page', 'wpdef' ),
179 'blog_public' => esc_html__( 'Search Engine Visibility', 'wpdef' ),
180 'default_category' => esc_html__( 'Default Post Category', 'wpdef' ),
181 'default_email_category' => esc_html__( 'Default Mail Category', 'wpdef' ),
182 'default_link_category' => esc_html__( 'Default Link Category', 'wpdef' ),
183 'default_post_format' => esc_html__( 'Default Post Format', 'wpdef' ),
184 'mailserver_url' => esc_html__( 'Mail Server', 'wpdef' ),
185 'mailserver_port' => esc_html__( 'Port', 'wpdef' ),
186 'mailserver_login' => esc_html__( 'Login Name', 'wpdef' ),
187 'mailserver_pass' => esc_html__( 'Password', 'wpdef' ),
188 'ping_sites' => esc_html__( 'Update Services', 'wpdef' ),
189 'permalink_structure' => esc_html__( 'Permalink Setting', 'wpdef' ),
190 'category_base' => esc_html__( 'Category base', 'wpdef' ),
191 'tag_base' => esc_html__( 'Tag base', 'wpdef' ),
192 'registrationnotification' => esc_html__( 'Registration notification', 'wpdef' ),
193 'registration' => esc_html__( 'Allow new registrations', 'wpdef' ),
194 'add_new_users' => esc_html__( 'Add New Users', 'wpdef' ),
195 'menu_items' => esc_html__( 'Enable administration menus', 'wpdef' ),
196 'upload_space_check_disabled' => esc_html__( 'Site upload space', 'wpdef' ),
197 'blog_upload_space' => esc_html__( 'Site upload space', 'wpdef' ),
198 'upload_filetypes' => esc_html__( 'Upload file types', 'wpdef' ),
199 'site_name' => esc_html__( 'Network Title', 'wpdef' ),
200 'first_post' => esc_html__( 'First Post', 'wpdef' ),
201 'first_page' => esc_html__( 'First Page', 'wpdef' ),
202 'first_comment' => esc_html__( 'First Comment', 'wpdef' ),
203 'first_comment_url' => esc_html__( 'First Comment URL', 'wpdef' ),
204 'first_comment_author' => esc_html__( 'First Comment Author', 'wpdef' ),
205 'welcome_email' => esc_html__( 'Welcome Email', 'wpdef' ),
206 'welcome_user_email' => esc_html__( 'Welcome User Email', 'wpdef' ),
207 'fileupload_maxk' => esc_html__( 'Max upload file size', 'wpdef' ),
208 'illegal_names' => esc_html__( 'Banned Names', 'wpdef' ),
209 'limited_email_domains' => esc_html__( 'Limited Email Registrations', 'wpdef' ),
210 'banned_email_domains' => esc_html__( 'Banned Email Domains', 'wpdef' ),
211 )
212 );
213
214 if ( isset( $human_read[ $key ] ) ) {
215 if ( empty( $human_read[ $key ] ) ) {
216 return $key;
217 }
218
219 return $human_read[ $key ];
220 }
221
222 return false;
223 }
224
225 public function dictionary() {
226 return array(
227 self::CONTEXT_SETTINGS => esc_html__( 'Settings', 'wpdef' ),
228 );
229 }
230 }
231