Supports development with the Zukit framework and implements various debugging methods and other service functions for WordPress.
Unfortunately, when developing in PHP for WordPress, it is not always possible to use the debugger and therefore the only way to find errors and debug is logging. In this plugin, I have collected my practices on various logging and debugging methods. Debug information can be output to a log file or displayed in Query Monitor if it is installed. There is also support for a powerful PHP debugging helper - Kint, which allows you to compactly display information in a structured way.
🎃 In addition, I usually add various service solutions to this plugin that are needed when creating a site or copying it from a template.
- Output of logs using Kint
- Output of logs to Query Monitor
- Output of debug info about the menu and submenu of Wordpress
- Support for logging on the front-end
- Management of the location of the log file and automatic overwriting
- Displays summary information about the Zukit framework and all themes and plugins using it in this instance
- Duplicate WordPress menu
- Duplicate Wordpress Posts, Pages and Custom Posts
- Upload the
zu-plus
folder to the/wp-content/plugins/
directory. - Activate the plugin using the
Plugins
menu in your WordPress admin panel. - You can adjust the necessary settings using your WordPress admin panel in
Settings > Zu+
.
In order to take advantage of the logging capabilities implemented in this plugin, you need to use one of the functions:
- zu_log(
...$params
) - zu_logc(
$context
,...$params
) - zu_log_if(
$condition
,...$params
) - zu_log_location(
$path
,$priority = 1
)
If you are using the Zukit framework, you can use the internal methods of your class - log
and logc
. This has its advantages and disadvantages. You will get additional information about the instance in which class your method was called, but you will lose the name of the variable passed to the function (only when using Kint).
- log(
...$params
) - logc(
$context
,...$params
)
The zu_log
function logs any number of arguments passed to it. The function zu_logc
differs from it only in that the first parameter is a string (context
) that will be displayed before the data. The context string can have modifiers. If the first character of the string is !
, ?
or *
then, this will change the color of the context line to red
, orange
or green
, respectively (when outputting to the Query Monitor).
The zu_log_location
function can be used to change the location of the log file. Moreover, if the $priority
argument is less than the current priority, then the file location will not change (sometimes useful when debugging several interacting plugins or modules). You can pass the magic constant __FILE__
to set the path of the log file in the same directory.
zu_log_location(__FILE__, 5);
zu_log($post, $title, $data['input']);
zu_logc('!Something went wrong', $_GET);
zu_log_if(isset($post), $post->ID);