更新时间:2023-11-30 23:20:22
显然是因为包含插件的功能的文件/wp-includes/pluggable直到插件被加载后才会被加载.
Apparently this is happening because the file /wp-includes/pluggable which contains the function doesn't get loaded until after the plugins are loaded.
的确如此.因此,将您正在执行的任何操作都包装在函数中,然后将其挂接到plugins_loaded或init钩上. (请参阅wp-settings.php文件)
Indeed it is. So wrap whichever thing you're doing in a function, and hook it onto the plugins_loaded or init hook. (see the wp-settings.php file)
示例:
add_action('init','do_stuff');
function do_stuff(){
$current_user = wp_get_current_user();
// ...
}