| @@ -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. |