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

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