来自函数.php文件(Wp_Register_Script)的奇怪错误

时间:2014-03-04 作者:user48455

我正在尝试迁移wordpress站点,在新服务器上调试时收到以下错误:

注意:wp\\u register\\u脚本调用不正确。在wp\\u enqueue\\u脚本、admin\\u enqueue\\u脚本或login\\u enqueue\\u脚本挂钩之前,不应注册或排队脚本和样式。有关详细信息,请参阅WordPress中的调试。(此消息是在版本3.3中添加的。)在/home/binaryop/public\\u html/wp中包含/functions。php在线3049

第3049行如下所示(以trigger\\u error开头的一行)

function _doing_it_wrong( $function, $message, $version ) {

do_action( \'doing_it_wrong_run\', $function, $message, $version );

// Allow plugin to filter the output error trigger
if ( WP_DEBUG && apply_filters( \'doing_it_wrong_trigger_error\', true ) ) {
    if ( function_exists( \'__\' ) ) {
        $version = is_null( $version ) ? \'\' : sprintf( __( \'(This message was added in version %s.)\' ), $version );
        $message .= \' \' . __( \'Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.\' );
        trigger_error( sprintf( __( \'%1$s was called <strong>incorrectly</strong>. %2$s %3$s\' ), $function, $message, $version ) );
    } else {
        $version = is_null( $version ) ? \'\' : sprintf( \'(This message was added in version %s.)\', $version );
        $message .= \' Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.\';
        trigger_error( sprintf( \'%1$s was called <strong>incorrectly</strong>. %2$s %3$s\', $function, $message, $version ) );
    }
}
}
然而,我看不出wp_register_script 在函数中。php,所以我对造成这种情况的原因感到困惑。有什么想法吗?

1 个回复
SO网友:Brandon White

如果这不能解决您的问题,我深表歉意,但在我达到50%的声誉之前,我无法发表评论。

原因:

导致此问题的原因是通知中所述的内容。有一个主题文件/插件文件试图过早地注册/排队脚本。

调试:

  1. 如果您最近更新了主题或功能,我建议您切换到默认主题并暂时禁用插件,以查看这是否解决了此问题wp_register_script(). 然后找到该函数添加到wordpress挂钩的位置。add_action()add_action() 参数#1大致是wp_enqueue_scripts. 请参见下面的示例。

    add_action(\'wp_enqueue_script\',\'register_my_scripts\');
    
    function register_my_scripts(){
        wp_register_script(\'etcetera\');
    }
    
    如果这样做not 解决您的问题,或者如果您的问题与主题文件/插件文件无关,那么下一个选项是尝试对WordPress进行干净的更新(而不是安装)。

    不相关的注意事项:

    此外,如果您的域URL正在更改,请确保在WordPress的设置中更新该URL。该文件位于Settings -> General. 如果我和你的决议处于同样的气氛中,请随时提出进一步的问题。

结束

相关推荐

qTranslate in functions.php

我有一个将用户重定向到特定页面的功能:wp_redirect(\'http://address/page\'); 通常我只会使用:<?php _e(\"<!--:en-->english permalink<!--:--><!--:de-->german permalink<!--:-->\"); ?> 但这是特定的情况,我不能这样使用它。。。你知道怎么做吗?谢谢