我刚升级到WordPress 3.1.1,突然出现以下错误:
Fatal error: Call to undefined function wp_get_current_user() in /home/arisehub/arisehub.org/wp-includes/capabilities.php on line 1028
我已经把它缩小到了“current\\u user\\u can”的使用范围
示例:
if ( !current_user_can(\'manage_options\') ) { add_action(\'admin_init\',\'customize_page_meta_boxes\'); }
删除对当前用户的引用可以删除错误。有什么想法吗?
最合适的回答,由SO网友:fuxia 整理而成
调用函数太早。这个functions.php
之前包含current_user_can()
已定义。Never 在上钩之前做任何事\'after_setup_theme\'
:
函数示例。php
add_action( \'after_setup_theme\', array( \'WPSE_14041_Base\', \'setup\' ) );
class WPSE_14041_Base
{
public static function setup()
{
! isset ( $GLOBALS[\'content_width\'] ) and $GLOBALS[\'content_width\'] = 480;
add_theme_support( \'post-thumbnails\', array( \'post\', \'page\' ) );
add_theme_support( \'automatic-feed-links\' );
add_theme_support( \'menus\' );
add_editor_style();
add_custom_background();
// You may use current_user_can() here. And more. :)
}
}