admin管理员组文章数量:1335861
While configuring Ctags to recognize WordPress functions, I came across the noop.php file. Here is an excerpt:
/**
* @ignore
*/
function add_action() {}
/**
* @ignore
*/
function did_action() {}
/**
* @ignore
*/
function do_action_ref_array() {}
Why does this file exist? Can I remove it to let VIM better navigate the code?
While configuring Ctags to recognize WordPress functions, I came across the noop.php file. Here is an excerpt:
/**
* @ignore
*/
function add_action() {}
/**
* @ignore
*/
function did_action() {}
/**
* @ignore
*/
function do_action_ref_array() {}
Why does this file exist? Can I remove it to let VIM better navigate the code?
Share Improve this question edited May 12, 2019 at 13:37 butlerblog 5,1013 gold badges26 silver badges43 bronze badges asked Jan 13, 2016 at 13:48 dotancohendotancohen 8491 gold badge9 silver badges20 bronze badges2 Answers
Reset to default 5The description on top of the page you have linked gives an explanation:
Create a new file,
wp-admin/includes/noop.php
, which loads all of the noop functions forload-script|styles.php
and is only loaded by those files. DRYs in the process. See #33813.
Additionally there is the trac ticket #33813 linked, which gives some additional insight. You generally shouldn't delete core files so consider noop.php
as a necessary file.
Why noop.php
?
Previously noop
functions were duplicated across core in multiple places, and an effort was made to co-locate them to avoid this duplication. This was done in https://core.trac.wordpress/ticket/33813 as part of an organisation effort.
What Are Noop functions?
Noop, or No Op-eration functions, are useful for testing and mocking. They're also a way to implement the null pattern, of presenting APIs that don't do anything to act as placeholders for ones that do.
Can I remove it to let VIM better navigate the code?
I would not modify core, instead you should tell ctags to ignore that file. This question/answer on stackoverflow will help:
https://stackoverflow/questions/7736656/vim-and-ctags-ignoring-certain-files-while-generating-tags
本文标签: plugin developmentWhy does WordPress have a noopphp file
版权声明:本文标题:plugin development - Why does WordPress have a noop.php file? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742397645a2467248.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论