0

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>

1 Answer 1

0

Unless 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>?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.