未定义变量:atts

问题描述 投票:0回答:1

如何解决此通知,它出现在wordpress网站上,是关于将某个插件的现有短代码更改为具有相同功能以及某些附加功能的另一个插件的

错误位置wp-content / plugins / n-custom-point / n_custom_point.php:864

第864行是

    'user_id'    => 'current',

此部分的几行内容

/*add_action('wp_head','override_cs_user_login');
function override_cs_user_login() {
    remove_shortcode(MYCRED_SLUG . '_my_balance');
    add_shortcode(MYCRED_SLUG . '_my_balance', 'mycred_my_balance_n');
}*/
add_shortcode('n_point_my_balance', 'mycred_my_balance_n');
function mycred_my_balance_n() {

    extract( shortcode_atts( array(
line 864    'user_id'    => 'current',
            'title'      => '',
            'title_el'   => 'h1',
            'balance_el' => 'div',
            'wrapper'    => 1,
            'formatted'  => 1,
            'type'       => MYCRED_DEFAULT_TYPE_KEY
        ), $atts, MYCRED_SLUG . '_my_balance' ) );

        $output = '';
        $total_point = 0;
        // Not logged in
        if ( ! is_user_logged_in() && $user_id == 'current' )
            return $content;

        // Get user ID
        $user_id = mycred_get_user_id( $user_id );
php wordpress
1个回答
0
投票
$atts变量应按以下方式提供给shortcode函数:

function mycred_my_balance_n($atts) { ... }

使用简码时,可以使用变量进行设置。您设置的任何变量都将覆盖您在数组中设置的默认变量。
© www.soinside.com 2019 - 2024. All rights reserved.