$value ) {
$menu[ $key ] = $value;
if ( 'orders' === $key ) {
$menu[ self::ENDPOINT ] = ABPET_Function::label() . ' ' . __( 'Bookings', 'abp-event-ticket' );
}
}
if ( 'dashboard' === self::ENDPOINT || ! array_key_exists( self::ENDPOINT, $menu ) ) {
$menu[ self::ENDPOINT ] = ABPET_Function::label() . ' ' . __( 'Bookings', 'abp-event-ticket' );
}
return $menu;
}
public function maybe_flush_rules(): void {
if ( ! get_option( 'abpet_my_account_flushed' ) ) {
$this->register_endpoint();
flush_rewrite_rules( false );
update_option( 'abpet_my_account_flushed', 1 );
}
}
public function render_bookings(): void {
$user_id = get_current_user_id();
?>
' . esc_html__( 'Please login to see your bookings.', 'abp-event-ticket' ) . '';
return;
}
$limit = absint( ABPET_Function::get_option( 'abpet_per_page_item', 20 ) );
if ( $limit < 1 ) {
$limit = 20;
}
$page = isset( $_GET['abpet_page'] ) ? absint( $_GET['abpet_page'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( $page < 1 ) {
$page = 1;
}
$offset = ( $page - 1 ) * $limit;
$user_email = wp_get_current_user()->user_email ?? '';
$filters = array(
'user_id' => $user_id,
'status' => 'all',
'order_by' => 'created_at',
'order_dir' => 'DESC',
'cache' => false,
);
if ( ! empty( $user_email ) ) {
$filters['user_email'] = $user_email;
}
$total = ABPET_Query::get_booking_query( $filters, 0, 0, true );
$bookings = ABPET_Query::get_booking_query( $filters, $limit, $offset );
if ( ! empty( $bookings ) && is_array( $bookings ) ) {
foreach ( $bookings as $booking_item ) {
$this->booking_card( $booking_item );
}
$this->pagination( $total, $limit, $page );
} else {
echo '
' . esc_html__( 'You have no bookings yet.', 'abp-event-ticket' ) . '
';
}
?>
: 0 ? wp_kses_post( function_exists( 'wc_price' ) ? wc_price( $total ) : number_format_i18n( $total, 2 ) ) : esc_html__( 'FREE', 'abp-event-ticket' ); ?>