Includes
Interfaces, Classes, Traits and Enums
- Tkt_Search_And_Filter_Activator
- Fired during plugin activation.
- Tkt_Search_And_Filter_Deactivator
- Fired during plugin deactivation.
- Tkt_Search_And_Filter_Declarations
- The Declarations Class.
- Tkt_Search_And_Filter_I18n
- Define the internationalization functionality.
- Tkt_Search_And_Filter_Loader
- Register all actions and filters for the plugin.
- Tkt_Search_And_Filter_Sanitizer
- The Sanitization, Validation and error handling Class.
- Tkt_Search_And_Filter
- The core plugin class.
Table of Contents
- better_dropdown_users() : string
- ### Start Comment to document Fix ### This function is not offerng a way to alter the `value` of the User Dropdown options.
- better_dropdown_categories() : string
- ### Start Comment to document Fix ### Taxonomy Dropdown is a little less messy than user Dropdown but misses the multiselect.
- better_paginate_links() : array<string|int, mixed>|string|void
- ### Start Comment to document Fix ### Pagination links is a mess. This needs to be urgently refactored and enhqanced.
Functions
better_dropdown_users()
### Start Comment to document Fix ### This function is not offerng a way to alter the `value` of the User Dropdown options.
better_dropdown_users([array<string|int, mixed>|string $args = '' ]) : string
Description
The fix adds the option to alter the value by any data from the user data object which should be used to start with, but WP Somehow chose to do things awkwardly when it comes to users
Also this fix includes a better output build. The Horrific syntax used in core for this is ununderstandable to me. It includes as well a new attribute to actually escape the output echoed. I mean, wtf.
Needless to say that also now it is WPCS compliant, which it was NOT at time of editing. If code comments would support emojy, I would :puke: at this point.
And for those who say this is useless or so:
- wp_dropdown_categories( string|array $args = '' ) does HAVE the value_field attribute which exactly what is needed.
- It IS useful because these dropdowns are not only used for silly thigns.
- Current core code was/is messy, unsafe and incomplete, as usual when it comes to USERS in WP.
Additionally this thing does not even support multiple selects, for whatever reasons. Yes, the HTML has a filter applied, but it is not the goal of filters to FIX things, it is the goal of filters to ALTER EXISTING content. Thus, we added a option for multi, too, which was there already but literally did NOTHING. I mean NOTHING. AT. ALL.
End Comment to document Fix
Create dropdown HTML content of users.
The content can either be displayed, which it is by default or retrieved by setting the 'echo' argument. The 'include' and 'exclude' arguments do not need to be used; all users will be displayed in that case. Only one can be used, either 'include' or 'exclude', but not both.
The available arguments are as follows:
Parameters
- $args
-
(array<string|int, mixed> |string)
Optional. Array or string of arguments to generate a drop-down of users. See WP_User_Query::prepare_query() for additional available arguments. @type string $show_option_all Text to show as the drop-down default (all). Default empty. @type string $show_option_none Text to show as the drop-down default when no users were found. Default empty. @type int|string $option_none_value Value to use for $show_option_non when no users were found. Default -1. @type string $hide_if_only_one_author Whether to skip generating the drop-down if only one user was found. Default empty. @type string $orderby Field to order found users by. Accepts user fields. Default 'display_name'. @type string $order Whether to order users in ascending or descending order. Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'. @type array|string $include Array or comma-separated list of user IDs to include. Default empty. @type array|string $exclude Array or comma-separated list of user IDs to exclude. Default empty. @type bool|int $multi Whether to skip the ID attribute on the 'select' element. Accepts 1|true or 0|false. Default 0|false. @type string $show User data to display. If the selected item is empty then the 'user_login' will be displayed in parentheses. Accepts any user field, or 'display_name_with_login' to show the display name with user_login in parentheses. Default 'display_name'. @type string $value_field User `data` object values to use as selection option **value**. Accepts any User `data` object property. Default to user ID. @type int|bool $echo Whether to echo or return the drop-down. Accepts 1|true (echo) or 0|false (return). Default 1|true. @type int|bool $allowed_html Array of allowed HTML to pass to wp_kses if echo. @type int $selected Which user ID should be selected. Default 0. If $value is passed, $selected should pass a valid value to match $value. @type bool $include_selected Whether to always include the selected user ID in the drop- down. Default false. @type string $name Name attribute of select element. Default 'user'. @type string $id ID attribute of the select element. Default is the value of $name. @type string $class Class attribute of the select element. Default empty. @type int $blog_id ID of blog (Multisite only). Default is ID of the current blog. @type string $who Which type of users to query. Accepts only an empty string or 'authors'. Default empty. @type string|array $role An array or a comma-separated list of role names that users must match to be included in results. Note that this is an inclusive list: users must match *each* role. Default empty. @type array $role__in An array of role names. Matched users must have at least one of these roles. Default empty array. @type array $role__not_in An array of role names to exclude. Users matching one or more of these roles will not be included in results. Default empty array.
Defaults to:''
Tags
Return
(string) String of HTML content.better_dropdown_categories()
### Start Comment to document Fix ### Taxonomy Dropdown is a little less messy than user Dropdown but misses the multiselect.
better_dropdown_categories([string|array<string|int, mixed> $args = '' ]) : string
Description
The suggested solution wp_terms_checklist is a huge garbage, almost worse than user Dropdown. Long enough I have battled the messy crap it generates and yu need to subclass its walker to even alter just one tiny aspect of its HTML. This is just an example of what shit programming is. Not saying I can do better, but obviously this is not the standards I would expect from WP or CP.
End Comment to document Fix
Display or retrieve the HTML dropdown list of categories.
The 'hierarchical' argument, which is disabled by default, will override the depth argument, unless it is true. When the argument is false, it will display all of the categories. When it is enabled it will use the value in the 'depth' argument.
Parameters
- $args
-
(string |array<string|int, mixed>)
Optional. Array or string of arguments to generate a categories drop-down element. See WP_Term_Query::__construct() for information on additional accepted arguments. @type string $show_option_all Text to display for showing all categories. Default empty. @type string $show_option_none Text to display for showing no categories. Default empty. @type string $option_none_value Value to use when no category is selected. Default empty. @type string $orderby Which column to use for ordering categories. See get_terms() for a list of accepted values. Default 'id' (term_id). @type bool $pad_counts See get_terms() for an argument description. Default false. @type bool|int $show_count Whether to include post counts. Accepts 0, 1, or their bool equivalents. Default 0. @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, or their bool equivalents. Default 1. @type bool|int $hierarchical Whether to traverse the taxonomy hierarchy. Accepts 0, 1, or their bool equivalents. Default 0. @type int $depth Maximum depth. Default 0. @type int $tab_index Tab index for the select element. Default 0 (no tabindex). @type string $name Value for the 'name' attribute of the select element. Default 'cat'. @type string $id Value for the 'id' attribute of the select element. Defaults to the value of `$name`. @type string $class Value for the 'class' attribute of the select element. Default 'postform'. @type int|string $selected Value of the option that should be selected. Default 0. @type string $value_field Term field that should be used to populate the 'value' attribute of the option elements. Accepts any valid term field: 'term_id', 'name', 'slug', 'term_group', 'term_taxonomy_id', 'taxonomy', 'description', 'parent', 'count'. Default 'term_id'. @type string|array $taxonomy Name of the category or categories to retrieve. Default 'category'. @type bool $hide_if_empty True to skip generating markup if no categories are found. Default false (create select element even if no categories are found). @type bool $required Whether the `
Defaults to:''
Tags
Return
(string) HTML content only if 'echo' argument is 0.better_paginate_links()
### Start Comment to document Fix ### Pagination links is a mess. This needs to be urgently refactored and enhqanced.
better_paginate_links([string|array<string|int, mixed> $args = '' ]) : array<string|int, mixed>|string|void
Description
For now we will add some additional features and fix the biggest mess (they dont even follow WPCS)
End Comment to document Fix
Retrieve paginated link for archive post pages.
Technically, the function can be used to create paginated link list for any area. The 'base' argument is used to reference the url, which will be used to create the paginated links. The 'format' argument is then used for replacing the page number. It is however, most likely and by default, to be used on the archive post pages.
The 'type' argument controls format of the returned value. The default is 'plain', which is just a string with the links separated by a newline character. The other possible values are either 'array' or 'list'. The 'array' value will return an array of the paginated link list to offer full control of display. The 'list' value will place all of the paginated links in an unordered HTML list.
The 'total' argument is the total amount of pages and is an integer. The 'current' argument is the current page number and is also an integer.
An example of the 'base' argument is "http://example.com/all_posts.php%%" and the '%%' is required. The '%_%' will be replaced by the contents of in the 'format' argument. An example for the 'format' argument is "?page=%#%" and the '%#%' is also required. The '%#%' will be replaced with the page number.
You can include the previous and next links in the list by setting the 'prev_next' argument to true, which it is by default. You can set the previous text, by using the 'prev_text' argument. You can set the next text by setting the 'next_text' argument.
If the 'show_all' argument is set to true, then it will show all of the pages instead of a short list of the pages near the current page. By default, the 'show_all' is set to false and controlled by the 'end_size' and 'mid_size' arguments. The 'end_size' argument is how many numbers on either the start and the end list edges, by default is 1. The 'mid_size' argument is how many numbers to either side of current page, but not including current page.
It is possible to add query vars to the link by using the 'add_args' argument and see add_query_arg() for more information.
The 'before_page_number' and 'after_page_number' arguments allow users to augment the links themselves. Typically this might be to add context to the numbered links so that screen reader users understand what the links are for. The text strings are added before and after the page number - within the anchor tag.
Parameters
- $args
-
(string |array<string|int, mixed>)
Optional. Array or string of arguments for generating paginated links for archives. @type string $base Base of the paginated url. Default empty. @type string $format Format for the pagination structure. Default empty. @type int $total The total amount of pages. Default is the value WP_Query's `max_num_pages` or 1. @type int $current The current page number. Default is 'paged' query var or 1. @type string $aria_current The value for the aria-current attribute. Possible values are 'page', 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'. @type bool $show_all Whether to show all pages. Default false. @type int $end_size How many numbers on either the start and the end list edges. Default 1. @type int $mid_size How many numbers to either side of the current pages. Default 2. @type bool $prev_next Whether to include the previous and next links in the list. Default true. @type bool $prev_text The previous page text. Default '« Previous'. @type bool $next_text The next page text. Default 'Next »'. @type string $type Controls format of the returned value. Possible values are 'plain', 'array' and 'list'. Default is 'plain'. @type array $add_args An array of query args to add. Default false. @type string $add_fragment A string to append to each link. Default empty. @type string $before_page_number A string to appear before the page number. Default empty. @type string $after_page_number A string to append after the page number. Default empty. @type string $li_classes Classes to be added to each LIST element. Default: empty. Accepts: valid HTML classes. @type string $ul_classes Classes to be added to the UL element. Default: empty. Accepts: valid HTML classes. @type string $a_classes Classes to be added to each a href element. Default: empty. Accepts: valid HTML classes. @type string $current_classes Classes to be added to each span (aria current) element. Default: empty. Accepts: valid HTML classes.
Defaults to:''