Slide 1

Slide 1 text

Leveraging the WordPress Coding Standards to Review Plugins and Themes

Slide 2

Slide 2 text

Hello! Juliette Reinders Folmer @jrf_nl @jrfnl

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

Slide 5

Slide 5 text

PHP CodeSniffer by

Slide 6

Slide 6 text

How It Works rulesets sniffs checks

Slide 7

Slide 7 text

Code Style Documentation Code Smells Code Metrics Best Practices Code Compatibility

Slide 8

Slide 8 text

Before you start: Basic checks Nikolay Bachiyski

Slide 9

Slide 9 text

Basic Checks  Uses GitHub ?   Uses PHPCS and/or other QA tools ?   Has (Unit) Tests ? 

Slide 10

Slide 10 text

Reviewing with PHP CodeSniffer Nikolay Bachiyski

Slide 11

Slide 11 text

QA WP Projects PHP Compatibility Standard WordPress Coding Standards PHP Codesniffer PHP LOC Bonus:

Slide 12

Slide 12 text

https://github.com/jrfnl/QA-WP-Projects

Slide 13

Slide 13 text

PHP • http://php.net/download Composer • https://getcomposer.org/download/ QA-WP- Projects • https://github.com/jrfnl/QA-WP-Projects • Either download the latest release as a zip or clone using git • Run: composer install

Slide 14

Slide 14 text

Before Running the QA Test  Download a copy of the plugin/theme

Slide 15

Slide 15 text

Sizing up the codebase vendor/bin> phploc ./path/to/plugin-root/ --exclude=tests

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Before Running the QA Test  Download a copy of the plugin/theme  Check the PHP version of the deployment environment  Check Readme.txt for minimum supported WP version  Check main plugin/theme file for the text-domain Header: Text Domain: my-plugin  "Guess" the plugin/theme prefixes

Slide 19

Slide 19 text

Running the checks vendor/bin> phpcs ./path/to/plugin-root/ --standard=WP-QA-Basic --report-full --report-source --report-summary --basepath=./path/to/plugin-root/ --runtime-set testVersion 5.6- --runtime-set minimum_supported_wp_version 4.5 --ignore=./path/to/plugin-root/tests/ --runtime-set text_domain plugin-slug --runtime-set prefixes plugin_prefix,plugin_acronym WP-QA-Strict

Slide 20

Slide 20 text

Interpreting the Results Nikolay Bachiyski

Slide 21

Slide 21 text

Dawn Armfield Dangerous Code

Slide 22

Slide 22 text

pelican Untestable Code

Slide 23

Slide 23 text

Outdated Code Benjamin Earwicker

Slide 24

Slide 24 text

Ashim D'Silva Messy Code

Slide 25

Slide 25 text

Incompatible Code – PHP

Slide 26

Slide 26 text

Jenn Vargas Incompatible Code - WP

Slide 27

Slide 27 text

Play4smee Conflicting Code (Strict)

Slide 28

Slide 28 text

Lyn Belisle Potentially Insecure Code (Strict)

Slide 29

Slide 29 text

Vera Kratochvil Internationalization Issues (Strict)

Slide 30

Slide 30 text

Baydog64 Potentially Buggy Code (Strict)

Slide 31

Slide 31 text

jschumacher Sloppy Code (Strict)

Slide 32

Slide 32 text

StuartMiles

Slide 33

Slide 33 text

--ignore-annotations

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

https://github.com/ WordPress-Coding-Standards/ WordPress-Coding-Standards/ issues/1157 WPCS native support

Slide 36

Slide 36 text

Thanks! Any questions ? Slides: https://speakerdeck.com/jrf Code: https://github.com/jrfnl/ qa-wp-projects @jrf_nl @jrfnl @jrf