我可以为回声''设置颜色,但我不知道如何为“befor_text”和“after_text”做同样的事情。
有人可以教我这个吗?谢谢......
extract( shortcode_atts( array(
'user_id' => 'current',
'title' => '',
'befor_text' => '',
'title_el' => 'h1',
'balance_el' => 'div',
'wrapper' => 1,
'formatted' => 1,
'after_text' => '',
'type' => MYCRED_DEFAULT_TYPE_KEY
), $atts ) );
$output = '';
// Not logged in
if ( ! is_user_logged_in() && $user_id == 'current' )
return $content;
// Get user ID
$user_id = mycred_get_user_id( $user_id );
// Make sure we have a valid point type
if ( ! mycred_point_type_exists( $type ) )
$type = MYCRED_DEFAULT_TYPE_KEY;
// Get the users myCRED account object
$account = mycred_get_account( $user_id );
if ( $account === false ) return;
// Check for exclusion
if ( empty( $account->balance ) || ! array_key_exists( $type, $account->balance ) ) return;
$balance = $account->balance[ $type ];
if ( $wrapper )
$output .= '<div class="mycred-my-balance-wrapper">';
// Title
if ( ! empty( $title ) ) {
if ( ! empty( $title_el ) )
$output .= '<' . $title_el . '>';
$output .= $title;
if ( ! empty( $title_el ) )
$output .= '</' . $title_el . '>';
}
//Text befor balance output
if ( ! empty( $befor_text ) ){
$output .= $befor_text;
}
// Balance
if ( ! empty( $balance_el ) )
$output .= '<' . $balance_el . '>';
if ( $formatted )
$output .= $balance->type->format( $balance->current );
else
$output .= $balance->type->number( $balance->current );
if ( ! empty( $balance_el ) )
$output .= '</' . $balance_el . '>';
if ( $wrapper )
$output .= '</div>';
//Text after balance output
if ( ! empty( $after_text ) ){
$output .= $after_text;
}
return $output;
}
endif;
add_shortcode( 'mycred_my_balance', 'mycred_render_shortcode_my_balance' );
?>
答案 0 :(得分:0)
我可能只是在span
中包装这些文本中的每一段,并为每一段提供不同的课程。然后添加一些CSS来定义你想要的颜色。
...
//Text befor balance output
if ( ! empty( $befor_text ) ){
$output .= "<span class='before_text'>".$befor_text."</span>";
}
...
//Text after balance output
if ( ! empty( $after_text ) ){
$output .= "<span class='after_text'>".$after_text."</span>";
}
CSS
.before_span {
color: red;
}
.after_span {
color: green;
}