=== Universal Ajax Filter ===
Contributors: prostilmangasule, walstartechnologies, pratapvashi123, walstarmedia
Tags: ajax filter, elementor, search filter, product filter, custom post type
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Build AJAX-powered filters for posts, products, and custom post types visually — with a shortcode and a native Elementor widget, no code required.

== Description ==

Universal Ajax Filter lets you build front-end filter bars that refresh results instantly via AJAX — without writing a single AJAX handler. Create as many filter sets as you need from a simple admin screen, then drop each one into a page using a shortcode or the plugin's own Elementor widget.

Each filter set can combine multiple fields — Search, Dropdown/Select, Checkbox, Radio, and Buttons (pill style) — bound to any taxonomy and its terms, and can drive one of four result actions:

* **Query Posts** – filter standard WordPress posts
* **Query Products** – filter WooCommerce-style product post types
* **Filter CPT** – filter any custom post type on your site
* **Load Elementor Template** – render matching items through an Elementor Pro Loop Item template

= Key Features =

* **Visual filter builder** — add, reorder, and remove filter fields from the admin screen; no code editing needed.
* **Multiple filter types** — Search, Dropdown/Select, Checkbox, and Radio, each bindable to any taxonomy and specific terms.
* **Four result actions** — Query Posts, Query Products, Filter CPT, or Load an Elementor Template, so one tool covers blogs, shops, and custom content types.
* **Shortcode support** — every saved filter gets its own shortcode, e.g. `[psaf_smart_ajax_filter id="12"]`, ready to paste into any page, post, or widget area.
* **Native Elementor widget** — search for "Universal Ajax Filter" in the Elementor panel and configure a filter directly inside the page editor, with no shortcode or saved filter needed.
* **Elementor normal grid support** — when using the standard Elementor editor, filtered results can be displayed using a regular Elementor grid without requiring Elementor Pro.
* **Elementor Pro Loop Grid support** — filter results can be rendered using Elementor Pro Loop Grid and Loop Item templates, allowing you to use your custom Loop Item designs. **Elementor Pro is required for Loop Grid/Loop Item functionality.**
* **Layout & Style options** — choose filter position (left, top, right), card style (Classic, List, Overlay, Minimal), columns per device, gap, image height, colors, shadows, corner radius and pagination style from the dashboard, with one-click presets.
* **Gutenberg block** — add the "Universal Ajax Filter" block and adjust the layout from the block sidebar; no shortcode needed.
* **Shortcode attributes** — override the layout per page, e.g. `[psaf_smart_ajax_filter id="12" position="top" columns="4" card_style="overlay"]`.
* **Custom results target** — results load by default into a `.psaf-results` container, or you can point the filter at your own CSS selector to filter an existing grid on the page.
* **Configurable pagination and sorting** — set results per page, order-by field, and sort direction per filter.
* **Custom loading and empty-state text** — set your own "Loading..." and "No results found." messages per filter.
* **Multiple filters per site** — build unlimited independent filter sets, each with its own configuration, shortcode, and widget instance.
* **Lightweight front end** — vanilla AJAX requests with dedicated frontend CSS/JS assets, only loaded where needed.

= How It Works =

1. Go to **Universal Ajax Filter → Add New** in the WordPress admin menu.
2. Choose a post type, result action (Query Posts, Query Products, Filter CPT, or Load Elementor Template), results-per-page, and sort order.
3. Add one or more filter fields (Search, Dropdown/Select, Checkbox, Radio) and bind each to a taxonomy and, optionally, specific terms.
4. Save the filter — you'll get a ready-to-use shortcode, e.g. `[psaf_smart_ajax_filter id="12"]`.
5. Paste the shortcode into any page or post, **or** open Elementor and drag in the "Universal Ajax Filter" widget to configure the same filter directly in the builder.
6. Visitors filter results instantly on the front end — no page reload.

= Requirements =

* WordPress 5.8 or higher.
* PHP 7.4 or higher.
* Elementor (free) is only required if you want to use the native Elementor widget — the shortcode works with any theme or page builder.
* Elementor Pro is only required if you choose the "Load Elementor Template" result action to render results through a Loop Item template.

== Installation ==

1. Upload the `prostil-smart-ajax-filter` folder to the `/wp-content/plugins/` directory, or install the plugin zip through **Plugins → Add New → Upload Plugin**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Go to **Universal Ajax Filter → Add New** to create your first filter.
4. Copy the generated shortcode into a page/post, or add the "Universal Ajax Filter" widget from the Elementor panel.

== Frequently Asked Questions ==

= Do I need Elementor to use this plugin? =

