You've already forked wc-licensed-product
Add search and filter form to PHP fallback template
The Twig template already had search/filter functionality but the PHP fallback template (used when Twig fails) was missing it. This ensures search and filters work regardless of which template is rendered. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -854,7 +854,7 @@ final class AdminController
|
|||||||
]);
|
]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Fallback to PHP template
|
// Fallback to PHP template
|
||||||
$this->renderLicensesPageFallback($enrichedLicenses, $page, $totalPages, $totalLicenses);
|
$this->renderLicensesPageFallback($enrichedLicenses, $page, $totalPages, $totalLicenses, $filters, $licensedProducts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,11 +974,20 @@ final class AdminController
|
|||||||
/**
|
/**
|
||||||
* Fallback render for licenses page
|
* Fallback render for licenses page
|
||||||
*/
|
*/
|
||||||
private function renderLicensesPageFallback(array $enrichedLicenses, int $page, int $totalPages, int $totalLicenses): void
|
private function renderLicensesPageFallback(array $enrichedLicenses, int $page, int $totalPages, int $totalLicenses, array $filters = [], array $products = []): void
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php esc_html_e('Licenses', 'wc-licensed-product'); ?></h1>
|
<h1 class="wp-heading-inline"><?php esc_html_e('Licenses', 'wc-licensed-product'); ?></h1>
|
||||||
|
<a href="<?php echo esc_url(admin_url('admin.php?page=wc-licenses&action=export_csv')); ?>" class="page-title-action">
|
||||||
|
<span class="dashicons dashicons-download" style="vertical-align: middle;"></span>
|
||||||
|
<?php esc_html_e('Export CSV', 'wc-licensed-product'); ?>
|
||||||
|
</a>
|
||||||
|
<a href="<?php echo esc_url(admin_url('admin.php?page=wc-licenses&action=import_csv')); ?>" class="page-title-action">
|
||||||
|
<span class="dashicons dashicons-upload" style="vertical-align: middle;"></span>
|
||||||
|
<?php esc_html_e('Import CSV', 'wc-licensed-product'); ?>
|
||||||
|
</a>
|
||||||
|
<hr class="wp-header-end">
|
||||||
|
|
||||||
<?php foreach ($this->getNotices() as $notice): ?>
|
<?php foreach ($this->getNotices() as $notice): ?>
|
||||||
<div class="notice notice-<?php echo esc_attr($notice['type']); ?> is-dismissible">
|
<div class="notice notice-<?php echo esc_attr($notice['type']); ?> is-dismissible">
|
||||||
@@ -986,8 +995,53 @@ final class AdminController
|
|||||||
</div>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<!-- Search and Filter Form -->
|
||||||
|
<form method="get" action="" class="wclp-filter-form">
|
||||||
|
<input type="hidden" name="page" value="wc-licenses">
|
||||||
|
|
||||||
|
<p class="search-box">
|
||||||
|
<label class="screen-reader-text" for="license-search-input"><?php esc_html_e('Search Licenses', 'wc-licensed-product'); ?></label>
|
||||||
|
<input type="search" id="license-search-input" name="s" value="<?php echo esc_attr($filters['search'] ?? ''); ?>"
|
||||||
|
placeholder="<?php esc_attr_e('Search license key or domain...', 'wc-licensed-product'); ?>">
|
||||||
|
<input type="submit" id="search-submit" class="button" value="<?php esc_attr_e('Search', 'wc-licensed-product'); ?>">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="tablenav top">
|
||||||
|
<div class="alignleft actions">
|
||||||
|
<select name="status">
|
||||||
|
<option value="all"><?php esc_html_e('All Statuses', 'wc-licensed-product'); ?></option>
|
||||||
|
<option value="active" <?php selected($filters['status'] ?? '', 'active'); ?>><?php esc_html_e('Active', 'wc-licensed-product'); ?></option>
|
||||||
|
<option value="inactive" <?php selected($filters['status'] ?? '', 'inactive'); ?>><?php esc_html_e('Inactive', 'wc-licensed-product'); ?></option>
|
||||||
|
<option value="expired" <?php selected($filters['status'] ?? '', 'expired'); ?>><?php esc_html_e('Expired', 'wc-licensed-product'); ?></option>
|
||||||
|
<option value="revoked" <?php selected($filters['status'] ?? '', 'revoked'); ?>><?php esc_html_e('Revoked', 'wc-licensed-product'); ?></option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select name="product_id">
|
||||||
|
<option value=""><?php esc_html_e('All Products', 'wc-licensed-product'); ?></option>
|
||||||
|
<?php foreach ($products as $id => $name): ?>
|
||||||
|
<option value="<?php echo esc_attr($id); ?>" <?php selected($filters['product_id'] ?? '', $id); ?>><?php echo esc_html($name); ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="submit" class="button" value="<?php esc_attr_e('Filter', 'wc-licensed-product'); ?>">
|
||||||
|
|
||||||
|
<?php if (!empty($filters)): ?>
|
||||||
|
<a href="<?php echo esc_url(admin_url('admin.php?page=wc-licenses')); ?>" class="button"><?php esc_html_e('Clear', 'wc-licensed-product'); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tablenav-pages">
|
||||||
|
<span class="displaying-num"><?php echo esc_html($totalLicenses); ?> <?php echo $totalLicenses === 1 ? esc_html__('item', 'wc-licensed-product') : esc_html__('items', 'wc-licensed-product'); ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e('Total licenses:', 'wc-licensed-product'); ?> <strong><?php echo esc_html($totalLicenses); ?></strong>
|
<?php esc_html_e('Showing', 'wc-licensed-product'); ?> <?php echo esc_html($totalLicenses); ?> <?php echo $totalLicenses === 1 ? esc_html__('license', 'wc-licensed-product') : esc_html__('licenses', 'wc-licensed-product'); ?>
|
||||||
|
<?php if (!empty($filters)): ?>
|
||||||
|
(<?php esc_html_e('filtered', 'wc-licensed-product'); ?>)
|
||||||
|
<?php endif; ?>
|
||||||
|
| <a href="<?php echo esc_url(admin_url('admin.php?page=wc-reports&tab=licenses')); ?>"><?php esc_html_e('View Dashboard', 'wc-licensed-product'); ?></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wc-licenses')); ?>">
|
<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wc-licenses')); ?>">
|
||||||
|
|||||||
Reference in New Issue
Block a user