PluginProbe
WP Debugging / 2.11.4
WP Debugging v2.11.4
2.12.6 2.12.5 trunk 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.11.10 2.11.11 2.11.12 2.11.13 2.11.14 2.11.15 2.11.16 2.11.17 2.11.18 2.11.19 2.11.2 2.11.20 2.11.21 2.11.22 2.11.23 2.11.24 2.11.3 All 59 releases
← All changes | src/Settings.php +17 -9 2.11.182.11.4 View file →
@@ -46,8 +46,15 @@
46 46 */
47 47 protected static $config_args;
48 48
49 49 /**
50 + * Holds nonce.
51 + *
52 + * @var $nonce
53 + */
54 + protected static $nonce;
55 +
56 + /**
50 57 * Constructor.
51 58 *
52 59 * @param array $options Plugin options.
53 60 * @param string $config_path Path to config file.
@@ -58,11 +65,12 @@
58 65 self::$options = $options;
59 66 self::$config_path = $config_path;
60 67 $this->defined_constants = $defined_constants;
61 68 self::$config_args = [ 'normalize' => true ];
69 + static::$nonce = wp_create_nonce( 'wp-debugging' );
62 70
63 71 if ( false === strpos( file_get_contents( self::$config_path ), "/* That's all, stop editing!" ) ) {
64 - if ( 1 === preg_match( '@\$table_prefix(.*;)@', file_get_contents( self::$config_path ), $matches ) ) {
72 + if ( 1 === preg_match( '@\$table_prefix = (.*);@', file_get_contents( self::$config_path ), $matches ) ) {
65 73 self::$config_args = array_merge(
66 74 self::$config_args,
67 75 [
68 76 'anchor' => "$matches[0]",
@@ -118,11 +126,9 @@
118 126 * @return void
119 127 */
120 128 public function update_settings() {
121 129 // Exit if improper privileges.
122 - if ( ! current_user_can( 'manage_options' )
123 - || ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_wpnonce'] ) ), 'wp_debugging-options' ) )
124 - ) {
130 + if ( ! current_user_can( 'manage_options' ) || ! wp_verify_nonce( static::$nonce, 'wp-debugging' ) ) {
125 131 return;
126 132 }
127 133
128 134 if ( isset( $_POST['option_page'] ) &&
@@ -258,16 +264,17 @@
258 264 * @return void
259 265 */
260 266 private function redirect_on_save() {
261 267 $update = false;
268 + if ( ! wp_verify_nonce( static::$nonce, 'wp-debugging' ) ) {
269 + return;
270 + }
262 271
263 - // phpcs:disable WordPress.Security.NonceVerification.Missing
264 272 if ( ( isset( $_POST['action'] ) && 'update' === $_POST['action'] ) &&
265 273 ( isset( $_POST['option_page'] ) && 'wp_debugging' === $_POST['option_page'] )
266 274 ) {
267 275 $update = true;
268 276 }
269 - // phpcs:enable
270 277
271 278 $redirect_url = is_multisite() ? network_admin_url( 'settings.php' ) : admin_url( 'tools.php' );
272 279
273 280 if ( $update ) {
@@ -288,9 +295,11 @@
288 295 *
289 296 * @return void
290 297 */
291 298 private function saved_settings_notice() {
292 - // phpcs:disable WordPress.Security.NonceVerification.Recommended
299 + if ( ! wp_verify_nonce( static::$nonce, 'wp-debugging' ) ) {
300 + return;
301 + }
293 302 if ( ( isset( $_GET['updated'] ) && '1' === $_GET['updated'] ) ||
294 303 ( isset( $_GET['settings-updated'] ) && '1' === $_GET['settings-updated'] )
295 304 ) {
296 305 echo '<div class="updated"><p>';
@@ -296,9 +305,8 @@
296 305 echo '<div class="updated"><p>';
297 306 esc_html_e( 'Saved.', 'wp-debugging' );
298 307 echo '</p></div>';
299 308 }
300 - // phpcs:enable
301 309 }
302 310
303 311 /**
304 312 * Register settings.
@@ -411,9 +419,9 @@
411 419 $action = is_multisite() ? 'edit.php?action=wp-debugging' : 'options.php'; ?>
412 420 <div class="wrap">
413 421 <h1><?php esc_html_e( 'WP Debugging', 'wp-debugging' ); ?></h1>
414 422 <div class="updated fade">
415 - <p><?php echo wp_kses_post( __( '<strong>Please note:</strong> Your <code>wp-config.php</code> file must be writable by the filesystem. Any errors will result in a PHP Exception being thrown. Debug constants as documented in <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a>.', 'wp-debugging' ) ); ?></p>
423 + <p><?php echo wp_kses_post( __( '<strong>Please note:</strong> Your <code>wp-config.php</code> file must be writable by the filesystem. Any errors will result in a PHP Exception being thrown. Debug constants per <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a>.', 'wp-debugging' ) ); ?></p>
416 424 </div>
417 425 <div>
418 426 <form method="post" action="<?php echo esc_attr( $action ); ?>">
419 427 <?php settings_fields( 'wp_debugging' ); ?>