我有php函数,Iam试图在真假条件下使用它。
function tribe_is_past_event( $event = null ) {
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
// Check if event has passed
$gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : ' ' . get_option( 'gmt_offset' );
$gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
if ( strtotime( tribe_get_end_date( $event, false, 'Y-m-d G:i' ) . $gmt_offset ) <= time() ) {
return true;
}
return false;
}
这是我的功能。如果此功能存在或为真,我试图做什么然后打印没有可用的其他付款选项
喜欢这个。但这只是第一个条件。否则条件不起作用。
<?php
if(function_exists('tribe_is_past_event')){
echo "no option";
}
else{?>
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="buy_ticket">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="aatul1031@gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="<?php the_title()?>">
<input type="hidden" name="amount" value="<?php echo str_replace("$", "",tribe_get_cost( null, true )) ?>">
<input type="hidden" name="return" value="<?= home_url();?>">
<input type="hidden" name="cancel_return" value="<?php global $wp;
echo home_url( $wp->request )?>">
<div class="buy_btn">
<input type="image" src="" border="0" name="submit" alt="Buy Tickets">
</div>
</form>
<?php }?>
答案 0 :(得分:0)
嗨感谢你的种类支持解决方案就是这个。谢谢你的支持者
<?php
if (tribe_is_past_event()){
echo "no option";
}
else{?>
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="buy_ticket">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="aatul1031@gmail.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="<?php the_title()?>">
<input type="hidden" name="amount" value="<?php echo str_replace("$", "",tribe_get_cost( null, true )) ?>">
<input type="hidden" name="return" value="<?= home_url();?>">
<input type="hidden" name="cancel_return" value="<?php global $wp;
echo home_url( $wp->request )?>">
<div class="buy_btn">
<input type="image" src="" border="0" name="submit" alt="Buy Tickets">
</div>
</form>
<?php }?>