Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm and WordPress project errors

I'm using PHPStorm while develop WordPress plugins (mainly for HTML/CSS/JS).

Each plugin is a separate PHPStorm project since I can have several goodies from using this way.

The issue is when working on a plugin, the WordPress functions like _e are marked as Warnings (yellow color) and the information PHPStorm gives is that

"Undefined function _e"

How can I configure PHPStorm that it understand the WordPress functions and do not shows that errors and autocomplete the functions without to have a big project wrapping the WordPress installation?

like image 644
Diosney Avatar asked Feb 16 '23 19:02

Diosney


1 Answers

You need to reference WordPress code in some way. Few possible approaches:

  1. Add as External Library -- perfect for referencing only: Settings | PHP | Include paths
  2. Add as part of the project itself (careful, as in this case WP code will be used during Search/Refactor/etc operations) -- Settings | Directories | Add Content Root
  3. Symbolic link somewhere in the project (but #2 is still better for your case)
like image 110
LazyOne Avatar answered Feb 23 '23 14:02

LazyOne