WordPress coding standards and Eclipse

If you are writing code for WordPress using Eclipse this post can help you to format your code in wp-style. This post is a simple how-to guide that helps you to integrate PHP Code Sniffer within eclipse.
All information about the WordPress coding standards are available on the codex here.

  • Download and install PHP_CodeSniffer plugin.
  • Download the WordPress Standard definition for Php_CodeSniffer package here.
  • Unpack the file and copy the folder “PHP_CodeSniffer_Standards_WordPress-0.0.1/WordPress” into [YOUR_ECLIPSE_DIRECTORY]/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20…/php/
  • Create a simple file called ruleset.xml with the following content
    <?xml version="1.0" encoding="UTF-8"?>
    <ruleset name="WordPress">
  •  change the visibility of the var $error to public in [YOUR_ECLIPSE_DIRECTORY]/eclipsePHP/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20…/php/
  • Configure the plugin on your prj following the instructions on this page.
  • Thats all. You can now validate files manually or automatically: http://www.phpsrc.org/projects/pti-php-codesniffer/wiki/

3 thoughts on “WordPress coding standards and Eclipse

  1. realloc

    I just tried that. May be you already had this problem or you have an idea how to deal with array-items like ‘posts_per_page’ => -1? I got a message like … ERROR | Expected 1 space after “-“; 0 found …

    1. Danilo Post author

      @realloc – I guess we should modify the checking rules defined within the WordPress Standard definition for Php_CodeSniffer. A simple and fast workaround is the following:
      ‘posts_per_page’ => (-1)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s