mardi 1 décembre 2015

if statment within an echo using ternary operators

I have the following echo statement:

echo '<li><a href="'. esc_url(add_query_arg( 'booking-id', $the_query->post->ID, site_url( '/pay-deposit/' ) )) .'">Pay deposit</a></li>';

I want to add the class "disabled" to the link when a parameter = 1

Here is what I am trying using ternary operators

    $is_deposit_paid = get_post_meta( $the_query->post->ID, 'deposit_paid', true );
    echo '<li><a '.( $is_deposit_paid = 1) ? "disabled" .' href="'. esc_url(add_query_arg( 'booking-id', $the_query->post->ID, site_url( '/pay-deposit/' ) )) .'">Pay deposit</a></li>';

however this produces a syntax error. How do I write this out correctly?

Aucun commentaire:

Enregistrer un commentaire