$value) {
$menu[$key] = $value;
if ('orders' === $key && !isset($menu[$slug])) {
$menu[$slug] = __('My Bookings', 'abp-rentalforge');
}
}
if (!isset($menu[$slug])) {
$menu[$slug] = __('My Bookings', 'abp-rentalforge');
}
return $menu;
}
public function maybe_flush_rules(): void {
if (!get_option('abprf_my_account_flushed')) {
$this->register_endpoint();
flush_rewrite_rules();
update_option('abprf_my_account_flushed', 1);
}
}
public function render_bookings(): void {
$user_id = get_current_user_id();
?>
' . esc_html__('Please login to see your bookings.', 'abp-rentalforge') . '';
return;
}
$limit = absint(ABPRF_Function::get_option('abprf_per_page_item', 20));
if ($limit < 1) {
$limit = 20;
}
$page = isset($_GET['abprf_page']) ? absint($_GET['abprf_page']) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ($page < 1) {
$page = 1;
}
$offset = ($page - 1) * $limit;
$filters = array(
'user_id' => $user_id,
'status' => 'all',
'order_by' => 'created_at',
'order_dir' => 'DESC',
);
$total = ABPRF_Query::get_booking_query($filters, 0, 0, true);
$bookings = ABPRF_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-rentalforge') . '
';
}
?>