无法访问仪表板并显示禁止的页面

时间:2013-12-30 作者:Zammuuz

我无法访问我的仪表板。在我实现wp调试后,它显示以下错误。

Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /var/www/html/enteopinion/wp-includes/functions.php on line 3012 
我应该怎么做才能使站点仪表板正常工作?我使用了一个插件简单的错误处理程序。它显示以下错误。

Error trapped: USER NOTICE(1024), wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.)
 /var/www/html/enteopinion/wp-includes/functions.php[3012]
 /var/www/html/enteopinion/wp-includes/functions.wp-scripts.php[57]
 /var/www/html/enteopinion/wp-settings.php[197]
 /var/www/html/enteopinion/wp-config.php[90]
 /var/www/html/enteopinion/wp-load.php[29]
 /var/www/html/enteopinion/wp-admin/admin.php[30]
 /var/www/html/enteopinion/wp-admin/plugins.php[10]
如何处理这些错误?:(请帮帮我

1 个回复
SO网友:s_ha_dum

这是一个简短而甜蜜的答案。

您、插件或主题正在执行以下操作:

wp_register_script( \'myscript\', get_template_directory_uri() . \'/path/to/myscript.js\', \'\', \'\', true );
应该发生的是:

add_action(
  \'wp_enqueue_scripts\',
  function() {
    wp_register_script( \'myscript\', get_template_directory_uri() . \'/path/to/myscript.js\', \'\', \'\', true );
  }
);
Notice:

wp_enqueue_scripts, admin_enqueue_scripts, 或login_enqueue_scripts 挂钩

换句话说,有些地方的脚本被过早注册。通过钩住Notice, 或者在这些运行之后的任何钩子,您可以确保脚本在应该注册的时候注册,而不是之前注册。

结束

相关推荐

Implement Hooks Using Array

我试图在一个主题中实现一些钩子,但不是用重复的代码写出每个钩子,而是想知道是否可以使用和数组来声明钩子。E、 g.通常,我会使用类似以下内容:function hook_name_1() { do_action( \'hook_name_1\' ); } function hook_name_2() { do_action( \'hook_name_2\' ); } 有没有办法将钩子名称放入一个数组中,然后用一个foreach循环