最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Can any IDE (eg PHPStorm, VS Code) correctly show functions added via require get_template_directory() strin

programmeradmin1浏览0评论

I would simply like to do some WordPress theme development using statements like

        require get_template_directory() . '/functions/base.php';

in my functions.php file. It seems IDEs do not know what to make of this function result and therefore do not map out [theme root]/functions/base.php as expected.

I would simply like to do some WordPress theme development using statements like

        require get_template_directory() . '/functions/base.php';

in my functions.php file. It seems IDEs do not know what to make of this function result and therefore do not map out [theme root]/functions/base.php as expected.

Share Improve this question asked May 5, 2020 at 22:56 HongPongHongPong 1315 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

In the process of looking this up I determined the correct answer is to use the full local path in my dev environment, and add a comment in the code like

/** @define "get_template_directory()" "/home/myuser/mywpproject/wp-content/themes/mytheme" */

And this works for the subsequent references in that file in JetBrains IDE / PHPStorm immediately. Thanks to here by Jeff Behnke. I have not checked this on other IDEs. As this is a comment I believe it should not affect server side execution.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论