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

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