这个init
hook 没有参数!钩子在WordPress完成加载后但在发送任何头之前被激发。您可以交替使用closure function 自php5起。6在此挂钩上添加参数。
从核心开始,请参见the file on github.
/**
* Fires after WordPress has finished loading but before any headers are sent.
*
* Most of WP is loaded at this stage, and the user is authenticated. WP continues
* to load on the {@see \'init\'} hook that follows (e.g. widgets), and many plugins instantiate
* themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).
*
* If you wish to plug an action once WP is loaded, use the {@see \'wp_loaded\'} hook below.
*
* @since 1.5.0
*/
do_action( \'init\' );
如果需要删除编辑器,则无需在挂钩上使用参数no。简单的移除就足够了。
//remove default wysiwyg editor
add_action( \'init\', function() {
remove_post_type_support( \'post\', \'editor\' );
}, 100);
在增强的注释中,请参见此示例,以在闭包的帮助下添加参数-
use.
//remove default wysiwyg editor
add_action( \'init\', function() use ($pt_name) {
remove_post_type_support( $pt_name, \'editor\' );
}, 100);