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 '

Products Set to Private

'; echo ''; echo ''; echo ''; foreach ( $products_display as $product ) { // Determine the status (either "done" or pending) $status = $product['status'] === 'done' ? '' : '-'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
ThumbnailIDProduct NameEdit LinkStatus
' . esc_html( $product['id'] ) . '' . esc_html( $product['title'] ) . 'Edit' . $status . '
'; // Pagination controls echo '
'; if ( $total_pages > 1 ) { echo '
'; $page_links = paginate_links( array( 'base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'total' => $total_pages, 'current' => $current_page )); echo $page_links; echo '
'; } echo '
'; } else { 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}}