admin管理员组文章数量:1277347
I'm trying to add css classes, so that each status (active, pending, canceled) has its own css class on the frontend. Please help.
function rcp_get_status_label( $status = '' ) {
static $labels = null;
// Array of status labels
if ( null === $labels ) {
$labels = array(
// General
'active' => __( 'Active', 'rcp'),
'inactive' => __( 'Inactive', 'rcp' ),
'pending' => __( 'Pending', 'rcp' ),
// Memberships
'cancelled' => __( 'Cancelled', 'rcp' ),
'expired' => __( 'Expired', 'rcp' ),
'free' => __( 'Free', 'rcp' ), // deprecated
// Payments
'abandoned' => __( 'Abandoned', 'rcp' ),
'complete' => __( 'Complete', 'rcp' ),
'failed' => __( 'Failed', 'rcp' ),
'refunded' => __( 'Refunded', 'rcp' ),
'new' => __( 'New', 'rcp' ),
'renewal' => __( 'Renewal', 'rcp' ),
'upgrade' => __( 'Upgrade', 'rcp' ),
'downgrade' => __( 'Downgrade', 'rcp' ),
// Discount Codes
'disabled' => __( 'Disabled', 'rcp' ),
);
}
<td data-th="<?php esc_attr_e( 'Status', 'rcp' ); ?>">
<?php rcp_print_membership_status( $membership->get_id() ); ?>
</td>
I'm trying to add css classes, so that each status (active, pending, canceled) has its own css class on the frontend. Please help.
function rcp_get_status_label( $status = '' ) {
static $labels = null;
// Array of status labels
if ( null === $labels ) {
$labels = array(
// General
'active' => __( 'Active', 'rcp'),
'inactive' => __( 'Inactive', 'rcp' ),
'pending' => __( 'Pending', 'rcp' ),
// Memberships
'cancelled' => __( 'Cancelled', 'rcp' ),
'expired' => __( 'Expired', 'rcp' ),
'free' => __( 'Free', 'rcp' ), // deprecated
// Payments
'abandoned' => __( 'Abandoned', 'rcp' ),
'complete' => __( 'Complete', 'rcp' ),
'failed' => __( 'Failed', 'rcp' ),
'refunded' => __( 'Refunded', 'rcp' ),
'new' => __( 'New', 'rcp' ),
'renewal' => __( 'Renewal', 'rcp' ),
'upgrade' => __( 'Upgrade', 'rcp' ),
'downgrade' => __( 'Downgrade', 'rcp' ),
// Discount Codes
'disabled' => __( 'Disabled', 'rcp' ),
);
}
<td data-th="<?php esc_attr_e( 'Status', 'rcp' ); ?>">
<?php rcp_print_membership_status( $membership->get_id() ); ?>
</td>
Share
Improve this question
asked Nov 11, 2021 at 13:50
Mr SilverMr Silver
1
1 Answer
Reset to default 0Unless you have a different function that we are not seeing, in the <td>
of your html, you are calling the function "rcp_print_membership_status", however, your function name in the first code example is "rcp_get_status_label". Are you trying to call that first function? If so:
As reads: <?php rcp_print_membership_status( $membership->get_id() ); ?>
Should read: <?php rcp_get_status_label( $membership->get_id() ); ?>
Additionally, you are not returning anything from that function so nothing will be printed/returned. If you are receiving a "status" ID and checking to see what string you should return based on that ID, you are better off just using a switch statement and NOT an array.
Are you expecting that first function to return something that is printed within the <td>
?
本文标签: phpAdd css class to string
版权声明:本文标题:php - Add css class to string 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741223410a2361402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论