if ( ! empty( $products ) ) { // Apply filters $filter_status = $_GET['filter_status'] ?? 'all'; $filtered_products = array_filter($products, function($product) use ($filter_status) { if ($filter_status === 'all') { return true; } return $product['status'] === $filter_status; }); // Show "pending" (not set to private) products first usort($filtered_products, function($a, $b) { if ($a['status'] === 'pending' && $b['status'] !== 'pending') { return -1; // Move "pending" to the top } elseif ($a['status'] !== 'pending' && $b['status'] === 'pending') { return 1; // Keep "done" below } else { return 0; // Keep the same order for products with the same status } }); // Pagination setup $current_page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; $products_per_page = 100; $total_pages = ceil(count($filtered_products) / $products_per_page); $offset = ($current_page - 1) * $products_per_page; $products_display = array_slice($filtered_products, $offset, $products_per_page); echo '
Thumbnail | ID | Product Name | Edit Link | Status |
---|---|---|---|---|
' . esc_html( $product['id'] ) . ' | '; echo '' . esc_html( $product['title'] ) . ' | '; echo 'Edit | '; echo '' . $status . ' | '; echo '
No products were set to private in the last hour.
'; } {"code":"rest_forbidden","message":"Sorry, you are not allowed to do that.","data":{"status":401}}