PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.7.6
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.7.6
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Admin / Options / Security.php

Security.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.0.7.6, at Inc/Admin/Options/Security.php

853 lines 30.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Admin\Options;
4
5 use WPAdminify\Inc\Utils;
6 use WPAdminify\Inc\Admin\AdminSettingsModel;
7
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 } // Cannot access directly.
12
13 if ( ! class_exists( 'Security' ) ) {
14 class Security extends AdminSettingsModel {
15
16 public $defaults = [];
17
18 public function __construct() {
19 $this->tweak_settings();
20 }
21
22 protected function get_defaults() {
23 return [
24 'security_head' => [
25 'enable_security_head' => false,
26 'security_head_data' => [
27 'generator_wp_version'
28 ],
29 'self_ping_sites' => ''
30 ],
31 'security_rest_api' => [
32 'security_rest_api_enable' => false,
33 'security_rest_api_data' => []
34 ],
35 'disable_comments' => [
36 'enable_disable_comments' => false,
37 'post_types' => [],
38 'apply_for' => [],
39 ],
40 'custom_gravatar' => [
41 'enable',
42 'image' => [
43 [
44 'avatar_image' => '',
45 'avatar_name' => 'Avatar Name',
46 ],
47 ],
48 ],
49 'post_archives' => [
50 'post_archives_enable' => false,
51 'post_archives_data' => [],
52 ],
53 'security_feed' => false,
54 'users_security' => [
55 'limit_logins' => false,
56 'change_username' => false,
57 ],
58 'disable_automatic_emails' => false,
59 'disable_language_switcher_login' => false,
60
61 // Redirect URLs
62 'redirect_urls_fields' => [
63 'enable_redirect_urls' => false,
64 'redirect_urls_options' => [
65 'redirect_urls_tabs' => [
66 'new_login_url' => '',
67 'redirect_admin_url' => '',
68 'new_register_url' => '',
69 'new_logout_url' => '',
70 'login_redirects' => [
71 'user_types' => 'user_role',
72 'redirect_user' => 'user_role',
73 'redirect_role' => '',
74 'redirect_cap' => '',
75 'redirect_url' => '',
76 // 'redirect_order' => 10,
77 ],
78 'logout_redirects' => [
79 'user_types' => 'user_role',
80 'redirect_user' => 'user_role',
81 'redirect_role' => '',
82 'redirect_cap' => '',
83 'redirect_url' => '',
84 // 'redirect_order' => 10,
85 ]
86 ],
87 ],
88 ]
89 ];
90 }
91
92
93 /**
94 * Security: Head Fields
95 *
96 * @return void
97 */
98 public function security_head_fields( &$head_fields ) {
99 $security_head = [
100 'xmlrpc' => __( 'Disable XML-RPC', 'adminify' ),
101 'generator_wp_version' => __( 'Remove WordPress Generator Version from front end', 'adminify' ),
102 'rsd' => __( 'Remove "<link rel=\'EditURI\'..." from head section', 'adminify' ),
103 'shortlink' => __( 'Remove "<link rel=\'shortlink\'..." from head section', 'adminify' ),
104 'canonical' => __( 'Remove &lt;link rel="canonical" href="https://www.site.com/some-url" /&gt; from head section', 'adminify' ),
105 'self_ping' => __('Disable self-ping, i.e., from your site to your site when writing posts.', 'adminify'),
106 ];
107
108 $third_party_security_head = [];
109 if ( Utils::is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
110 $third_party_security_head['wc_generator'] = __( 'Remove WooCommerce Generator Meta', 'adminify' );
111 }
112
113 if ( Utils::is_plugin_active( 'revslider/revslider.php' ) ) {
114 $third_party_security_head['revslider_generator'] = __( 'Remove Revolution Slider Generator Meta', 'adminify' );
115 }
116
117 if ( Utils::is_plugin_active( 'js_composer/js_composer.php' ) ) {
118 $third_party_security_head['js_composer_generator'] = __( 'Remove Visual Composer Generator Meta', 'adminify' );
119 }
120
121 if ( Utils::is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
122 $third_party_security_head['wpml_generator'] = __( 'Remove WPML Generator Meta', 'adminify' );
123 }
124
125 if ( Utils::is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) {
126 $third_party_security_head['yoast_generator'] = __( 'Remove All Yoast HTML Comments', 'adminify' );
127 }
128
129 $security_head = array_merge($security_head, $third_party_security_head);
130
131
132 $head_fields[] = [
133 'id' => 'security_head',
134 'title' => __('Header Security', 'adminify'),
135 'subtitle' => __('WordPress Frontend Head Tags Security ', 'adminify'),
136 'type' => 'fieldset',
137 'fields' => [
138 [
139 'id' => 'enable_security_head',
140 'type' => 'switcher',
141 'title' => __('', 'adminify'),
142 'class' => 'adminify-pl-0 adminify-pt-0',
143 'text_on' => __('Show', 'adminify'),
144 'text_off' => __('Hide', 'adminify'),
145 'text_width' => 80,
146 'default' => $this->get_default_field('security_head')['enable_security_head'],
147 ],
148 [
149 'id' => 'security_head_data',
150 'type' => 'checkbox',
151 'class' => 'adminify-one-col',
152 'title' => __('', 'adminify'),
153 'options' => $security_head,
154 'default' => $this->get_default_field('security_head')['security_head_data'],
155 'dependency' => ['enable_security_head', '==', 'true', 'true']
156 ],
157 [
158 'id' => 'self_ping_sites',
159 'type' => 'textarea',
160 'subtitle' => __('Additional URLs to disable Self Ping', 'adminify'),
161 'placeholder' => __('Each URLs in new line', 'adminify'),
162 'title' => 'Additional Self-Ping URLs',
163 'default' => $this->get_default_field('self_ping_sites'),
164 'dependency' => ['security_head_data|enable_security_head', 'any|==', 'self_ping|true', 'true'],
165 ]
166 ]
167 ];
168
169 }
170
171
172 /**
173 * Security: Feed Fields
174 *
175 * @param [type] $security_feed
176 *
177 * @return void
178 */
179 public function security_feed_fields( &$security_feed ) {
180 $security_feed[] = [
181 'id' => 'security_feed',
182 'type' => 'switcher',
183 'title' => __('Feed Links', 'adminify'),
184 'text_on' => __('Yes', 'adminify'),
185 'text_off' => __('No', 'adminify'),
186 'text_width' => 80,
187 'subtitle' => __('Disable all RSS, Atom, and RDF feeds, including posts, categories, tags, comments, authors, and search. Also redirect all feed URLs.', 'adminify'),
188 'default' => $this->get_default_field('security_feed'),
189 ];
190 }
191
192 /**
193 * Change Username Module
194 */
195 public function security_redirect_urls(&$redirect_urls){
196 $settings_fields = [];
197 $login_redirects = [];
198 // $logout_redirects = [];
199 $this->login_register_url_fields($settings_fields);
200 $this->roles_redirect_tabs($login_redirects);
201
202 $redirect_urls = [
203 [
204 'id' => 'redirect_urls_fields',
205 'title' => sprintf(__('Redirect URLs %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
206 'class' => 'adminify-pro-fieldset',
207 'subtitle' => __('Login and logout redirects based on user roles. Customize URLs for administrators, editors, or subscribers etc.', 'adminify'),
208 'type' => 'fieldset',
209 'fields' => [
210 [
211 'id' => 'enable_redirect_urls',
212 'type' => 'switcher',
213 'class' => 'adminify-pl-0',
214 'text_on' => __('Show', 'adminify'),
215 'text_off' => __('Hide', 'adminify'),
216 'text_width' => 80,
217 'default' => $this->get_default_field('redirect_urls_fields')['enable_redirect_urls'],
218 ],
219 [
220 'id' => 'redirect_urls_options',
221 'type' => 'fieldset',
222 'title' => __(' ', 'adminify'),
223 'class' => 'adminify-pt-0 adminify-pl-0 adminify-one-col adminify-tabs-content adminify-pro-notice',
224 'fields' => [
225 [
226 'id' => 'redirect_urls_tabs',
227 'type' => 'tabbed',
228 'title' => '',
229 'tabs' => [
230 [
231 'title' => __('Login/Register URL', 'adminify'),
232 'fields' => $settings_fields,
233 ],
234 [
235 'title' => __('Roles Redirect', 'adminify'),
236 'fields' => $login_redirects,
237 ],
238 ],
239 ]
240 ],
241 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options'],
242 'dependency' => ['enable_redirect_urls', '==', 'true', true],
243 ]
244 ]
245 ]
246 ];
247 }
248
249
250
251 public function login_register_url_fields(&$settings_fields)
252 {
253 $settings_fields[] = [
254 'id' => 'new_login_url',
255 'type' => 'text',
256 'class' => 'new-login-url',
257 'title' => __('New Login URL', 'adminify'),
258 'desc' => __('Change the login URL and prevent access to the wp-admin and <code>' . wp_login_url() . '</code> page directly.', 'adminify'),
259 'placeholder' => 'login',
260 'before' => \get_site_url() . '/',
261 // 'after' => '/',
262 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['new_login_url'],
263 ];
264
265 $settings_fields[] = [
266 'id' => 'redirect_admin_url',
267 'type' => 'text',
268 'class' => 'new-login-url redirect-admin-url',
269 'title' => __('Redirect Admin', 'adminify'),
270 'desc' => __('Redirect users those are not logged in and trying to access <code>' . get_admin_url() . '</code>', 'adminify'),
271 'placeholder' => '404',
272 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['redirect_admin_url'],
273 'before' => \get_site_url() . '/',
274 // 'after' => '/',
275 ];
276
277 $settings_fields[] = [
278 'id' => 'new_register_url',
279 'type' => 'text',
280 'class' => 'new-login-url new-register-url',
281 'title' => __('New Register URL', 'adminify'),
282 'subtitle' => __('Enable <a href="' . admin_url('options-general.php#users_can_register') . '"><b>Membership: "Anyone can register"</b></a> checkbox from Settings.', 'adminify'),
283 'desc' => __('Change the Register URL, to setup the custom designed registration page.', 'adminify'),
284 'placeholder' => 'wp-login.php?action=register',
285 'before' => \get_site_url() . '/',
286 // 'after' => '/',
287 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['new_register_url'],
288 ];
289 }
290
291 /**
292 * Settings Fields
293 *
294 * @return void
295 */
296 public function roles_redirect_tabs(&$roles_redirect)
297 {
298 $login_redirect_fields = [];
299 $logout_redirect_fields = [];
300 $this->login_redirect_tab_fields($login_redirect_fields);
301 $this->logout_redirect_tab_fields($logout_redirect_fields);
302
303 $roles_redirect[] = [
304 'id' => 'roles_redirect_tabs',
305 'type' => 'button_set',
306 'title' => __('Redirect Rules Type', 'adminify'),
307 'options' => array(
308 'login' => __('Login Redirect ', 'adminify'),
309 'logout' => __('Logout Redirect ', 'adminify'),
310 ),
311 'default' => 'login',
312 ];
313
314 // Heading
315 $roles_redirect[] = [
316 'type' => 'submessage',
317 'style' => 'info',
318 'class' => 'adminify-one-col',
319 'content' => __('Add Login conditions to redirect users to different pages based on their user names, roles & capabilities', 'adminify'),
320 'dependency' => ['roles_redirect_tabs', '==', 'login'],
321 ];
322 $roles_redirect[] = [
323 'id' => 'login_redirects',
324 'type' => 'group',
325 'title' => '',
326 'accordion_title_prefix' => __('Login Redirect: ', 'adminify'),
327 'accordion_title_number' => true,
328 'accordion_title_auto' => true,
329 'button_title' => __('Add New Login Redirect', 'adminify'),
330 'fields' => $login_redirect_fields,
331 'dependency' => ['roles_redirect_tabs', '==', 'login'],
332 ];
333
334
335
336 // Logout Heading
337 $roles_redirect[] = [
338 'type' => 'submessage',
339 'style' => 'info',
340 'class' => 'adminify-one-col',
341 'content' => __('Add Logout conditions to redirect users to different pages based on their user names, roles & capabilities', 'adminify'),
342 'dependency' => ['roles_redirect_tabs', '==', 'logout'],
343 ];
344 $roles_redirect[] = [
345 'id' => 'logout_redirects',
346 'type' => 'group',
347 'title' => '',
348 'accordion_title_prefix' => __('Logout Redirect: ', 'adminify'),
349 'accordion_title_number' => true,
350 'accordion_title_auto' => true,
351 'button_title' => __('Add New Logout Redirect', 'adminify'),
352 'fields' => $logout_redirect_fields,
353 'dependency' => ['roles_redirect_tabs', '==', 'logout'],
354 ];
355 }
356
357
358 /**
359 * Login Redirect Fields
360 *
361 * @param [type] $login_redirect_fields
362 *
363 * @return void
364 */
365 public function login_redirect_tab_fields(&$login_redirect_fields)
366 {
367 $login_redirect_fields[] = [
368 'id' => 'user_types',
369 'type' => 'button_set',
370 'title' => __('User Types', 'adminify'),
371 'placeholder' => __('Select User Types', 'adminify'),
372 'options' => array(
373 'user_role' => __('User Role', 'adminify'),
374 'user_name' => __('User Name', 'adminify'),
375 'user_cap' => __('User Capability', 'adminify'),
376 ),
377 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['login_redirects']['user_types'],
378 ];
379
380 // Select User Names
381 $login_redirect_fields[] = [
382 'id' => 'redirect_user',
383 'type' => 'select',
384 'title' => __('User', 'adminify'),
385 'placeholder' => __('Select a user', 'adminify'),
386 'options' => 'users',
387 'dependency' => ['user_types', '==', 'user_name'],
388 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['login_redirects']['redirect_user'],
389 ];
390
391 // Select User Roles
392 $login_redirect_fields[] = [
393 'id' => 'redirect_role',
394 'type' => 'select',
395 'title' => __('Role', 'adminify'),
396 'placeholder' => __('Select a Role', 'adminify'),
397 'options' => 'roles',
398 'dependency' => ['user_types', '==', 'user_role'],
399 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['login_redirects']['redirect_role'],
400 ];
401
402 // Select User Capability
403 $login_redirect_fields[] = [
404 'id' => 'redirect_cap',
405 'type' => 'select',
406 'title' => __('Capability', 'adminify'),
407 'placeholder' => __('Select a Capability', 'adminify'),
408 'options' => '\WPAdminify\Inc\Classes\Helper::get_capability_options',
409 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['login_redirects']['redirect_cap'],
410 'dependency' => ['user_types', '==', 'user_cap'],
411 ];
412
413
414 // Redirect URL
415 $login_redirect_fields[] = [
416 'id' => 'redirect_url',
417 'type' => 'text',
418 'class' => 'new-login-url',
419 'title' => __('Redirect URL', 'adminify'),
420 // 'before' => \get_site_url() . '/',
421 'desc' => __('Note: Full URL here. Change the URL for a User or User Roles.', 'adminify'),
422 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['login_redirects']['redirect_url'],
423 ];
424
425 // // Redirect Order
426 // $login_redirect_fields[] = [
427 // 'id' => 'redirect_order',
428 // 'type' => 'number',
429 // 'title' => __('Order', 'adminify'),
430 // 'default' => $this->get_default_field('redirect_urls_options')['login_redirects']['redirect_order'],
431 // ];
432 }
433
434
435
436
437 /**
438 * Logout Settings Fields
439 *
440 * @return void
441 */
442 public function logout_redirect_tab_fields(&$logout_redirect_fields)
443 {
444 $logout_redirect_fields[] = [
445 'id' => 'user_types',
446 'type' => 'button_set',
447 'title' => __('User Types', 'adminify'),
448 'placeholder' => __('Select User Types', 'adminify'),
449 'options' => array(
450 'user_role' => __('User Role', 'adminify'),
451 'user_name' => __('User Name', 'adminify'),
452 'user_cap' => __('User Capability', 'adminify'),
453 ),
454 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['logout_redirects']['user_types'],
455 ];
456
457 // Select User Names
458 $logout_redirect_fields[] = [
459 'id' => 'redirect_user',
460 'type' => 'select',
461 'title' => __('User', 'adminify'),
462 'placeholder' => __('Select a user', 'adminify'),
463 'options' => 'users',
464 'dependency' => ['user_types', '==', 'user_name'],
465 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['logout_redirects']['redirect_user'],
466 ];
467
468 // Select User Roles
469 $logout_redirect_fields[] = [
470 'id' => 'redirect_role',
471 'type' => 'select',
472 'title' => __('Role', 'adminify'),
473 'placeholder' => __('Select a Role', 'adminify'),
474 'options' => 'roles',
475 'dependency' => ['user_types', '==', 'user_role'],
476 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['logout_redirects']['redirect_role'],
477 ];
478
479 // Select User Capability
480 $logout_redirect_fields[] = [
481 'id' => 'redirect_cap',
482 'type' => 'select',
483 'title' => __('Capability', 'adminify'),
484 'placeholder' => __('Select a Capability', 'adminify'),
485 'options' => '\WPAdminify\Inc\Classes\Helper::get_capability_options',
486 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['logout_redirects']['redirect_cap'],
487 'dependency' => ['user_types', '==', 'user_cap'],
488 ];
489
490
491 // Redirect URL
492 $logout_redirect_fields[] = [
493 'id' => 'redirect_url',
494 'type' => 'text',
495 'class' => 'new-login-url',
496 'title' => __('Redirect URL', 'adminify'),
497 'before' => \get_site_url() . '/',
498 'desc' => __('Change the URL for a User or User Roles.', 'adminify'),
499 'default' => $this->get_default_field('redirect_urls_fields')['redirect_urls_options']['redirect_urls_tabs']['logout_redirects']['redirect_url'],
500 ];
501
502 // Redirect Order
503 // $logout_redirect_fields[] = [
504 // 'id' => 'redirect_order',
505 // 'type' => 'number',
506 // 'title' => __('Order', 'adminify'),
507 // 'default' => $this->get_default_field('redirect_urls_options')['logout_redirects']['redirect_order'],
508 // ];
509 }
510
511
512 /**
513 * Change Username Module
514 */
515 public function security_user_security(&$users){
516
517 $users_settings[] = [
518 'id' => 'change_username',
519 'type' => 'switcher',
520 'text_on' => __('Show', 'adminify'),
521 'text_off' => __('Hide', 'adminify'),
522 'text_width' => 80,
523 'title' => __('Username Change', 'adminify'),
524 'subtitle' => sprintf(__('Remove Comments for Media attachment Template <a href="%s">More Details</a> ', 'adminify'), esc_url('https://wpadminify.com/docs')),
525 'default' => $this->get_default_field('users_security')['change_username'],
526 ];
527 $users_settings[] = [
528 'id' => 'limit_logins',
529 'type' => 'switcher',
530 'text_on' => __('Show', 'adminify'),
531 'text_off' => __('Hide', 'adminify'),
532 'text_width' => 80,
533 'title' => __('Limit Login Attempts', 'adminify'),
534 'subtitle' => sprintf(__('Prevent brute force attacks by limiting the number of failed login attempts per IP address. <a href="%s">More Details</a> ', 'adminify'), esc_url('https://wpadminify.com/docs')),
535 'default' => $this->get_default_field('users_security')['limit_logins'],
536 ];
537
538 $users[] = array(
539 'id' => 'users_security',
540 'type' => 'fieldset',
541 'title' => __('Users Security', 'adminify'),
542 'subtitle' => __('Security for Users, Login/Logout etc.', 'adminify'),
543 'fields' => $users_settings,
544 'default' => $this->get_default_field('users_security'),
545 );
546 }
547
548 /**
549 * Security: WP JSON API's
550 *
551 * @param [type] $json_api_fields
552 *
553 * @return void
554 */
555 public function security_rest_api_fields( &$json_api_fieldset ) {
556
557 $json_api_fields_data = [
558 'rest_api' => __('Disable REST API', 'adminify'),
559 'powered' => __('Remove "X-Powered-By:..." from Server Response HTTP headers', 'adminify'),
560 ];
561
562 $json_api_fields = [
563 [
564 'id' => 'security_rest_api_enable',
565 'type' => 'switcher',
566 'class' => 'adminify-pl-0 adminify-pt-0',
567 'title' => __('', 'adminify'),
568 'text_on' => __('Show', 'adminify'),
569 'text_off' => __('Hide', 'adminify'),
570 'text_width' => 80,
571 'default' => $this->get_default_field('security_rest_api')['security_rest_api_enable'],
572 ],
573 [
574 'id' => 'security_rest_api_data',
575 'type' => 'checkbox',
576 'title' => __('', 'adminify'),
577 'class' => 'adminify-one-col',
578 'options' => $json_api_fields_data,
579 'default' => $this->get_default_field('security_rest_api')['security_rest_api_data'],
580 'dependency' => ['security_rest_api_enable', '==', 'true', true],
581 ]
582 ];
583
584 $json_api_fieldset[] = array(
585 'id' => 'security_rest_api',
586 'type' => 'fieldset',
587 'title' => __('REST API', 'adminify'),
588 'subtitle' => __('Disable REST API access for non-authenticated users and remove URL traces from &lt;head&gt;, HTTP headers and WP RSD endpoint.', 'adminify'),
589 'fields' => $json_api_fields,
590 'default' => $this->get_default_field('security_rest_api'),
591 );
592
593 }
594
595
596 /**
597 * Security: Post & Archives
598 */
599 public function security_archive_fields( &$archive_fields ) {
600 $archive_fields_data = [
601 'last_modified_date' => __('Display Last Post Updated Date', 'adminify' ),
602 'capital_p_dangit' => __('Remove Capital "P" Dangit', 'adminify' ),
603 'archives_date' => __('Redirect "Date Archives" Template to Homepage', 'adminify' ),
604 'archives_author' => __('Redirect "Author Archives" Template to Homepage', 'adminify' ),
605 'archives_tag' => __('Redirect "Tag Archives" Template to Homepage', 'adminify' ),
606 'archives_category' => __('Redirect "Category Archives" Template to Homepage', 'adminify' ),
607 'archives_postformat' => __('Redirect "Post Format Archives" Template to Homepage', 'adminify' ),
608 'archives_search' => __('Redirect "Search Template" to Homepage', 'adminify' ),
609 ];
610
611 $archive_fields[] = [
612 'id' => 'post_archives',
613 'title' => __('Post & Archives', 'adminify'),
614 'subtitle' => __('Redirect unused Archives pages to homepage', 'adminify'),
615 'type' => 'fieldset',
616 'fields' => [
617 [
618 'id' => 'post_archives_enable',
619 'type' => 'switcher',
620 'title' => __('', 'adminify'),
621 'text_on' => __('Show', 'adminify'),
622 'text_off' => __('Hide', 'adminify'),
623 'text_width' => 80,
624 'class' => 'adminify-pl-0 adminify-pt-0',
625 'default' => $this->get_default_field('post_archives')['post_archives_enable'],
626 ],
627 [
628 'id' => 'post_archives_data',
629 'type' => 'checkbox',
630 'class' => 'adminify-one-col',
631 'title' => __('', 'adminify'),
632 'options' => $archive_fields_data,
633 'default' => $this->get_default_field('post_archives')['post_archives_data'],
634 'dependency' => ['post_archives_enable', '==', 'true', true],
635 ],
636 ]
637 ];
638
639 }
640
641
642 /**
643 * Custom Gravatar Image
644 *
645 * @param [type] $fields
646 *
647 * @return void
648 */
649 public function security_custom_gravatar( &$gravatar_image ){
650
651 // Comments Avatar
652 $custom_gravatar_settings = [
653 [
654 'id' => 'enable',
655 'type' => 'switcher',
656 'title' => '',
657 'class' => 'adminify-pt-0 adminify-pl-0 adminify-col-fit',
658 'label' => sprintf(__('Add your Custom Gravatar Images for Comments. Select Avatar Image from <a href="%s">Settings>Discussion>Default Avatar</a>.', 'adminify'), esc_url(admin_url('options-discussion.php'))),
659 'text_on' => __('Yes', 'adminify'),
660 'text_off' => __('No', 'adminify'),
661 'text_width' => 80,
662 'default' => $this->get_default_field('enable'),
663 ],
664 [
665 'id' => 'image',
666 'type' => 'repeater',
667 'title' => __('Add Avatar Image', 'adminify'),
668 'fields' => [
669 [
670 'id' => 'avatar_image',
671 'type' => 'media',
672 'title' => __('Image', 'adminify'),
673 'library' => 'image',
674 ],
675 [
676 'id' => 'avatar_name',
677 'type' => 'text',
678 'title' => __('Name', 'adminify'),
679 ],
680 ],
681 'default' => $this->get_default_field('image'),
682 'dependency' => ['enable', '==', 'true'],
683 ]
684 ];
685
686 $gravatar_image[] = [
687 'id' => 'custom_gravatar',
688 'type' => 'fieldset',
689 'title' => __('Custom Gravatar Images', 'adminify'),
690 'fields' => $custom_gravatar_settings,
691 ];
692 }
693
694
695 /**
696 * Disable Comments
697 *
698 * @param [type] $fields
699 *
700 * @return void
701 */
702 public function security_others( &$fields ){
703 $fields[] = [
704 'id' => 'disable_automatic_emails',
705 'type' => 'switcher',
706 'class' => 'adminify-pro-fieldset adminify-pro-notice',
707 'title' => sprintf(__('Disable Automatic Updates Emails %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
708 'subtitle' => __('Stop getting emails about automatic updates on your WordPress site.', 'adminify'),
709 'text_on' => __('Yes', 'adminify'),
710 'text_off' => __('No', 'adminify'),
711 'text_width' => 80,
712 'default' => $this->get_default_field('disable_automatic_emails'),
713 ];
714
715 $fields[] = [
716 'id' => 'disable_language_switcher_login',
717 'type' => 'switcher',
718 'class' => 'adminify-pro-fieldset adminify-pro-notice',
719 'title' => sprintf(__('Disable Login Screen Language Switcher %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
720 'subtitle' => __('Hide the Language Switcher on the default WordPress login screen.', 'adminify'),
721 'text_on' => __('Yes', 'adminify'),
722 'text_off' => __('No', 'adminify'),
723 'text_width' => 80,
724 'default' => $this->get_default_field('disable_language_switcher_login'),
725 ];
726 }
727
728 /**
729 * Disable Comments
730 *
731 * @param [type] $fields
732 *
733 * @return void
734 */
735 public function security_disable_comments( &$fields ){
736
737 // Disable Comments
738 $disable_comments_for = [
739 'admin_bar' => __('Remove "Comments" from Admin Bar', 'adminify'),
740 'menu_redirect' => __('Admin Menu "Comments" Redirect to "wp-admin"', 'adminify'),
741 'admin_menu' => __('Remove Admin Menu "Comments"', 'adminify'),
742 'discussion_menu' => __('Remove Discussion Menu from "Settings>Discussion" Sub Menu', 'adminify'),
743 'close_front' => __('Close Comments from front-end', 'adminify'),
744 'comments_notes' => __('Remove "Your email address will not be published..." from comment form template', 'adminify'),
745 'comments_url_field' => __('Remove website Field (URL) from comment form template', 'adminify'),
746 'replace_author_link' => sprintf(__('Remove Link from comment "Author Name" & replace to JavaScript? %s'), Utils::adminify_upgrade_pro_class()),
747 'replace_comment_link' => sprintf(__('Comments Content disable auto linking, display comments links as plain text, replace Comment Links to JavaScript? %s', 'adminify'), Utils::adminify_upgrade_pro_class()),
748 'hide_existing' => sprintf(__('Hide Existing Comments from Frontend? %s', 'adminify'), Utils::adminify_upgrade_pro_class()),
749 ];
750
751 // check if WP_Widget_Recent_Comments is used
752 // $recentcomments = [];
753 if ( !is_active_widget(false, false, 'WP_Widget_Recent_Comments', true) ) {
754 $disable_comments_for['recentcomments'] = __('Remove Hardcoded ".recentcomments" CSS for default "Recent Comments" widget. i.e ', 'adminify');
755 $disable_comments_for = array_merge($disable_comments_for, $disable_comments_for);
756 }
757
758 $fields[] = [
759 'id' => 'disable_comments',
760 'title' => __('Disable Comments', 'adminify'),
761 'subtitle' => __('Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', 'adminify'),
762 'type' => 'fieldset',
763 'fields' => [
764 [
765 'id' => 'enable_disable_comments',
766 'type' => 'switcher',
767 'title' => __('', 'adminify'),
768 'class' => 'adminify-pl-0 adminify-pt-0',
769 'text_on' => __('Show', 'adminify'),
770 'text_off' => __('Hide', 'adminify'),
771 'text_width' => 80,
772 'default' => $this->get_default_field('disable_comments')['enable_disable_comments'],
773 ],
774 [
775 'id' => 'post_types',
776 'type' => 'checkbox',
777 'title' => __('for Post Types', 'adminify'),
778 'subtitle' => __('Check for enable Post Types', 'adminify'),
779 'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types',
780 'default' => $this->get_default_field('disable_comments')['post_types'],
781 'dependency' => ['enable_disable_comments', '==', 'true', true],
782 ],
783 // [
784 // 'id' => 'disable_comments_post_types',
785 // 'type' => 'notice',
786 // 'style' => 'warning',
787 // 'content' => Utils::adminify_upgrade_pro(),
788 // 'dependency' => [
789 // [ 'post_types', 'not-any', 'post,page', 'true' ],
790 // [ 'post_types', '!=', '', 'true' ],
791 // ],
792 // ],
793 [
794 'id' => 'apply_for',
795 'type' => 'checkbox',
796 'title' => __('', 'adminify'),
797 'class' => 'adminify-one-col',
798 'options' => $disable_comments_for,
799 'default' => $this->get_default_field('disable_comments')['apply_for'],
800 'dependency' => ['enable_disable_comments', '==', 'true', true],
801 ]
802 ]
803 ];
804 }
805
806
807 public function tweak_settings() {
808 if ( ! class_exists( 'ADMINIFY' ) ) {
809 return;
810 }
811
812
813 $fields = [];
814
815 $fields[] = [
816 'id' => 'security_subheading',
817 'type' => 'subheading',
818 'content' => Utils::adminfiy_help_urls(
819 __('"WordPress" White Label Settings', 'adminify'),
820 'https://wpadminify.com/docs/security/',
821 '',
822 'https://www.facebook.com/groups/jeweltheme',
823 \WPAdminify\Inc\Admin\AdminSettings::support_url()
824 )
825 ];
826
827 $this->security_redirect_urls( $fields );
828 // $this->security_user_security( $fields );
829 $this->security_head_fields( $fields );
830 $this->security_feed_fields( $fields );
831 $this->security_rest_api_fields( $fields );
832 $this->security_disable_comments( $fields );
833 $this->security_archive_fields( $fields );
834 // $this->security_others( $fields );
835
836 $this->security_custom_gravatar( $fields );
837
838 $fields = apply_filters('adminify_settings/security', $fields, $this);
839
840 // Tweaks Section
841 \ADMINIFY::createSection(
842 $this->prefix,
843 [
844 'title' => __( 'Security', 'adminify' ),
845 'id' => 'security',
846 'icon' => 'fas fa-shield-alt',
847 'fields' => $fields,
848 ]
849 );
850 }
851 }
852 }
853