Tkt_Search_And_Filter_Shortcodes
in package

Defines all ShortCodes of the TukuToi Search & Filter Plugin.

Tags
author

Beda Schmid beda@tukutoi.com

Table of Contents

$declarations  : string
The Configuration object.
$plugin_prefix  : string
The unique prefix of this plugin.
$version  : string
The version of this plugin.
__construct()  : mixed
Initialize the class and set its properties.
buttons()  : mixed
TukuToi `[buttons]` ShortCode.
loop()  : mixed
TukuToi `[loop]` ShortCode.
pagination()  : mixed
TukuToi `[pagination]` ShortCode.
searchtemplate()  : mixed
TukuToi `[searchtemplate]` ShortCode.
selectsearch()  : mixed
TukuToi `[selectsearch]` ShortCode.
spinner()  : mixed
TukuToi `[spinner]` ShortCode.
textsearch()  : mixed
TukuToi `[textsearch]` ShortCode.
tkt_ajax_pagination()  : void
Alias for TukuToi `[pagination]` ShortCode used when doing AJAX.
paginate_helper()  : mixed
Paginate Links Builder for TukuToi `[pagination]` ShortCode.

Properties

$declarations

The Configuration object.

private string $declarations
Description

All configurations and declarations of this plugin.

Tags
since
1.0.0
access

private

$plugin_prefix

The unique prefix of this plugin.

private string $plugin_prefix
Description

The string used to uniquely prefix technical functions of this plugin.

Tags
since
1.0.0
access

private

Methods

__construct()

Initialize the class and set its properties.

public __construct(string $plugin_prefix, string $version, object $declarations, object $query, object $sanitizer, object $plugin_public) : mixed
Parameters
$plugin_prefix
(string) The unique prefix of this plugin.
$version
(string) The version of this plugin.
$declarations
(object) The Configuration object.
$query
(object) The Query object.
$sanitizer
(object) The Sanitization object.
$plugin_public
(object) The Public object of this plugin.
Tags
since
1.0.0
Return
(mixed)

buttons()

TukuToi `[buttons]` ShortCode.