No. The shortcode `[psaf_smart_ajax_filter id="X"]` works on any theme or page builder. The Elementor widget is an optional, additional way to add and configure a filter directly inside the Elementor editor.

= Can I filter WooCommerce products? =

Yes. Choose the "Query Products" result action and set the post type accordingly when creating a filter.

= Can I filter a custom post type? =

Yes. Choose "Filter CPT" as the result action and select your custom post type from the Post Type dropdown.

= Can filters target an existing results grid on my page instead of generating their own? =

Yes. By default results load into a `.psaf-results` container, but you can set a custom CSS selector as the results target in the filter settings to hook into your own existing grid.

= Does this work with Elementor Loop Item templates? =

Yes, if Elementor Pro is active. Set the result action to "Load Elementor Template" and select the Loop Item template you want filtered results rendered through.

= Can I create more than one filter? =

Yes. Create as many independent filter sets as you need from **Universal Ajax Filter → Add New** — each has its own configuration, shortcode, and can also be added as a separate Elementor widget instance.

= How do I change the layout when I use the shortcode in the block editor? =

Open **Universal Ajax Filter → Edit** and use the **Layout & Style** card (position, card style, columns, colors and more). To change it for just one page, either use the **Universal Ajax Filter** block and its sidebar settings, or add attributes to the shortcode, for example `[psaf_smart_ajax_filter id="12" position="top" columns="4" card_style="overlay" accent="#2563eb"]`. Supported attributes: position (left, top, right), columns, columns_tablet, columns_mobile, card_style (classic, horizontal, overlay, minimal), gap, image_height, card_radius, card_shadow (none, soft, strong), card_hover, show_image, show_excerpt, excerpt_lines, accent, card_bg, card_border, title_color, text_color, panel_bg, panel_radius, input_radius, pagination_style, class.

= How do I choose what a WooCommerce product card shows? =

Set the filter's post type to Product, then open **Layout & Style → Product card** in the filter editor. You can also set it per page, for example `[psaf_smart_ajax_filter id="12" show_cart="no" show_category="yes" button_text="Buy now"]`, or with the Universal Ajax Filter block's **Product card** panel. Attributes: show_badge, show_rating, show_price, show_cart, show_category, show_stock, show_sku, show_description (yes or no), button_style (filled, outline), button_width (full, auto), button_text, badge_style (pill, square), badge_position (left, right).

== Screenshots ==

1. Elementor widget – Layout settings (filters position, sidebar width, columns, gap).
2. Elementor widget – Query & Results settings with Loop Item template selection.
3. Elementor widget – Filter controls (Search, Dropdown, Checkbox) with AND/OR logic.
4. Universal Ajax Filter widget in the Elementor editor with live preview.
5. Shortcode usage and the frontend filter output with results grid.
6. Admin – Query, Frontend, and Elementor Loop Item Template settings.
7. Admin – Add AJAX Filter screen with Basic Settings and Multiple Filters.

== Changelog ==

= 1.1.1 =
* Fix: the shortcode ID no longer changes every time a filter is edited and saved in the dashboard.
* New: Buttons (pill style) filter type — a taxonomy filter shown as clickable buttons, with single or multiple selection and an optional, renameable "All" button.
* New: "Filter buttons" styling in Layout & Style, the shortcode (fbtn_* attributes), the Gutenberg block and a new "Filter Buttons" section in the Elementor Style tab: shape, size, text weight, alignment, wrap or scroll layout, spacing and normal / hover / active colors.
* New: Price slider filter type — a two-handle range slider with min/max number inputs, available in the filter editor and the Elementor widget. Works with WooCommerce prices or any custom price field.
* New: WooCommerce product card for product filters — sale badge, star rating, price and add to cart button.
* New: "Product card" options in Layout & Style, the shortcode and the Gutenberg block: show or hide badge, rating, price, add to cart, category, short description, stock status and SKU, plus button style, button width, button text, badge shape and badge position.
* Shortcode and block overrides are now kept when results reload through AJAX.

= 1.1.0 =
* New: "Layout & Style" card in the filter editor — filter position, card styles, columns (desktop/tablet/mobile), gap, image height, colors, shadow, radius, pagination style and presets.
* New: Gutenberg block with layout and style controls in the editor sidebar.
* New: layout and style attributes for the [psaf_smart_ajax_filter] shortcode.
* Fix: pagination now sits under the results when filters are on the left.
* Existing filters keep their current look until a style option is changed.

= 1.0.0 =
* Initial release: visual filter builder, Search/Dropdown/Select/Checkbox/Radio filter types, AJAX results, shortcode support for Posts, Products, and custom post types.


