Download the PHP package danlapteacru/facetwp-builder without Composer
On this page you can find all versions of the php package danlapteacru/facetwp-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danlapteacru/facetwp-builder
More information about danlapteacru/facetwp-builder
Files in danlapteacru/facetwp-builder
Package facetwp-builder
Short Description An Advanced FacetWP Builder for facets and templates.
License MIT
Homepage https://github.com/danlapteacru/facetwp-builder/
Informations about the package facetwp-builder
FacetWP Builder
Create, register, and reuse FacetWP plugin facets/templates using PHP, and keep them in your source code repository. To read more about registering FacetWP facets and templates via PHP, go here: facets documentation and templates documentation.
- Minimum Requirements
- Installation
- Adding/Removing FacetWP Facets and Templates with the Builder
- Composing Custom/3rd Party Addon Facets
- Hooks
- Examples
- Credits
- License
Minimum Requirements
- PHP v8.1
- WordPress v6.1
- FacetWP v4.0
Installation
If your project isn't using composer, you can require the autoload.php
file.
Adding/Removing FacetWP Facets and Templates with the Builder
Table of Contents
Facets | Templates |
---|---|
Autocomplete | Add a template |
Checkbox | |
Date Range | |
Dropdown | |
fSelect | |
Hierarchy | |
Number Range | |
Pager | |
Proximity | |
Radio | |
Reset | |
Search | |
Slider | |
Sort | |
Star Rating | |
User Selections |
Facet Types
You can find a full reference of available facets on the official FacetWP documentation.
Autocomplete
Checkboxes
Date Range
Dropdown
fSelect
Hierarchy
Number Range
Pager
Proximity
Radio
Reset
Search
Slider
Sort
Star Rating
User Selections
TODO: Add available options.
Shortcut functions
If you don't want to use the second parameter of the add method, you can use the following shortcut functions:
Templates
You can find a full reference of how to add a template with PHP on the official FacetWP documentation.
Add a template
You can add a template by using the addTemplate
method.
Example:
Attention! The query
key should contain a PHP code string. If you prefer to use a PHP array, utilize the setQuery
helper function instead.
Here are some available declarative shortcut functions for the addTemplate
method:
If you dont want to specify the query
or query_obj
keys, you can use the setPostType
and setPostsPerPage
methods to define the post_type
and posts_per_page
arguments.
Example:
Default Label
If setLabel
is not set, or the addTemplate
arguments do not contain the label
key, then the label will be generated from the template name/key.
Default Modes
If setModes
is not set, or the addTemplate
arguments do not contain the modes
key, then the default modes
will be used:
Composing Custom/3rd Party Addon Facets
You can use the addFacet
method to add a custom/3rd party addon facet.
addFacet(string $name, string $type, array $args = [])
Example:
If you want to use a facet type which is not defined in the ALLOWED_FACET_TYPES constant, you can use the addAllowedFacetType
method or danlapteacru/facetwp-builder/allowed_facet_types hook to add it.
Hooks
You can use the following hooks to modify the FacetWP Builder:
danlapteacru/facetwp-builder/allowed_facet_types
You can use this hook to add custom facet types to the FacetWP Builder.
danlapteacru/facetwp-builder/facets
You can use this hook to modify the facets array before it is returned.
danlapteacru/facetwp-builder/facet_key
You can use this hook to modify the facet key before it is used to check if facet type exists.
danlapteacru/facetwp-builder/templates
You can use this hook to modify the templates array before it is returned.
Examples
Table of Contents
Examples |
---|
Add Facets |
Add a custom facet |
Add Template |
Add Facets
Add a custom facet
Add Template
Credits
FacetWP Builder is created by Dan Lapteacru.
Full list of contributors can be found here.
License
FacetWP Builder is released under the MIT License.