public buttons(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Buttons for Search Form.
Can only be used inside a [searchtemplate][/searchtemplate] ShortCode.
Can be used to produce Search input as well, apart of Submit and Reset buttons.

Example usage: [buttons label="Submit..." type="submit" customid="my_id" customclasses="class_one classtwo"]
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.

Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $label          The Button Label. Default: 'Submit'. Accepts: valid string.
     @type string    $url_param      URL parameter to use. Default: ''. Accepts: valid URL search parameter.
     @type string    $value          The value to pass to the URL parameter 'url_param'. Default: ''. Accepts: valid URL search parameter.
     @type string    $search_by      Query Parameter. Default: ''. Accepts: valid WP Query Parmater.
     @type string    $type           Type of Button. Default: 'submit'. Accepts: 'submit', 'reset', 'button'.
     @type string    $autofocus      Whether to autofocus the button. Only one item on document can be autofocused. Default: ''. Accepts: '', autofocus'.
     @type string    $form           Form ID to submit. Default: ancestor Form. Accepts: valid Form ID.
     @type string    $formtarget     Target of the form. Default: '_self'. Accepts: '_self', '_blank'.
     @type string    $customid       ID to use for the Search Form. Default: ''. Accepts: '', valid HTML ID.
     @type string    $customclasses  CSS Classes to use for the Search Form. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
$content
(mixed) ShortCode enclosed content. TukuToi Search and Filter Search ShortCodes, HTML. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'selectsearch'.
Tags
since
2.0.0
Return
(mixed)

loop()

TukuToi `[loop]` ShortCode.

public loop(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Search Results and loops over each item found.
Mandatory to use when adding Search Results.

Example usage:

[loop instance="my_instance" customid="my_id" customclasses="class_one classtwo" type="post" error="no posts found"]
  // Any TukuToi ShortCodes, or other HTML and Post Data to display for each item found.
[/loop]
```</br>
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.
Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $instance       The Instance used to bind this Loop section to a Search Form Section. Default: ''. Accepts: '', any valid string or number. Must match corresponding Search Form instance.
     @type string    $type           For what type the query results are for. Default: 'post'. Accepts: valid post type, valid taxonomy type, valid user role.
     @type string    $error          The no results found message: Default ''. Accepts: valid string or HTML.
$content
(mixed) ShortCode enclosed content. TukuToi ShortCodes, ShortCodes and HTML. No TukuToi Search ShortCodes. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'loop'.
Tags
since
2.0.0
todo

This is messy, redo this query args.

Return
(mixed)

pagination()

TukuToi `[pagination]` ShortCode.

public pagination(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the pagination Buttons.

Example usage: [pagination label_prev="Previous" label_next="Next" urlparam="_page" customclasses="class classone"]
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.

Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $aria_current       The value for the aria-current attribute. Default: page. Accepts: valid string.
     @type bool      $show_all           Whether to show all pages. Default: false. Accepts: boolean true|false.
     @type int       $end_size           How many numbers on either the start and the end list edges. Default 1. Accepts: numeric value.
     @type string    $mid_size           How many numbers to either side of the current page. Default: 2. Accepts: numeric value.
     @type string    $prev_next          Whether to include the previous and next links. Default: true. Accepts: bool true|false.
     @type string    $prev_text          The previous page text. Default: 'Pre'. Accepts: valid string.
     @type string    $next_text          The next page text. Default: 'Next'. Accepts: valid string.
     @type string    $type               Controls format of the returned value. Default: plain. Accepts: plain, list.
     @type string    $add_args           Query arguments to append to the URL. Default: ''. Accepts: URL arguments formatted like so: 'url_param:value,another_param:another-value'.
     @type string    $add_fragment       A string to append to each URL (link) at the end. Default: ''. Accepts: valid string or urlparam.
     @type string    $before_page_number A string to appear before the page number. Default: ''. Accepts: valid string.
     @type string    $after_page_number  A string to appear after the page number. Default: ''. Accepts: valid string.
     @type string    $instance           The unique instance of search and loop this pagination has to control. Default: ''. Accepts: valid instance (must match  Search template and Loop instance).
     @type string    $customclasses      CSS Classes to use for the pagination links. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
     @type string    $pag_arg            The URL parameter to use for this pagination. Default: item. Accepts: valid string but NOT 'page' or 'paged'.
     @type string    $container          Container Type to put the pagination into. Default: ''. Accepts: '', valid HTML Container type.
     @type string    $containerclasses   CSS Classes to use for the Pagination Container. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
$content
(mixed) ShortCode enclosed content. Not applicable for this ShortCode. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'pagination'.
Tags
since
2.0.0
Return
(mixed)

searchtemplate()

TukuToi `[searchtemplate]` ShortCode.

public searchtemplate(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Search Form.
Mandatory to use when adding Search ShortCodes.

Example usage:

[searchtemplate instance="my_instance" customid="my_id" customclasses="class_one classtwo"]
  // Search ShortCodes here.
[/searchtemplate]
```</br>
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.
Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $instance       The Instance used to bind this Search section to a Loop Results Section. Default: ''. Accepts: '', any valid string or number.
     @type string    $customid     ID to use for the Search Form. Default: ''. Accepts: '', valid HTML ID.
     @type string    $customclasses   CSS Classes to use for the Search Form. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
$content
(mixed) ShortCode enclosed content. TukuToi Search and Filter Search ShortCodes, HTML. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'searchtemplate'.
Tags
since
2.0.0
Return
(mixed)

selectsearch()

TukuToi `[selectsearch]` ShortCode.

public selectsearch(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Select Search Form.
Can only be used inside a [searchtemplate][/searchtemplate] ShortCode.

Example usage: [selectsearch placeholder="Search..." urlparam="_s" searchby="title" type="multiples2" customid="my_id" customclasses="class_one classtwo"]
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.

Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $placeholder    The Search Input Placeholder. Default: 'Search...'. Accepts: valid string.
     @type string    $urlparam       URL parameter to use. Default: '_s'. Accepts: valid URL search parameter.
     @type string    $searchby       Query Parameter. Default: 's'. Accepts: valid WP Query Parmater.
     @type string    $type           Type of Select. Default: 'single'. Accepts: 'single', 'multiple', 'singleS2', 'multipleS2'.
     @type string    $customid       ID to use for the Search Form. Default: ''. Accepts: '', valid HTML ID.
     @type string    $customclasses  CSS Classes to use for the Search Form. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
     @type string    $custom_tax     Custom Taxonomy Slug to query by. Default: ''. Accepts: valid custom taxonomy slug.
     @type string    $tax_field      Custom Taxonomy field to query by. Default: 'term_id'. Accepts: valid `tax_query` `field` values.
$content
(mixed) ShortCode enclosed content. TukuToi Search and Filter Search ShortCodes, HTML. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'selectsearch'.
Tags
since
2.0.0
since
2.29.0

Added ShortCode attributes custom_tax and tax_field

Return
(mixed)

spinner()

TukuToi `[spinner]` ShortCode.

public spinner(array<string|int, string> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Spinners for Search and Paginations when using AJAX.

Example usage:

[spinner url="/path/to/spinner.gif" container="div" customid="my_id" customclasses="class_one classtwo" value=""]

For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.

Parameters
$atts
(array<string|int, string>)
     The ShortCode Attributes.

     @type string    $url            Url to the Spinner asset. Default: ''. Accepts: valid URL to resource/asset.
     @type string    $container      HTML container to use for displaying the spinner. Default: 'span'. Accepts: valid HTML element.
     @type string    $value          Value to show instead of or together with URL asset. Default: ''. Accepts: valid string.
     @type string    $customid       ID to use for the Search Form. Default: ''. Accepts: '', valid HTML ID.
     @type string    $customclasses  Additional CSS Classes to use for the Search Form. Default: 'tkt_ajax_loader'. Mandatory 'tkt_ajax_loader'. Accepts: 'tkt_ajax_loader' + valid HTML CSS classes, space delimited.
$content
(mixed) ShortCode enclosed content. Not applicable for this ShortCode. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'spinner'.
Tags
since
2.0.0
Return
(mixed)

textsearch()

TukuToi `[textsearch]` ShortCode.

public textsearch(array<string|int, mixed> $atts[, mixed $content = null ], string $tag) : mixed
Description

Outputs the Text Search Form.
Can only be used inside a [searchtemplate][/searchtemplate] ShortCode.

Example usage: [textsearch placeholder="Search..." url_param="_s" search_by="title" customid="my_id" customclasses="class_one classtwo"]
For possible attributes see the Parameters > $atts section below or use the TukuToi ShortCodes GUI.

Parameters
$atts
(array<string|int, mixed>)
     The ShortCode Attributes.

     @type string    $placeholder    The Search Input Placeholder. Default: 'Search...'. Accepts: valid string.
     @type string    $urlparam      URL parameter to use. Default: '_s'. Accepts: valid URL search parameter.
     @type string    $searchby      Query Parameter. Default: 's'. Accepts: valid WP Query Parmater.
     @type string    $customid       ID to use for the Search Form. Default: ''. Accepts: '', valid HTML ID.
     @type string    $customclasses  CSS Classes to use for the Search Form. Default: ''. Accepts: '', valid HTML CSS classes, space delimited.
$content
(mixed) ShortCode enclosed content. TukuToi Search and Filter Search ShortCodes, HTML. Defaults to: null
$tag
(string) The Shortcode tag. Value: 'textsearch'.
Tags
since
2.0.0
Return
(mixed)

tkt_ajax_pagination()

Alias for TukuToi `[pagination]` ShortCode used when doing AJAX.

public tkt_ajax_pagination() : void
Tags
see

{/public/class-tkt-search-and-filter-shortcodes.php} > pagination ShortCode.

Internal Function used as Alias to the Pagination ShortCode when doing ajax. Public because AJAX requires public callback, but shouldn't be used. Use ShortCode instead.

since
2.19.0
access

public

Return
(void)

paginate_helper()

Paginate Links Builder for TukuToi `[pagination]` ShortCode.

private paginate_helper(array<string|int, mixed> $atts[, int $page = 1 ][, string $paged = '' ], string $max[, string $add_args = array() ][, string $base = false ]) : mixed
Description

Builds the Pagination Links array/list/plain.

Internal Function to build pagination links. Not intended for external Usage.

Parameters
$atts
(array<string|int, mixed>) The ShortCode Attributes, @see
/public/class-tkt-search-and-filter-shortcodes.php
> `pagination` ShortCode.
$page
(int) The current page, populates $pargs['current']. Default: 1. Accepts: valid integer. Defaults to: 1
$paged
(string) The Pagination URL parameter, populates $pargs['format']. Default: ''. Accepts: valid URL parameter. Defaults to: ''
$max
(string) The Number Posts Found, populates $parg['total']. Default: ''. Accepts: valid integer.
$add_args
(string) Additional URL parameters, populates $pargs['add_args']. Default: array. Accepts: array of URL parameter => value. Defaults to: array()
$base
(string) The Pagination URL Base, populates $pargs['base']. Default: ''. Accepts: valid base URL. Defaults to: false
Tags
since
2.0.0
access

private

Return
(mixed) $pag The Pagination Links, either in plain, list or array mode.

Search results