GithubHelp home page GithubHelp logo

wptt / wpthemereview Goto Github PK

View Code? Open in Web Editor NEW
208.0 25.0 44.0 2.87 MB

PHP_CodeSniffer rules (sniffs) to enforce WordPress theme review coding conventions

License: MIT License

PHP 99.92% CSS 0.05% JavaScript 0.02% HTML 0.01%
wordpress coding-standards wordpress-theme

wpthemereview's Introduction

Latest Version Last Commit to Unstable CS Build Status Test Build Status

Minimum PHP Version License: MIT Number of Contributors

WPThemeReview Standard for PHP_CodeSniffer

Introduction

WordPress Themes for which a hosting application has been made for the theme to be hosted in the theme repository on wordpress.org have to comply with a set of requirements before such an application can be approved. Additionally, there are also recommendations for best practices for themes.

This project attempts to automate the code analysis part of the Theme Review Process as much as possible using static code analysis.

PHP_CodeSniffer is the base tool upon which this project is build and is a PHP command-line tool.

This project is a work in progress and passing the checks is no guarantee that your theme will be approved.

Requirements

The WPThemeReview Standard requires:

Installation

The only supported installation method is via Composer.

  1. Make sure you have PHP installed on your system.
  2. If not installed yet, install Composer.

Installing WPThemeReview globally

If you would like to have the WPThemeReview standard available to all projects on your system, you can install it in a central location.

From the command-line, run the following command:

$ php composer.phar global require wptrt/wpthemereview dealerdirect/phpcodesniffer-composer-installer

Installing WPThemeReview as a project dependency

If you use Composer to manage dependencies from your project anyway or are considering using it, you can also choose to install the WPThemeReview standard for an individual project.

From the command-line, run the following command from the root directory of your project:

$ php composer.phar require --dev wptrt/wpthemereview:* dealerdirect/phpcodesniffer-composer-installer:^0.7

Note:

  • The --dev means that WPThemeReview will be installed as a development requirement, not as a requirement for using the Theme.
  • The second package - dealerdirect/phpcodesniffer-composer-installer -, is a Composer plugin which will automatically sort out that PHP_CodeSniffer recognizes the WPThemeReview standard and the various WordPress standards.

Checking your installation was successful

# For a global install:
$ phpcs -i

# For a project install:
$ vendor/bin/phpcs -i

If everything went well, the output should look something like this:

The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, PHPCompatibility,
PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP,
WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and WPThemeReview

Using the WPThemeReview standard

You can now test your theme code against the WPThemeReview standard by running the following command from the root directory of your theme:

# For a global install:
$ phpcs -p . --standard=WPThemeReview

# For a project install:
$ vendor/bin/phpcs -p . --standard=WPThemeReview

If any issues are found, PHP_CodeSniffer will display a report with all the errors (must fix) and warnings (recommended to fix) for each file.

More information about running PHP_CodeSniffer can be found in the PHP_CodeSniffer Wiki.

Contributing

See CONTRIBUTING, including information about unit testing the standard.

License

See LICENSE (MIT).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.