wordpress 警告:call_user_func_array()要求参数1是有效的回调,但未给定数组或字符串

hkmswyz6  于 2022-11-02  发布在  WordPress
关注(0)|答案(4)|浏览(182)

我在我的WordPress网站上,这些重复的消息弹出在我的 Jmeter 板上。我使用的是WordPress 4. 7. 1。我没有我的网站上的FeedWordPress插件,因为我看到他们也有这个错误的问题。
警告:call_user_func_array()要求参数1是有效的回调,第298行上的/home/mydomain/public_html/wp-includes/class-wp-hook. php中没有给定数组或字符串
警告:call_user_func_array()要求参数1是有效的回调,第298行上的/home/mydomain/public_html/wp-includes/class-wp-hook. php中没有给定数组或字符串
这条线是298

$value = call_user_func_array( $the_['function'], $args );

这是包含第298行的函数

public function apply_filters( $value, $args ) {
    if ( ! $this->callbacks ) {
        return $value;
    }

    $nesting_level = $this->nesting_level++;

    $this->iterations[ $nesting_level ] = array_keys( $this->callbacks );
    $num_args = count( $args );

    do {
        $this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] );

        foreach ( $this->callbacks[ $priority ] as $the_ ) {
            if( ! $this->doing_action ) {
                $args[ 0 ] = $value;
            }

            // Avoid the array_slice if possible.
            if ( $the_['accepted_args'] == 0 ) {
                $value = call_user_func_array( $the_['function'], array() );
            } elseif ( $the_['accepted_args'] >= $num_args ) {
                $value = call_user_func_array( $the_['function'], $args );
            } else {
                $value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );
            }
        }
    } while ( false !== next( $this->iterations[ $nesting_level ] ) );

    unset( $this->iterations[ $nesting_level ] );
    unset( $this->current_priority[ $nesting_level ] );

    $this->nesting_level--;

    return $value;
}

这是严重警告吗?如果是,我该如何修复?

zxlwwiss

zxlwwiss1#

只是为了更新这个线程-我有同样的错误升级到4.7.2。我停用我的插件一个接一个,并找到一个造成的问题

blmhpbnm

blmhpbnm2#

你说你停用了一些插件,并修复了它。什么插件导致的问题,因为我得到了同样的事情

wswtfjt7

wswtfjt73#

我也遇到了同样的问题。我禁用了滑块革命插件,它修复了这个问题。
希望对大家有帮助!

wvmv3b1j

wvmv3b1j4#

当您在wordpress action hook的回调参数中添加函数而不是字符串时,会出现此警告。

例如:

这将导致警告:

add_action("wp_enqueue_scripts",somefunction());

但这不会:

add_action("wp_enqueue_scripts","somefunction");

或者,如果未包含包含该“somefunction”的文件,也会出现此警告。
这些都是我重复警告的案例。

相关问题