未定义的变量:atts



如何修复这个通知,它出现在wordpress网站上,它是关于用另一个具有相同功能的插件的现有短代码加上一些添加

错误位置wp-content/plugins/n-customerpoint/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 );

$atts变量应提供给shortcode函数,如下所示:

function mycred_my_balance_n($atts) {
...
}

当你使用快捷代码时,你可以用变量设置它。您设置的任何变量都将覆盖您在数组中设置的默认值。

最新更新