In this shinding the gives a live demo of the phpcs (php code sniffer) and a discussion of several theme-check-tools.
Meeting with participants from the theme_review crew. The theme reviewers test whether submitted themes live up to the WordPress standards. If a new theme is accepted, it’s added to the WordPress repo. Then it’s available to millions of users.
Setting up the recommended theme review environment in Virtual Box on Linux Mint. The hardest part was setting up the PHP code sniffer. WordPress reviewers use several plugins for theme reviews.
Do you want to publish a theme on WordPress? In that case a team of reviewers will check the theme for errors. The code must follow the WordPress standards and policies. If the theme doesn’t meet the standards the theme is rejected.
- See: The Theme Review Process.
The theme review team recommended to test the themes on a virtual system. I installed Virtualbox via apt. Found and downloaded a Linux Mint .iso via Torrents. Booted the system and installed Linux on the virtual disk. So far so good.
The LAMP server
Set up a LAMP server via the Ubuntu meta-package:
sudo apt-get install lamp-server^
An then WordPress was installed manually. Noproblemo here.
Set up WordPress as Reviewer
Testing is a major subject in WordPress. Several tools are recommended:
- Theme Check
- Debug Bar
- Log Deprecated Notices
- Monster Widget
- WordPress Beta Tester
- Regenerate Thumbnails
Then the codesniffer was installed. My first experiments were more or less “trial and error”. If worked, but pretty it wasn’t (later I found Tom McFarlin’s excellent tutorial.).
This blog is a research tool. So I’m saving my fumblings with the code:
2011 pear 2013 sudo pear channel-update pear.php.net 2014 pear upgrade-all 2016 pear install wordpress 2018 sudo apt-get install composer 2019 composer create-project \ wp-coding-standards/wpcs:dev-master --no-dev 2020 phpcs --standard=WordPress wp-config.php 2021 phpcs --config-set installed_paths wpcs 2022 sudo phpcs --config-set installed_paths wpcs 2023 phpcs -i 2024 phpcs --standard=WordPress /foo/bar.php
Lo and behold: the sniffer worked. Via wildcards it’s possible to scan all files in the theme directory:
phpcs --standard=WordPress pathToTheme/*/*.php
The sniffer will print errors and warnings – and so the debugging process may begin. Here’s a sample:
Note the wildcard result. Several files are checked. Errors and linenumbers are displayed. That’s a handy tool.
Avoid “Pig Latin”
In a package of test tools I found the pig latin. Don’t use that silly plug in. It will redesign your Dashboard and add all kinds of silly pig latin words all over the plugin. Joke or not – it’s a complete waste of time.
Theme Testing Environment Ready
Now the virtual theme testing environment is up and running. If there are grave errors in the theme, no damage will come to the test pc.
The next step is a real life theme review.
Entered the theme review theme on make.wordpress.org. Today a lot of software was installed:
- Virtualbox (for a linux sandbox for WordPress)
- Installed the recommended bugtragging plugins in the sandbox.
Then I read the extensive documentation on coding standards, and the things a theme reviewer should look at.
The codesniffer gave some problems. The recipe found here worked. The documentation in a zip-file on Slack missed many practical details. And so did the page on Github with the codesniffer code.
First phpcs was installed via apt-get. The next steps are contained in this shell history dump:
2010 phpcs --standard=WordPress wp-config.php 2011 pear 2012 phpcs --standard=WordPress wp-config.php 2013 sudo pear channel-update pear.php.net 2014 pear upgrade-all 2015 phpcs --standard=WordPress wp-config.php 2016 pear install wordpress 2017 composer create-project wp-coding-standards/wpcs:dev-master --no-dev 2018 sudo apt-get install composer 2019 composer create-project wp-coding-standards/wpcs:dev-master --no-dev 2020 phpcs --standard=WordPress wp-config.php 2021 phpcs --config-set installed_paths wpcs 2022 sudo phpcs --config-set installed_paths wpcs 2023 phpcs -i 2024 phpcs --standard=WordPress wp-config.php
If you want to try the new version of WordPress the Beta Tester Plugin is a must. However, don’t run it on a production server! After all a tester isn’t stable.
So the project is launched on our webpage ( http://eaaa.dk ). For now the text is only available in danish. A very short resume:
The business needs people with solid WordPress knowledge. Many businesses use WordPress as their prime sales or communication channel – what kind of knowledge do you need in order to meet tomorrow’s challenges with WordPress?