PluginProbe
WP Debugging / 2.9.2
WP Debugging v2.9.2
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 +25 -41 2.10.22.9.2 View file →
@@ -39,15 +39,8 @@
39 39 */
40 40 protected $defined_constants;
41 41
42 42 /**
43 - * Holds config args for WPConfigTransformer.
44 - *
45 - * @var array
46 - */
47 - protected static $config_args;
48 -
49 - /**
50 43 * Constructor.
51 44 *
52 45 * @param array $options Plugin options.
53 46 * @param string $config_path Path to config file.
@@ -57,21 +50,8 @@
57 50 public function __construct( $options, $config_path, $defined_constants ) {
58 51 self::$options = $options;
59 52 self::$config_path = $config_path;
60 53 $this->defined_constants = $defined_constants;
61 - self::$config_args = [ 'normalize' => true ];
62 -
63 - 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 ) ) {
65 - self::$config_args = array_merge(
66 - self::$config_args,
67 - [
68 - 'anchor' => "$matches[0]",
69 - 'placement' => 'after',
70 - ]
71 - );
72 - }
73 - }
74 54 }
75 55
76 56 /**
77 57 * Load hooks for settings.
@@ -128,9 +108,9 @@
128 108 ? wp_unslash( $_POST['wp-debugging'] )
129 109 : [];
130 110 // phpcs:enable
131 111
132 - $options = $this->sanitize( $options );
112 + $options = self::sanitize( $options );
133 113 $this->update_constants( self::$options, $options );
134 114 $filtered_options = array_filter(
135 115 self::$options,
136 116 function ( $e ) {
@@ -174,13 +154,16 @@
174 154 $added = [];
175 155 try {
176 156 $config_transformer = new \WPConfigTransformer( self::$config_path );
177 157 foreach ( $add as $constant => $config ) {
178 - $value = 'wp_debug_display' === $constant ? 'false' : 'true';
179 - $value = isset( $config['value'] ) ? $config['value'] : $value;
180 - $raw = isset( $config['raw'] ) ? $config['raw'] : true;
181 - self::$config_args = array_merge( self::$config_args, [ 'raw' => $raw ] );
182 - $config_transformer->update( 'constant', strtoupper( $constant ), $value, self::$config_args );
158 + $value = 'wp_debug_display' === $constant ? 'false' : 'true';
159 + $value = isset( $config['value'] ) ? $config['value'] : $value;
160 + $raw = isset( $config['raw'] ) ? $config['raw'] : true;
161 + $config_args = [
162 + 'raw' => $raw,
163 + 'normalize' => true,
164 + ];
165 + $config_transformer->update( 'constant', strtoupper( $constant ), $value, $config_args );
183 166 $added[ $constant ] = $value;
184 167 }
185 168
186 169 return $added;
@@ -341,20 +324,21 @@
341 324 'title' => esc_html__( 'Set WP_DEBUG_DISPLAY to false, default is true.', 'wp-debugging' ),
342 325 ]
343 326 );
344 327
345 - add_settings_field(
346 - 'wp_disable_fatal_error_handler',
347 - null,
348 - [ $this, 'checkbox_setting' ],
349 - 'wp_debugging',
350 - 'wp_debugging',
351 - [
352 - 'id' => 'wp_disable_fatal_error_handler',
353 - 'title' => esc_html__( 'Set WP_DISABLE_FATAL_ERROR_HANDLER to true.', 'wp-debugging' ),
354 - 'class' => version_compare( get_bloginfo( 'version' ), '5.2', '>=' ) ? '' : 'hidden',
355 - ]
356 - );
328 + if ( version_compare( get_bloginfo( 'version' ), '5.2-beta', '>=' ) ) {
329 + add_settings_field(
330 + 'wp_disable_fatal_error_handler',
331 + null,
332 + [ $this, 'checkbox_setting' ],
333 + 'wp_debugging',
334 + 'wp_debugging',
335 + [
336 + 'id' => 'wp_disable_fatal_error_handler',
337 + 'title' => esc_html__( 'Set WP_DISABLE_FATAL_ERROR_HANDLER to true.', 'wp-debugging' ),
338 + ]
339 + );
340 + }
357 341 }
358 342
359 343 /**
360 344 * Print settings section information.
@@ -413,9 +397,9 @@
413 397 <div class="updated fade">
414 398 <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>
415 399 </div>
416 400 <div>
417 - <form method="post" action="<?php echo esc_attr( $action ); ?>">
401 + <form method="post" action="<?php esc_attr_e( $action ); ?>">
418 402 <?php settings_fields( 'wp_debugging' ); ?>
419 403 <?php do_settings_sections( 'wp_debugging' ); ?>
420 404 <?php submit_button(); ?>
421 405 </form>
@@ -450,10 +434,10 @@
450 434 public function checkbox_setting( $args ) {
451 435 $checked = isset( self::$options[ $args['id'] ] ) ? self::$options[ $args['id'] ] : null;
452 436 ?>
453 437 <style> .form-table th { display:none; } </style>
454 - <label for="<?php echo esc_attr( $args['id'] ); ?>">
455 - <input type="checkbox" name="wp-debugging[<?php echo esc_attr( $args['id'] ); ?>]" value="1" <?php checked( '1', $checked ); ?> >
438 + <label for="<?php esc_attr_e( $args['id'] ); ?>">
439 + <input type="checkbox" name="wp-debugging[<?php esc_attr_e( $args['id'] ); ?>]" value="1" <?php checked( '1', $checked ); ?> >
456 440 <?php esc_html_e( $args['title'] ); ?>
457 441 </label>
458 442 <?php
459 443 }