PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/better-wp-security/core/modules/wordpress-tweaks/settings-page.php

https://gitlab.com/najomie/fit-hippie
PHP | 162 lines | 145 code | 17 blank | 0 comment | 5 complexity | 246d4a2b8dda27510281493e5288a057 MD5 | raw file
  1. <?php
  2. final class ITSEC_WordPress_Tweaks_Settings_Page extends ITSEC_Module_Settings_Page {
  3. public function __construct() {
  4. $this->id = 'wordpress-tweaks';
  5. $this->title = __( 'WordPress Tweaks', 'better-wp-security' );
  6. $this->description = __( 'Advanced settings that improve security by changing default WordPress behavior.', 'better-wp-security' );
  7. $this->type = 'recommended';
  8. parent::__construct();
  9. }
  10. protected function render_description( $form ) {
  11. ?>
  12. <p><?php esc_html_e( 'These are advanced settings that may be utilized to further strengthen the security of your WordPress site.', 'better-wp-security' ); ?></p>
  13. <?php
  14. }
  15. protected function render_settings( $form ) {
  16. $settings = $form->get_options();
  17. $xmlrpc_options = array(
  18. '2' => __( 'Disable XML-RPC (recommended)', 'better-wp-security' ),
  19. '1' => __( 'Disable Pingbacks', 'better-wp-security' ),
  20. '0' => __( 'Enable XML-RPC', 'better-wp-security' ),
  21. );
  22. $allow_xmlrpc_multiauth_options = array(
  23. false => __( 'Block (recommended)', 'better-wp-security' ),
  24. true => __( 'Allow', 'better-wp-security' ),
  25. );
  26. $jquery_version = ITSEC_Modules::get_setting( $this->id, 'jquery_version' );
  27. $jquery_version_is_safe = ITSEC_Lib::is_jquery_version_safe();
  28. if ( empty( $jquery_version ) ) {
  29. $jquery_description = sprintf( __( 'Your current jQuery version is undetermined. Please <a href="%1$s" target="_blank" rel="noopener noreferrer">check your homepage</a> to see if you even need this feature' ), site_url() );
  30. } else {
  31. $jquery_description = sprintf( __( 'Your current jQuery version is %1$s' ), $jquery_version );
  32. }
  33. if ( $jquery_version_is_safe ) {
  34. $jquery_description_color = 'green';
  35. } else {
  36. $jquery_description_color = 'red';
  37. }
  38. ?>
  39. <p><?php esc_html_e( 'Note: These settings are listed as advanced because they block common forms of attacks but they can also block legitimate plugins and themes that rely on the same techniques. When activating the settings below, we recommend enabling them one by one to test that everything on your site is still working as expected.', 'better-wp-security' ); ?></p>
  40. <p><?php esc_html_e( 'Remember, some of these settings might conflict with other plugins or themes, so test your site after enabling each setting.', 'better-wp-security' ); ?></p>
  41. <table class="form-table">
  42. <tr>
  43. <th scope="row"><label for="itsec-wordpress-tweaks-wlwmanifest_header"><?php esc_html_e( 'Windows Live Writer Header', 'better-wp-security' ); ?></label></th>
  44. <td>
  45. <?php $form->add_checkbox( 'wlwmanifest_header' ); ?>
  46. <label for="itsec-wordpress-tweaks-wlwmanifest_header"><?php esc_html_e( 'Remove the Windows Live Writer header.', 'better-wp-security' ); ?></label>
  47. <p class="description"><?php esc_html_e( 'This is not needed if you do not use Windows Live Writer or other blogging clients that rely on this file.', 'better-wp-security' ); ?></p>
  48. </td>
  49. </tr>
  50. <tr>
  51. <th scope="row"><label for="itsec-wordpress-tweaks-edituri_header"><?php esc_html_e( 'EditURI Header', 'better-wp-security' ); ?></label></th>
  52. <td>
  53. <?php $form->add_checkbox( 'edituri_header' ); ?>
  54. <label for="itsec-wordpress-tweaks-edituri_header"><?php esc_html_e( 'Remove the RSD (Really Simple Discovery) header.', 'better-wp-security' ); ?></label>
  55. <p class="description"><?php esc_html_e( 'Removes the RSD (Really Simple Discovery) header. If you don\'t integrate your blog with external XML-RPC services such as Flickr then the "RSD" function is pretty much useless to you.', 'better-wp-security' ); ?></p>
  56. </td>
  57. </tr>
  58. <tr>
  59. <th scope="row"><label for="itsec-wordpress-tweaks-comment_spam"><?php esc_html_e( 'Comment Spam', 'better-wp-security' ); ?></label></th>
  60. <td>
  61. <?php $form->add_checkbox( 'comment_spam' ); ?>
  62. <label for="itsec-wordpress-tweaks-comment_spam"><?php esc_html_e( 'Reduce Comment Spam', 'better-wp-security' ); ?></label>
  63. <p class="description"><?php esc_html_e( 'This option will cut down on comment spam by denying comments from bots with no referrer or without a user-agent identified.', 'better-wp-security' ); ?></p>
  64. </td>
  65. </tr>
  66. <tr>
  67. <th scope="row"><label for="itsec-wordpress-tweaks-file_editor"><?php esc_html_e( 'File Editor', 'better-wp-security' ); ?></label></th>
  68. <td>
  69. <?php $form->add_checkbox( 'file_editor' ); ?>
  70. <label for="itsec-wordpress-tweaks-file_editor"><?php esc_html_e( 'Disable File Editor', 'better-wp-security' ); ?></label>
  71. <p class="description"><?php esc_html_e( 'Disables the file editor for plugins and themes requiring users to have access to the file system to modify files. Once activated you will need to manually edit theme and other files using a tool other than WordPress.', 'better-wp-security' ); ?></p>
  72. </td>
  73. </tr>
  74. <tr>
  75. <th scope="row"><label for="itsec-wordpress-tweaks-disable_xmlrpc"><?php esc_html_e( 'XML-RPC', 'better-wp-security' ); ?></label></th>
  76. <td>
  77. <p><?php printf( wp_kses( __( 'WordPress\' XML-RPC feature allows external services to access and modify content on the site. Common example of services that make use of XML-RPC are <a href="%1$s">the Jetpack plugin</a>, <a href="%2$s">the WordPress mobile app</a>, and <a href="%3$s">pingbacks</a>. If the site does not use a service that requires XML-RPC, select the "Disable XML-RPC" setting as disabling XML-RPC prevents attackers from using the feature to attack the site.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://jetpack.me/' ), esc_url( 'https://apps.wordpress.org/' ), esc_url( 'https://make.wordpress.org/support/user-manual/building-your-wordpress-community/trackbacks-and-pingbacks/#pingbacks' ) ); ?></p>
  78. <?php $form->add_select( 'disable_xmlrpc', $xmlrpc_options ); ?>
  79. <ul>
  80. <li><?php echo wp_kses( __( '<strong>Disable XML-RPC</strong> - XML-RPC is disabled on the site. This setting is highly recommended if Jetpack, the WordPress mobile app, pingbacks, and other services that use XML-RPC are not used.', 'better-wp-security' ), array( 'strong' => array() ) ); ?></li>
  81. <li><?php echo wp_kses( __( '<strong>Disable Pingbacks</strong> - Only disable pingbacks. Other XML-RPC features will work as normal. Select this setting if you require features such as Jetpack or the WordPress Mobile app.', 'better-wp-security' ), array( 'strong' => array() ) ); ?></li>
  82. <li><?php echo wp_kses( __( '<strong>Enable XML-RPC</strong> - XML-RPC is fully enabled and will function as normal. Use this setting only if the site must have unrestricted use of XML-RPC.', 'better-wp-security' ), array( 'strong' => array() ) ); ?></li>
  83. </ul>
  84. </td>
  85. </tr>
  86. <tr>
  87. <th scope="row"><label for="itsec-wordpress-tweaks-allow_xmlrpc_multiauth"><?php esc_html_e( 'Multiple Authentication Attempts per XML-RPC Request', 'better-wp-security' ); ?></label></th>
  88. <td>
  89. <p><?php esc_html_e( 'WordPress\' XML-RPC feature allows hundreds of username and password guesses per request. Use the recommended "Block" setting below to prevent attackers from exploiting this feature.', 'better-wp-security' ); ?></p>
  90. <?php $form->add_select( 'allow_xmlrpc_multiauth', $allow_xmlrpc_multiauth_options ); ?>
  91. <ul>
  92. <li><?php echo wp_kses( __( '<strong>Block</strong> - Blocks XML-RPC requests that contain multiple login attempts. This setting is highly recommended.', 'better-wp-security' ), array( 'strong' => array() ) ); ?></li>
  93. <li><?php echo wp_kses( __( '<strong>Allow</strong> - Allows XML-RPC requests that contain multiple login attempts. Only use this setting if a service requires it.', 'better-wp-security' ), array( 'strong' => array() ) ); ?></li>
  94. </ul>
  95. </td>
  96. </tr>
  97. <tr>
  98. <th scope="row"><label for="itsec-wordpress-tweaks-safe_jquery"><?php esc_html_e( 'Replace jQuery With a Safe Version', 'better-wp-security' ); ?></label></th>
  99. <td>
  100. <?php if ( $jquery_version_is_safe ) : ?>
  101. <?php $form->add_checkbox( 'safe_jquery' ); ?>
  102. <label for="itsec-wordpress-tweaks-safe_jquery"><?php esc_html_e( 'Enqueue a safe version of jQuery', 'better-wp-security' ); ?></label>
  103. <p class="description"><?php esc_html_e( 'Remove the existing jQuery version used and replace it with a safe version (the version that comes default with WordPress).', 'better-wp-security' ); ?></p>
  104. <?php endif; ?>
  105. <p class="description" style="color: <?php echo esc_attr( $jquery_description_color ); ?>"><?php echo $jquery_description; ?></p>
  106. <p class="description"><?php printf( wp_kses( __( 'Note that this only checks the homepage of your site and only for users who are logged in. This is done intentionally to save resources. If you think this is in error <a href="%s" target="_blank" rel="noopener noreferrer">click here to check again</a>. This will open your homepage in a new window allowing the plugin to determine the version of jQuery actually being used. You can then come back here and reload this page to see your version.', 'better-wp-security' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) ) ), site_url() ); ?></p>
  107. </td>
  108. </tr>
  109. <tr>
  110. <th scope="row"><label for="itsec-wordpress-tweaks-login_errors"><?php esc_html_e( 'Login Error Messages', 'better-wp-security' ); ?></label></th>
  111. <td>
  112. <?php $form->add_checkbox( 'login_errors' ); ?>
  113. <label for="itsec-wordpress-tweaks-login_errors"><?php esc_html_e( 'Disable login error messages', 'better-wp-security' ); ?></label>
  114. <p class="description"><?php esc_html_e( 'Prevents error messages from being displayed to a user upon a failed login attempt.', 'better-wp-security' ); ?></p>
  115. </td>
  116. </tr>
  117. <tr>
  118. <th scope="row"><label for="itsec-wordpress-tweaks-force_unique_nicename"><?php esc_html_e( 'Force Unique Nickname', 'better-wp-security' ); ?></label></th>
  119. <td>
  120. <?php $form->add_checkbox( 'force_unique_nicename' ); ?>
  121. <label for="itsec-wordpress-tweaks-force_unique_nicename"><?php esc_html_e( 'Force users to choose a unique nickname', 'better-wp-security' ); ?></label>
  122. <p class="description"><?php esc_html_e( 'This forces users to choose a unique nickname when updating their profile or creating a new account which prevents bots and attackers from easily harvesting user\'s login usernames from the code on author pages. Note this does not automatically update existing users as it will affect author feed urls if used.', 'better-wp-security' ); ?></p>
  123. </td>
  124. </tr>
  125. <tr>
  126. <th scope="row"><label for="itsec-wordpress-tweaks-disable_unused_author_pages"><?php esc_html_e( 'Disable Extra User Archives', 'better-wp-security' ); ?></label></th>
  127. <td>
  128. <?php $form->add_checkbox( 'disable_unused_author_pages' ); ?>
  129. <label for="itsec-wordpress-tweaks-disable_unused_author_pages"><?php esc_html_e( 'Disables a user\'s author page if their post count is 0.', 'better-wp-security' ); ?></label>
  130. <p class="description"><?php esc_html_e( 'This makes it harder for bots to determine usernames by disabling post archives for users that don\'t post to your site.', 'better-wp-security' ); ?></p>
  131. </td>
  132. </tr>
  133. <tr>
  134. <th scope="row"><label for="itsec-wordpress-tweaks-block_tabnapping"><?php esc_html_e( 'Protect Against Tabnapping', 'better-wp-security' ); ?></label></th>
  135. <td>
  136. <?php $form->add_checkbox( 'block_tabnapping' ); ?>
  137. <label for="itsec-wordpress-tweaks-block_tabnapping"><?php esc_html_e( 'Alter target="_blank" links to protect against tabnapping', 'better-wp-security' ); ?></label>
  138. <p class="description"><?php printf( wp_kses( __( 'Enabling this feature helps protect visitors to this site (including logged in users) from phishing attacks launched by a linked site. Details on tabnapping via target="_blank" links can be found in <a href="%s">this article</a>.', 'better-wp-security' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( 'https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/' ) ); ?></p>
  139. </td>
  140. </tr>
  141. </table>
  142. <?php
  143. }
  144. }
  145. new ITSEC_WordPress_Tweaks_Settings_Page();