Theme Sniffer

Theme Sniffer is a plugin utilizing custom sniffs for PHP_CodeSniffer that statically analyzes your theme and ensures that it adheres to WordPress coding conventions, as well as checking your code against PHP version compatibility.

The plugin is available from the plugin directory and Github.

Themes are not required to pass the Theme Sniffer scan without warnings or errors to be included in the theme directory.

Usage Usage

-If you download the plugin from Github, make sure that you select the
distribution plugin zip linked from the documentation. Cloning or downloading the zip file that Github provides will not work.

Install the plugin.

Select the Theme Sniffer menu:

An image describing the Theme Sniffer menu item, available below the Settings menu item.

On the plugin page, you will find the following options:

Select theme: A list of installed themes. The active theme is selected by default.

Theme prefixes: Optional.
Add a list of permitted prefixes to check if all functions and global variables are prefixed correctly. Use one or multiple prefixes, separated by comma – e.g. twentyseventeen,twentysixteen,myprefix.

Select Standard:

Options:

  • Hide Warning: Select this option to hide the warnings and only include errors in the report.
  • Raw Output: Select this option if you prefer to use the PHPCS formatting in the report.
  • Ignore annotations: Select this option to ignore comments that might disable the sniff, for example phpcs:ignore.
  • Check only PHP files. Select this option to prevent any possible memory leaks from sniffing CSS and JS files.
  • Minimum PHP Version: Select between: 5.2  5.3  5.4  5.5  5.6  7.0  7.1  7.2  7.3.

After selecting your options, select GO to start sniffing. If you need to stop the sniff before it has completed, select STOP.

Report Report

When the report is generated the results are organized file by file with line number, type, and description.

It is important to remember that:

  • Not all errors are required to be fixed by the Theme Review requirements for including a theme in the directory.
  • All warnings need to be manually checked, for example the escaping.
An image describing how the warnings are presented file by file, with the data in tables.
The table contains the line number, the type of error or warning, and a description.

Using the report in a theme review Using the report in a theme review

When sharing the report, you can copy and paste it directly into the Trac ticket.

Explain to the author where the report is generated from, where they can download the plugin, and what they are required to fix.

Do not include a list of errors and warnings only, check them manually and request the author to fix actual errors that you find during the manual check.

Top ↑

Development Development

For information about how to contribute to the plugin, see https://github.com/WPTRT/theme-sniffer#development

For information about how to contribute to the WPThemeReview Coding standards, see https://github.com/WPTRT/WPThemeReview/blob/develop/.github/CONTRIBUTING.md

Top ↑

Reporting issues Reporting issues

Please report issues on Github.