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 badges
Add a comment  | 

2 Answers 2

Reset to default 5

The 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 for load-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