Git Product home page Git Product logo

wp-debugging's Introduction

WP Debugging

A debugging/support plugin for WordPress.

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.

Default settings:

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.

The Settings page allows the user to set the following.

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.

The filter wp_debugging_add_constants allows the user to add constants to wp-config.php.

The filter returns an array where the key is the name of the constant and the value is an array of data containing the value as a string and a boolean to indicate whether or not the value should be passed without quotes.

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

The value option contains the constant's value as a string.

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.

Example:

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
);

This will create the following constants.

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

Development

PRs are welcome against the develop branch.

wp-debugging's People

Stargazers

Nawawi Jamili avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.