WP Manifestindependent plugin directory
manifest / ecommerce / wp-ajax-product-filter

WP AJAX Product Filter

AJAX Product Filter for WooCommerce — 7 widget types, shortcode, responsive

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/kaito2013/wp-ajax-product-filter/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Plugin tạo bộ lọc sản phẩm AJAX cho WooCommerce. Hỗ trợ nhiều widget lọc: checkbox, radio, dropdown, slider giá, color swatch, image swatch, rating.

Tính năng

  • AJAX Filtering — Lọc sản phẩm không reload trang
  • 7 Widget Types — Checkbox, Radio, Dropdown, Price Slider, Color Swatch, Image Swatch, Rating
  • URL PushState — Cập nhật URL khi filter (SEO friendly)
  • Responsive — Drawer trên mobile
  • Caching — Transient cache cho performance
  • Collapsible — Thu gọn/mở rộng widget
  • Shortcode — [ajax_product_filter]
  • HPOS Compatible — Tương thích High-Performance Order Storage

Yêu cầu

  • WordPress 6.0+
  • PHP 8.0+
  • WooCommerce 7.0+

Cài đặt

  1. Upload thư mục wp-ajax-product-filter vào /wp-content/plugins/
  2. Kích hoạt plugin qua menu Plugins
  3. Vào Appearance → Widgets, thêm các widget "APF: ..." vào vùng "Product Filter Sidebar"
  4. Thêm shortcode [ajax_product_filter] vào trang shop

Shortcode

[ajax_product_filter]
[ajax_product_filter columns="3" per_page="12" category="dien-thoai"]

Thuộc tính

Thuộc tính Mặc định Mô tả
columns 4 Số cột sản phẩm
per_page 12 Số sản phẩm mỗi trang
category — Lọc theo slug danh mục, cách nhau bởi dấu phẩy
tag — Lọc theo slug thẻ
orderby date Sắp xếp (date, price, popularity, rating)
order DESC Thứ tự (ASC, DESC)

Cấu trúc

wp-ajax-product-filter/
├── wp-ajax-product-filter.php          # Main file
├── uninstall.php
├── includes/
│   ├── class-plugin.php                # Singleton bootstrap
│   ├── class-activator.php             # Activation/deactivation
│   ├── class-assets.php                # Enqueue CSS/JS
│   ├── class-ajax-handler.php          # AJAX endpoint
│   ├── class-filter-query.php          # WP_Query builder
│   ├── class-shortcode.php             # Shortcode handler
│   ├── admin/
│   │   └── class-admin-settings.php    # WooCommerce settings tab
│   └── widgets/
│       ├── class-widget-base.php       # Abstract base
│       ├── class-widget-checkbox.php   # Checkbox list
│       ├── class-widget-radio.php      # Radio list
│       ├── class-widget-dropdown.php   # Dropdown
│       ├── class-widget-slider.php     # Price slider
│       ├── class-widget-color.php      # Color swatches
│       ├── class-widget-image.php      # Image swatches
│       └── class-widget-rating.php     # Rating filter
├── assets/
│   ├── css/
│   │   ├── frontend.css
│   │   └── admin.css
│   └── js/
│       ├── frontend.js
│       └── admin.js
└── templates/                          # Overridable templates

Bảo mật

  • ✅ Nonce verification trên mọi AJAX request
  • ✅ Input sanitization (sanitize_text_field, absint, sanitize_textarea_field)
  • ✅ Output escaping (esc_html, esc_attr, esc_url, wp_kses_post)
  • ✅ $wpdb->prepare() cho custom SQL
  • ✅ defined('ABSPATH') guard cho mọi PHP file

License

GPL v2 or later