Giter VIP home page Giter VIP logo

debug-this's Introduction

=== Debug This ===
Tags: debug, debugger, developer, query, queries, hooks, filters, print_r, var_dump
Contributors: wpchill,silkalns,misternifty,cdillon27,raldea89
Tested up to: 6.3
Requires at least: 5.2
Stable Tag: 0.6.4
Requires PHP: 5.6
License: GPLv3 or later

Peek under the hood with sixty debugging reports just one click away.

== Description ==

For admins, developers, and support staff, **Debug This** provides a ton of information about your WordPress installation, all from the front-end admin bar.

* *The current WP_Query object*
* Blog info and options
* Embed providers
* Files in rendered HTML (CSS, images, JavaScript)
* Filters and actions
* Images sizes
* Globals and constants
* Menus
* Object cache stats
* Plugins, must-use plugins, and dropins
* Rewrite rules
* Queries
* PHP and server information
* Post attachments
* Post types
* Scripts and styles enqueued
* Shortcodes
* Sidebars and widgets
* Taxonomies and terms
* Themes
* Users
* WP cron schedules and jobs
* WP debug log

**Debug This** helps you save time and effort when trying to figure out what's going on. Instead of hardcoding debug snippets or writing complex unit
tests for small functionality, you can simply bring to the surface what you need right from the admin bar.

For example, when viewing a single post, you can see:

* a list of post attachments,
* which menus and sidebars are being displayed,
* the post type, post fields, and meta data,
* the current query variables and query string,
* the rewrite rules applied,
* the author,
* the terms,
* and much more.

== Installation ==

1. Upload to your plugins folder, usually `wp-content/plugins/`
2. Activate the plugin on the plugin screen.
3. Navigate to the front-end of your website and hover over the 'Debug This' menu item in the admin bar.

== Frequently Asked Questions ==

**How do I use Debug This?**

1. Make sure the admin bar is enabled in your user profile.
2. Visit any page/post/archive on your website and you will see a Debug This menu item on the admin bar.

**What PHP version is this compatible with?**

We've tested on PHP >= 5.2.17

**Can I request new debug modes?**

Certainly! In order to keep the plugin lightweight and performant, requests that are too localized for the greater good may be refused. If that happens, I will gladly help you build your own debug mode.

**Can I alter the plugin or build my own debug modes?**

