How to Debug WordPress Plugin with 3 Top Priority WordPress Dev Tools
This plugin is created to facilitate the development, testing and debugging of the code on the WordPress and WooCommerce platform. Premmerce Dev Tools provide such tools as: WordPress debug, WordPress plugin boilerplate generator, WooCommerce product generator and WordPress data cleaner.
We have developed this plugin while we were testing the capabilities of WordPress for the developers. As we develop and maintain a large number of plugins and features, we will constantly improve our tools for the developers, release their new versions and will be happy to share them with you.
Meanwhile, we encourage you to take a look at our research on WordPress Development Environment and Developers Best Practices Review.
The main features of the plugin:
- Integration of symgony/var-dumper for WordPress debug.
- Integration of symfony/stopwatch for the execution time checking.
- WooCommerce product generator – Generating the test data for WooCommerce.
- WordPress plugin boilerplate generator, which creates the basic files structure.
- Database clean up.
You can install this plugin from the official WordPress plugin directory.
- Unzip the downloaded zip file.
- Upload the plugin folder into the ‘wp-content/plugins/’ directory of your WordPress site.
- Activate ‘DevTools’ from Plugins page.
See also: WooCommerce Tutorial Step by Step
Using symgony/var-dumper, you can easily debug the associative arrays and objects. For this, add the following lines to the code:
dump($var); – to output the value;
dd($var); – to output the value and end the script work.
Here is the result in the front:
For tracking the execution time and memory usage for certain parts of the code, the symfony/stopwatch library is integrated into the plugin.
WordPress plugin boilerplate generator
The WordPress plugin boilerplate generator creates the source files and folders of the plugin based on the boilerplate we developed:
- assets – images, css, js.
- languages – translations.
- src – source code.
- views – themes.
- BoilerplatePlugin – the main class of the plugin; the file name is generated from the plugin name.
- FilteManager.php – the file search within the plugin.
- Admin.php – the controller from the admin panel.
- Frontend.php – the controller from the front.
- composer.json – it is created when the plugin uses composer; in other cases, autoload.php is created.
- boilerplate.php – the plugin file with the plugin description, where the plugin’s code is being initialized.
- licence.txt – licence (GPL by default).
- readme.txt – readme example.
All the plugin classes are placed under its namespace, which allows you not to use the prefixes while naming classes, as they can be loaded automatically.
For the loading of the classes, the autoloader is being created in the autoload.php file. If the “Use composer” is ticked, the composer autoloader is being used, in case the plugin includes some libraries via composer.
WooCommerce product generator
The plugin allows you to quickly generate the test data for WooCommerce.
The following settings are available on the Generate data page:
- Products number – to set the number of the generated files;
- Generate product photo – to generate photo for every product;
- Product gallery photos number – to set the number of the generated photos for the product gallery;
- Product type – to choose the product type (Simple product, Grouped product, External/Affiliate product, Variable product);
- Categories number – to set the number of the generated categories; the products will be evenly distributed between them;
- Attributes number – to set the number of the product attributes, which will be generated and attached to all the products;
- Each attribute terms number – to set the number of values for every product attribute.
See also: WooCommerce SEO Guide
On the Clean up page you can quickly:
- delete all the products, product categories, product attributes from the database;
- delete the images that are not being used;
- clean up the database from the elements that are not being used: posts, terms, connections, metadata.
More features coming soon.
- Hyperlink management by Premmerce Filter Plugin for SEO improvement of WooCommerce stores
- The Showdown of WooCommerce vs Shopify: Which One Is Best For You and Why
- WordPress VIP: Benefits, Comparisons, Prices [Review 2020]
- How Does SalesZone Theme Comply with Premmerce Plugins
- Magento or WooCommerce: Choosing the Right eCommerce Platform for Your Store in 2019
- WordPress Development Environment and Developers’ Best Practices Review «
- How many products can WooCommerce handle? »