WP Debugging

Description

This plugin sets the following debug constants in wp-config.php on plugin activation and removes them on plugin deactivation. Any errors will result in a PHP Exception being thrown. Debug constants per Debugging in WordPress.

Réglages par défaut :

define( 'WP_DEBUG_LOG', true );
define( 'SCRIPT_DEBUG', true );
define( 'SAVEQUERIES', true );

 
@ini_set( ‘display_errors’, 1 ); is set when the plugin is active. WP_DEBUG is set to true when the plugin is first run, thereafter it can be turned off in the Settings.

La page des réglages autorise l’utilisateur ou l’utilisatrice à définir les éléments suivants.

define( 'WP_DEBUG', true ); // Default on initial plugin installation.
define( 'WP_DEBUG_DISPLAY', false ); // Default when not declared is true.
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); // WordPress 5.2 WSOD Override.

When the plugin is deactivated best efforts are made to re-add pre-existing constants to their former state. When the plugin is activated the default settings and any saved settings are restored.

This plugin uses the wp-cli/wp-config-transformer command for writing constants to wp-config.php.

Debug Quick Look from Andrew Norcross is included with this plugin to assist in reading the debug.log file. If you already have this plugin installed you should delete it when WP Debugging is not active.

Query Monitor and Debug Bar plugins are optional dependencies to aid in debugging and troubleshooting. The notice for installation will recur 45 days after being dismissed.

If you have a non-standard location for your wp-config.php file you can use the filter wp_debugging_config_path to return the file path for your installation.

Le filtre wp_debugging_add_constants autorise l’utilisateur ou l’utilisatrice à ajouter des constantes dans wp-config.php.

Le filtre renvoie un tableau où la clé est le nom de la constante et la valeur est un tableau de données contenant la valeur sous forme de chaine et un booléen pour indiquer si la valeur doit être passée sans guillemet.

$my_constants = [
    'my_test_constant' =>
    [
        'value' => 'abc123',
        'raw' => false,
    ],
    'another_test_constant' => [ 'value' => 'true' ],
];

L’option valeurcontient les valeurs de constantes comme une chaine.

The raw option means that instead of placing the value inside the config as a string it will become unquoted. The default is true. Set as false for non-boolean values.

Exemple :

add_filter(
    'wp_debugging_add_constants',
    function( $added_constants ) {
        $my_constants = [
            'my_test_constant'      => [
                'value' => '124xyz',
                'raw'   => false,
            ],
            'another_test_constant' => [ 'value' => 'true' ],
        ];
        return array_merge( $added_constants, $my_constants );
    },
    10,
    1
);

Cela créera les constantes suivantes.

define( 'MY_TEST_CONSTANT', '124xyz' );
define( 'ANOTHER_TEST_CONSTANT', true );

Development

PRs are welcome against the develop branch on GitHub.

Captures d’écran

  • Settings Screen

Avis

4 septembre 2021
Huge. I needed help with something and installed this, found the issue, resolved it, deleted the plugin. Love it. Thanks!
9 avril 2021
With this plugin it's at last possible to debug a remote site wihtout having access to the cpanel!
Lire les 11 avis

Contributeurs & développeurs

« WP Debugging » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.

Contributeurs

“WP Debugging” a été traduit dans 4 locales. Remerciez l’équipe de traduction pour ses contributions.

Traduisez « WP Debugging » dans votre langue.

Le développement vous intéresse ?

Parcourir le code, consulter le SVN dépôt, ou s’inscrire au journal de développement par RSS.

Journal

2.11.1 / 2021-09-24

  • init in plugins_loaded hook
  • composer update

2.11.0 / 2021-09-23

  • fix security issue for capabilities check, possible CSRF, and nonce checks.

2.10.2 / 2021-09-04

  • only use esc_attr_e for translating strings

2.10.1 / 2021-07-23

  • fix PHP Notice, Settings:line 68
  • update Debug Quick Look admin bar menu for mobile

2.10.0 / 2021-06-30

  • update Debug Quick Look to show menu on mobile

2.9.3 / 2021-06-22

  • update WPConfigTransformer to use alternate anchor if default not present
  • add @10up GitHub Actions for WordPress svn integration

2.9.1 / 2020-11-17

  • mise à jour de la bibliothèque wp-dependency-installer
  • mise à jour wp-cli/wp-config-transformer
  • comment out quote normalization in set_pre_activation_constants(), not sure why I did that but it can cause problems #10

2.9.0 / 2020-08-15

  • use try/catch around use of WPConfigTransformer object

2.8.0 / 2020-08-01

  • exit if called directly
  • NB: I have seen the WPConfigTransformer Exception error live. The issue seems to be that a file_get_contents() on the wp-config.php file path, at random times, returns an empty value. I’m done chasing this random error in wp-cli/wp-config-transformer. Modified version of wp-cli/wp-config-transformer present

2.7.2 / 2020-06-01

  • test wp-config.php everywhere, still occasional WSOD reports.

2.7.1 / 2020-5-15

  • return early if wp-config.php is empty before calling WPConfigTransformer

2.7.0 / 2020-04-30

  • start loading in init hook
  • run process_filter_constants() as chained method in Bootstrap

2.6.1 / 2020-03-28

  • move Settings action link to front
  • change test for wp-config.php file empty

2.6.0 / 2020-02-28

  • load autoloader in main file
  • update composer dependencies

2.5.8 / 2019-12-23

  • badly messed up check for empty wp-config.php

2.5.7 / 2019-12-20

  • check and exit early if wp-config.php is empty
  • return empty array for the above exit

2.5.6 / 2019-11-02

  • early exit if wp-config.php not set in specific functions

2.5.5 / 2019-09-17

  • update composer.json for wp-dependency-installer update, now requires at least PHP 5.6 for spread operator
  • composer update

2.5.4 / 2019-04-25

  • added check for writable wp-config.php, exit with notice if not found

2.5.3 / 2019-04-01

  • update Debug Quick Look to display error log file path

2.5.1 / 2019-04-01

  • updated version of wp-cli/wp-config-transformer

2.5.0 / 2019-03-25

  • added wp_debugging_add_constants filter for users to add their own constants

2.4.3 / 2019-03-09

  • missed an output escape

2.4.2 / 2019-02-26

  • add Domain Path header

2.4.1 / 2019-02-10

  • refactor set/restore pre-activation constants

2.4.0 / 2019-02-06

  • save pre-activation constants for re-installation on deactivation ( say that 5x fast )

2.3.0 / 2019-02-04

  • look for wp-config.php in directory above ABSPATH
  • add filter wp_debugging_config_path to set non-standard path to wp-config.php

2.2.0 / 2019-02-02 🏈

  • initial release on dot org

2.1.1 / 2019-02-01

  • only show WSOD bypass when appropriate
  • update dependencies

2.1.0 / 2019-01-26

  • update Debug Quick Look, minor CSS changes
  • Improve messaging
  • add setting for WP_DISABLE_FATAL_ERROR_HANDLER constant (WSOD)
  • add default setting of WP_DEBUG to true, can be changed

2.0.0 / 2019-01-18

  • total re-write
  • add settings page
  • use wp-cli/wp-config-transformer to change wp-config.php
  • include norcross/debug-quick-look as dependency via composer but use my fork
  • update POT via composer.json and wp-cli
  • add image assets