Yes! Visit the [Extend section](https://wordpress.org/plugins/debug-this/other_notes/) to find out how you can thoroughly extend Debug This for your own needs.

== Screenshots ==

1. The current query, for example.
2. Enhanced display when a Kint debugger plugin is installed (see Description).

== Extend ==

= Debug This Functions =

New debug modes can be created easily:

`
add_debug_extension(
	$mode,
	$menu_label,
	$description,
	$callback,
	$group = 'General'
);
`

**Example**

`
add_debug_extension(
	'actions',
	__('Actions', 'debug-this'),
	__('$wp_actions contains all active registered actions', 'debug-this'),
	'foo_callback',
	'Filters And Actions'
);
function foo_callback($buffer, $template){
	global $wp_actions;
	$debug = print_r($wp_actions, true);
	return $debug;
}
`

You can add links to the header of a debug mode page. Place this code within your debug callback function.

`add_debug_header_link('http://urltolink', 'Link Label');`


Extensions can be removed as well using `remove_debug_extension($mode);`


**No PRE Tags**

If you don't want your debug output to be enclosed in PRE tags, simply set the following in your extension:

`Debug_This::$no_pre = true;`

**Saved Queries and Execution Time**

Retrieve saved queries and execution time by using the following static properties:

* `Debug_This::$execution_time`
* `Debug_This::$queries` - SAVEQUERIES must defined as true

**URL Helpers**

* `Debug_This::get_current_debug_url()` - current URL with the debug query
* `Debug_This::get_escape_url()` - used for the debug escape link that links to original page URL

= WP Actions =

* `debug_this` - receives the $mode arg - outputs the debug code sent from the extension modes. The default action is set to priority 5. This allows you to prepend or append any output without conflict using less or greater priorities.

= WP Filters =

There are a few filters you can use to customize Debug This to your needs:

* `debug_this_template` - receives $template arg - Use your own template
* `debug_this_default_mode`  - receives $mode arg - Alters the mode for the parent DT admin bar button link.
* `debug_this_output` - receives $output, $mode args - Filter debug content before it's rendered

= JavaScript =

To access the built-in Debug This JS functionality, enqueue your custom script with the dependency set to `debug-this`. Your script will inherit a jQuery dependency.

**Object: debugThis**

* `debugThis.mode` - current mode
* `debugThis.defaultMode`
* `debugThis.template` - current included template
* `debugThis.queryVar` - the defined query string variable

**Functions:**

* `isDebug()`
* `getDebugMode()` - uses `isDebug()`

**Events:**

A jQuery `debug-this` event is fired from the footer. You can hook into this event with the following;
`
jQuery(document).bind('debug-this', function(event, debugThis){
	console.log(debugThis);
});
`

= Helper Functions =

There are three included functions to help you work with files.

* `debug_this_get_file_ownership($file)` - returns `array('name' => $name, 'group' => $group)`
* `debug_this_get_file_perms($file)` - returns string - Example: 0775
* `debug_this_convert_perms_to_rwx($perms)` - returns string - converts permission number to RWX format - Example: 0755 folder becomes drwxr-xr-x


== Changelog ==

= 0.6.4 - 07.01.2022 =
* Display bug fix
* Added: Sanitization and escapes

= 0.6.3 - October 10, 2019 =
* Translation file update

= 0.6.2 - September 12, 2019 =
* Translation ready

= 0.6.1 - June 19, 2018 =
* Fix bug with anonymous functions in Filters report.

= 0.6 - May 22, 2018 =
* Fix bug with static methods in Filters report.

= 0.5.2 - November 17, 2017 =
* Improve error handling.

= 0.5.1 - December 27, 2016 =
* Prevent conflict with Kint Debugger when Debug Bar is active.

= 0.5 - December 15, 2016 =
* Update for WordPress 4.4+
* Add error handling.
* Add mode for unserialized options.
* Add mode for active plugins.
* Add `<pre>` tags conditionally (not every mode).
* Compatible with Kint wrapper plugins.
* Compatible with custom error logs.
* Remove Bootstrap stylesheet.
* Update POT file.

= 0.4 - August 29, 2015 =
* Fix display of global array variables.
* Fix display of current template.
* Fix use of a deprecated function.

= 0.3.2 - April 17, 2015 =
* Improve SAVEQUERIES check.

= 0.3.1 - March 17, 2015 =
* Fix non-static method call. Thanks [Daniele "Mte90" Scasciafratte](https://wordpress.org/support/profile/mte90).
* Fix output for TwentyFifteen theme.
* Replace close button "X" with Dashicon.

= 0.3 =
* Added advanced remote fetch for buffer
* Added real saved queries and execution time from original URL - can now be accessed as static properties $queries and $execution_time
* Added `get_current_debug_url()` method - exposes current URL with debug query
* Added post-meta debug mode. Created new menu section for queried object
* Updated bloginfo mode to true bloginfo values
* Updated wp-debug mode with better logic
* Added functionality for adding header links to the debug mode screen via `add_debug_header_link($url, $label, $classes = '')`
* Added reset debug log functionality with debug header link for wp-debug mode

= 0.2.2 =
* Added backwards compatibility to 3.3.
* Added support for no pretty permalinks.

= 0.2.1 =
* Critical fix for PHP <= 5.2 Removed anonymous functions.
* Fixed undefined $debug notices for all versions.

= 0.02 =
* Added new debug modes: Apache modules, PHP loaded extensions, file permissions, php.ini, $_SERVER, and execution time.
* Added three functions for getting file ownership and permissions
	* `debug_this_get_file_ownership($file)`
	* `debug_this_get_file_perms($file)`
	* `debug_this_convert_perms_to_rwx($perms)`

= 0.01 =
* Debug This Creation

== Upgrade notice ==

debug-this's People

Contributors

cdillon avatar razvanaldea89 avatar teoalex avatar giucu91 avatar cristianraiber avatar andyluak avatar

Stargazers

Ramael Metatron avatar Marcel Köppen avatar

Watchers

James Cloos avatar David Gwyer avatar Jack Kitterhing avatar  avatar  avatar  avatar  avatar

debug-this's Issues

Temp admin accessto selected pages

Is your feature request related to a problem? Please describe.
Offer temp admin access to only a defined set of pages. Can be achieved by comparing URL query strings between requester and the defined URL paths.

Offer export functionality to singular CPT

Is your feature request related to a problem? Please describe.
Offer the export functionality to single CPT page. Useful when debugging content/settings for 3rd party support.

HTTP requests in docker local dev environment

I’m using Docker for my development environment. I have an use case where my code (php-fpm container) and my webserver (nginx container) are separated in two different containers.

The plugins is triggering HTTP requests (debug-this.php L: 199) where it’s using the host from the get_bloginfo() function.

$url = get_bloginfo( 'url' ) . '/' . $wp->request . "?$query_string";

Since my code and therefore the plugin resides in a separate container it cannot create requests to http://localhost/ because the webserver is in another container. In order to perform the request it would have to send these requests to: http://nginx:80 (the docker service name if its in the same network)

Is it possible to provide an environment variable to set a HOST ourselfs?
query-monitor for example also provides actions of env variables: https://querymonitor.com/docs/configuration-constants/

https://wordpress.org/support/topic/http-requests-in-docker-local-dev-environment/

Shortcode- Critical error

I need to troubleshoot a shortcode, but it gives me a critical error very quickly.

14:52:39 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 206573568 bytes) in /home1/friscoro/public_html/fishingreport/wp-content/plugins/debug-this/inc/extensions.php on line 350
[19-May-2021 14:53:02 UTC] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 174067712 bytes) in /home1/friscoro/public_html/fishingreport/wp-content/plugins/debug-this/inc/extensions.php on line 350

I’ve added a statement to my wp-config, but it didn’t help
define( 'WP_MAX_MEMORY_LIMIT' , '512M' );

If you press the top level “Debug This” button on the page preview, it gives you a page layout of all the elements. The shortcode I’m using does not show on that page at all even though I have 2 blocks with the same shortcode. A Shortcode block, and a Custom HTML block. Both just render the actual shortcode text on the preview page, but there is nothing when viewing it with Debug This.

https://wordpress.org/support/topic/shortcode-critical-error/

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.