VS Code highlighted all my wordpress function name

WordpressVisual Studio-CodeIntelephense

Wordpress Problem Overview


I am using PHP Intelephense(version 1.3.7) which is the latest version and my VS Code is up to date There was no problem before but a few days ago, it keeps on highlighted all my wordpress function name I tried to downgrade my PHP Intelephense but the situation still exist.. Any help will be appreciate

[enter image description here] 1

Wordpress Solutions


Solution 1 - Wordpress

You have to add "wordpress" to the intelephense.stubs array setting in your VS Code settings file. This array should probably also have many other stubs listed as well. For example: ("wordpress" is at the bottom)

//  VS Code settings.json
{
    // ... other settings here ...
    "intelephense.files.maxSize": 3000000,
    "intelephense.stubs": [
        "apache",
        "bcmath",
        "bz2",
        "calendar",
        "com_dotnet",
        "Core",
        "ctype",
        "curl",
        "date",
        "dba",
        "dom",
        "enchant",
        "exif",
        "FFI",
        "fileinfo",
        "filter",
        "fpm",
        "ftp",
        "gd",
        "gettext",
        "gmp",
        "hash",
        "iconv",
        "imap",
        "intl",
        "json",
        "ldap",
        "libxml",
        "mbstring",
        "meta",
        "mysqli",
        "oci8",
        "odbc",
        "openssl",
        "pcntl",
        "pcre",
        "PDO",
        "pdo_ibm",
        "pdo_mysql",
        "pdo_pgsql",
        "pdo_sqlite",
        "pgsql",
        "Phar",
        "posix",
        "pspell",
        "readline",
        "Reflection",
        "session",
        "shmop",
        "SimpleXML",
        "snmp",
        "soap",
        "sockets",
        "sodium",
        "SPL",
        "sqlite3",
        "standard",
        "superglobals",
        "sysvmsg",
        "sysvsem",
        "sysvshm",
        "tidy",
        "tokenizer",
        "xml",
        "xmlreader",
        "xmlrpc",
        "xmlwriter",
        "xsl",
        "Zend OPcache",
        "zip",
        "zlib",
        "wordpress"
    ]
}

You can also take a look at these github issues:

Solution 2 - Wordpress

The quick fix for this is simply to add WordPress to the Intelephense: Stubs list.

1: Press (Ctrl+Shift+X) to the extensions bar on the left and search for PHP Intelephense.

2: Click the settings icon of the extension and choose Extension Settings.

screenshot of extensions bar

3: Scroll down to the bottom to see the list of Stubs.

4: Click on Add Item and choose wordpress from the list.

screenshot of extensions settings menu

If the changes are not affected, try to close and reopen Vscode.

This will solve the issue with built-in WordPress Functions, However, it will not recognize any functions from installed plugins.

Solution 3 - Wordpress

Maybe I'm missing something, but I never have this problem, and I think the reason is just that I open my whole WordPress site directory in VS Code at once.

Are you opening only your theme directory?

If so it makes sense that these functions are missing since they aren't in the project.

Open the whole site and this should go away. You'll also get all your theme and plugin functions imported correctly.

Solution 4 - Wordpress

Adam allalou and drwatsoncode are right and they work but just a reminder, to be sure that the changes are effected, don't forget to close and open your VsCode editor again.

Solution 5 - Wordpress

you just need to add WordPress item to the Intelephense: Stubs from the extension setting.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCyberCatHKView Question on Stackoverflow
Solution 1 - WordpressdrwatsoncodeView Answer on Stackoverflow
Solution 2 - WordpressAdam A AllalouView Answer on Stackoverflow
Solution 3 - WordpressjerclarkeView Answer on Stackoverflow
Solution 4 - WordpressjovialcoreView Answer on Stackoverflow
Solution 5 - WordpressjsinaView Answer on Stackoverflow