Skip to content

wpcodefactory/wpfactory-coding-standards

Repository files navigation

WPFactory coding standards

A brief tutorial for getting WordPress coding standards in your WordPress project, adapted to WPFactory needs.

PHP coding standards installation

Note

If for some reason you get the error "PHPCSUtils" does not exist" please change these libraries on composer.json file:

    "squizlabs/php_codesniffer": "^3.7.1",
    "wp-coding-standards/wpcs": "^2.3.0"

Optional

  • Copy .github/workflows/php.yml to you project if you want to get coding standards reports from github on each push

✔️ Visual Studio Code

😎 Note: This setup allows to sniff the code and to reformat it automatically on file saving

✔️ Sublime Text 4

Access Preference > Package settings > SublimeLinter > Settings and config the linters node like this:

"linters": {
    "phpcs": {
        "disable": false,            
        "SublimeLinter.linters.phpcs.args": "--standard='${folder}/phpcs.xml'",            
        "executable": "${folder}/vendor/squizlabs/php_codesniffer/bin/phpcs.bat",
    },

😅 Note: This setup does not allow to fix code errors automatically on file saving yet, you can only sniff the code.

✔️ Notepad ++

  • Install NppExec plugin
  • Setup NppExec
  1. Access Plugins > NppExec > Execute, create this command and save it:
$(CURRENT_DIRECTORY)/vendor/squizlabs/php_codesniffer/bin/phpcbf.bat --standard=phpcs.xml $(FULL_CURRENT_PATH)
NPP_SENDMSG NPPM_RELOADFILE 0 "$(FULL_CURRENT_PATH)"
  1. Access Settings > Shortcuts mapper > Plugin commands
    • Find the saved command looking for the last line of NppExec.dll
    • Assign a shortcut to it (Probably Alt + Shift + F)
    • Be happy
  2. You might want to enable Settings > Preferences > Misc > Update silently

😅 Note: This setup does not allow to sniff the code, you can only reformat it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages