=== The Taxonomy Sort ===
Contributors: RistoNiinemets
Tags: terms, taxonomy, sorting, ordering, categories
Stable tag: 2.1
Tested up to: 7.1
Requires at least: 6.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Allows you to easily change the order of different taxonomies/terms/categories.

== Description ==

Most commonly taxonomy sorting plugins will create a new interface to drag or order/sort your terms. This plugin uses the built-in view just to make things easier. Just grab the term and drag it to a new position. No more extra clicks - everything is saved after repositioning!

The order is applied to term queries that did not ask for an order of their own. A query that explicitly sorts by count, slug, term order or anything else gets what it asked for, so themes and plugins that sort terms themselves are left alone.

== Installation ==

1. Upload `the-taxonomy-sort/` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to taxonomy page (for example Posts -> Categories) and drag the table rows to change ordering.

== Frequently Asked Questions ==

= Is there a way to disable it for some taxonomies? =

Yes, as of version 2.1. Return the taxonomies it should apply to, and it applies to no others:

`add_filter( 'the_taxonomy_sort_define_taxonomies', function () {
	return array( 'category', 'product_cat' );
} );`

For a decision per query - one taxonomy sorted in the admin but not on the front end, say - there is `the_taxonomy_sort_is_sortable`:

`add_filter( 'the_taxonomy_sort_is_sortable', function ( $sortable, $taxonomies, $args ) {
	return is_admin() ? $sortable : false;
}, 10, 3 );`

= Does it work with hierarchical taxonomies? =

Yes. Terms are ordered among their siblings; WordPress still nests children under their parent, so dragging a child to the top of the list moves it to the top of its own branch.

= Who is allowed to reorder terms? =

Whoever may manage that taxonomy's terms - the same capability WordPress checks before showing the taxonomy screen.

== Changelog ==
= 2.1 =
* Fix: term queries that ask for ids, names or slugs came back empty, which emptied tag autocomplete, WooCommerce attribute terms and anything else built on them
* Fix: two terms sharing a position made one of them disappear from every list
* Fix: the sorting no longer costs one database query per term - it is done in SQL, in the query that was going to run anyway
* Fix: dragging on page two of a paginated taxonomy no longer renumbers over page one, which is what made the last terms of a long list look unsortable
* Fix: rows can be dragged past the bottom of the table again
* Fix: uninstalling now removes the order it saved (it was deleting post meta, where nothing was ever stored)
* Security: saving an order now requires a nonce and the capability to manage that taxonomy's terms; any logged-in user could previously reorder every term on the site
* Feature: `the_taxonomy_sort_define_taxonomies` and `the_taxonomy_sort_is_sortable` filters to limit where the order applies
* Queries that ask for a specific order are left alone, so term sorting done by themes and other plugins keeps working
* Tested against PHP 8.4 and WordPress 7.1

= 2.0 =
* Using now term meta

= 1.1 =
* Fix: Uninstallation hook notice
* Feature: Activity spinner on saving the order

= 1.0 =
* Welcoming plugin to WordPress plugins!

== Upgrade Notice ==

= 2.1 =
Fixes term queries coming back empty, drops the per-term database queries, and closes a hole that let any logged-in user reorder terms. Your saved order is kept.
