Since WordPress appeared in 2003 a lot has changed. But not only in a core, but also in the additional software. Plugins and themes that allow users to realize any ideas have appeared - one may create forum, shop, blog, social network and even more in WordPress.
During these 12 years of WP functioning one more branch was developing - tools for developing and debugging WordPress code. They make the platform even more convenient and attractive not only for the end users but also for any WordPress developer.
Tools, mentioned in this post will save you hours, or even days of work, help to understand the code better, and create safe sites, apps, themes and plugins. After some time spent and debugging it’s possible to speed up the code and, correspondingly, the page loading time.
1. Debug Bar plugins pack
Debug Bar plugin allows to look under the hood of the site and see what’s going on while page opening and more. Probably, the most important task of the plugin is the help to search for the slow ‘knots’ on the site. They can be SQL-queries, events and filters.
After uploading the plugin and addons you’ll be able to see lots of useful information:
- Performed queries to the database and their time of execution.
- Events and filters, list of handlers (callbacks), general time of execution and the number of requests (Debug Bar Show Actions).
- Content of WP Query.
- Rewrite Rule, used while the request execution and the request itself (Request and Query String).
- Statistics of objects caching.
- Content of transient cache (Debug Bar Transients).
- Amount of memory used, PHP and MySQL versions.
- Planned Cron-tasks (Debug Bar Cron).
With the help of Debug Bar Console you may execute the random PHP-code or SQL-requests after the WordPress loading. That is very useful in case you need to see how anything works without any side switching between the code editor and browser.
2. WP CLI
WordPress managing center from the terminal (command line). Probably everything you can do from WordPress admin bar is possible to repeat with the help of a commands in a terminal, what means it can be optimized by bash-script. There are some functions that are not available from the visual interface.
The full list of the commands is available on the official web site. There you may also find addons for lots of popular plugins (like Advanced Custom Fields, Jetpack). Let’s check some of the useful possibilities of this utility.
WordPress check after hacking or infectioning.
Command wp core verify-checksums
allows to check the integrity of the WordPress installation. It’s useful in case your code was affected by viruses or hacked. With its help you may check whether any of the core files were changed.
Work with mediafiles in WP-CLI
Sometimes you have to do the refresh of the site images. And instead of Regenerate Thumbnails plugin you may use the wp media regenerate command. Additional parameters allow to perform the operation for all files or only for a certain ones.
In case you’re moving to another CMS or want to add several tens of mediafiles to WordPress, you may use the wp media
import command. It allows to import all files from a specified directory or URL.
3. Core Control plugin
One more multifunctinal plugin to manage inner functions of WordPress Core. After activation you may find the plugin in Tools -> Core Control.
The module for Cron, instead of Debug Bar, allows not only to watch the queries, but also to execute them not waiting for the set time.
Filesystem module allows to manage transports, that are used for the core, plugins and themes update. Note, that you may set the transport using the FS_METHOD
constant in wp-config.php
or with the filesystem_method
filter.
HTTP Access and HTTP Access Logger modules are set to watch the work with HTTP-transports and requests sent from your site. In case you’re developing plugin that is connected with the explicit services, like Twitter or Facebook, both modules will be really useful.
Updates module adds options to disable automatic check for core, plugins and theme updates.
4. Query Monitor plugin
SQL-queries always take time. For example, if some functional of your site requests the list of all posts or pages with a certain value from the additional fields, and the database consists of tens of thousands publications, the SQL-query will be very slow. As a result, the pages may be generated on a server in a couple of seconds. Compare it to 250 milliseconds needed for the server to generate WordPress with a default theme and with no plugins.
Query Monitor plugin shows the requests to the database, execution speed and the function, performing the request. As in the Debug Bar here you may also see Rewrite Rule and WP_Query content, memory consumption, etc.
In a separate table there is a list of all events (and no filters) and the handlers queue for them. Sometimes, handlers may not wotk causing issues because of a wrong priority.
Small Conditionals table shows the conditional tags (functions like is_single
, is_404
, etc.) and highligts wit green those that gave true on the opened page.
5. XHProf and Xdebug
XHProf and Xdebug are tools for profiling and debugging PHP code. They allow to find the slow code parts, watch the content of the variables instead of using var_dump()
, var_export()
or print_r()
.
6. Log Deprecated Notices
Log Deprecated Notices plugin takes stock of usage of old files, functions and arguments in WordPress. In case old functions or wrong arguments are called, the plugin will try to tell you how to fix the situation and suggest alternative function.
7. Theme Check and Plugin Check plugins
Theme Check and Plugin Check plugins automatically test themes and plugins for WordPress standards correspondence. When they find mistakes, they inform you about what is wrong, show you the line with the problem and give pieces of advice on how to fix it and useful links.
These plugins are required in case you’re going to publish your theme or plugin on WordPress.org.
8. Rewrite Rules Inspector
Rules to recognize pretty links in WordPress are saved in one of the options of wp_options
table, and are a set of regular expressions. In case you’re developing a plugin that adds additional types of publications, taxonomy or just works with links, the Rewrite Rules Inspector will let you to understand what rules (patterns) are already set and where in a queue will be yours.
In the Match URL field you may check the URL, and see what patterns does it suit. Flush Rules button starts the regeneration process, and Download exports everything to the TXT-file in PHP array form.
9. Log Viewer
With Log Viewer you may view any log files via WordPress admin interface. You have to be the admin (or superadmin for multisite) for the proper performance of the plugin. DISALLOW_FILE_EDIT
constant must be turned off (set its value to false
or don’t set any at all). Besides, it’s also convenient to watch log files via Console system application included to OS X.
10. User Switching
To switch the accounts with different rights you don’t have to open lots of browsers while web developing. User Switching plugin adds switching link to the user page and in one click you’ll be able to see the site from another account. You may get back also from the menubar of WordPress.
11. Monster Widget
After Monster Widget plugin activation you’ll see a new widget called Monster in a widgets list. It includes displaying all widgets available in WordPress core at once. So you won’t have to place widgets into different sidebars manually while developing a new theme.
12. Regenerate Thumbnails
Regenerate Thumbnails plugin allows to regenerate the images thumbnails from WordPress media library. And instead of WP CLI, you may do that via visual interface.
13. WordPress Beta Tester
If the working capacity is of a great importance for you and the downtime is unacceptable, we’d recommend you to test the plugins and themes for a development copies before every core updates. WordPress Beta Tester plugin allows you to install beta-versions of WordPress and test the compatibility of the plugins and themes with the new version before it’s officially released.
Conclusion
All the plugins and addons listed in the post are useful tools that help to save time, understand the processes and find the vulnerabilities and slow code parts. You have to understand that most of these tools you can use only on the test sites. Many of them lessen the productivity and may cause safety damages. You may find the manuals and instructions on the plugins pages on WordPress.org website.
What tools do you use while web development and customization? Maybe you can suggest any other useful plugins? Feel free to share your thoughts in comments.
These materials were used during preparing this post: Thoriq Firdaus post in Hongikat and Wpmag post by Kolya Korobochkin.