PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.6
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.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.2.6, at Inc/Admin/Options/Security.php

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