Version Description
- 2018-07-02
- Add action 'customtaxorder_terms_ordered'.
Download this release
Release Info
Developer | mpol |
Plugin | Custom Taxonomy Order NE |
Version | 2.9.4 |
Comparing to | |
See all releases |
Code changes from version 2.9.3 to 2.9.4
- customtaxorder.php +35 -6
- readme.txt +21 -4
- taxonomies.php +1 -1
customtaxorder.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Custom Taxonomy Order NE
|
4 |
Plugin URI: http://products.zenoweb.nl/free-wordpress-plugins/custom-taxonomy-order-ne/
|
5 |
Description: Allows for the ordering of categories and custom taxonomy terms through a simple drag-and-drop interface.
|
6 |
-
Version: 2.9.
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl/
|
9 |
License: GPLv2 or later
|
@@ -40,7 +40,7 @@ Domain Path: /lang/
|
|
40 |
|
41 |
|
42 |
// Plugin Version
|
43 |
-
define('CUSTOMTAXORDER_VER', '2.9.
|
44 |
|
45 |
|
46 |
function customtaxorder_register_settings() {
|
@@ -237,7 +237,7 @@ function customtaxorder_update_order() {
|
|
237 |
/*
|
238 |
* Flush object cache when order is changed in taxonomy ordering plugin.
|
239 |
*
|
240 |
-
*
|
241 |
*
|
242 |
*/
|
243 |
function customtaxorder_flush_cache() {
|
@@ -263,8 +263,7 @@ function customtaxorder_sub_query( $terms, $tax ) {
|
|
263 |
|
264 |
|
265 |
/*
|
266 |
-
*
|
267 |
-
* Function to sort the standard WordPress Queries.
|
268 |
*
|
269 |
* @return string t.orderby
|
270 |
*
|
@@ -346,6 +345,8 @@ add_filter('get_terms_defaults', 'customtaxorder_get_terms_defaults', 10, 2);
|
|
346 |
function customtaxorder_wp_get_object_terms_order_filter( $terms ) {
|
347 |
$options = customtaxorder_get_settings();
|
348 |
|
|
|
|
|
349 |
if ( empty($terms) || ! is_array($terms) ) {
|
350 |
return $terms; // only work with an array of terms
|
351 |
}
|
@@ -390,6 +391,19 @@ function customtaxorder_wp_get_object_terms_order_filter( $terms ) {
|
|
390 |
}
|
391 |
|
392 |
usort($terms, 'customtax_cmp');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
return $terms;
|
394 |
}
|
395 |
return $terms;
|
@@ -430,11 +444,26 @@ add_filter('acf/format_value_for_api', 'customtaxorder_wp_get_object_terms_order
|
|
430 |
function customtaxorder_order_categories( $categories ) {
|
431 |
$options = customtaxorder_get_settings();
|
432 |
|
|
|
|
|
433 |
if ( !isset ( $options['category'] ) ) {
|
434 |
$options['category'] = 0; // default if not set in options yet
|
435 |
}
|
436 |
-
if ( $options['category'] == 1 && !isset($_GET['orderby']) ) {
|
437 |
usort($categories, 'customtax_cmp');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
return $categories;
|
439 |
}
|
440 |
return $categories;
|
3 |
Plugin Name: Custom Taxonomy Order NE
|
4 |
Plugin URI: http://products.zenoweb.nl/free-wordpress-plugins/custom-taxonomy-order-ne/
|
5 |
Description: Allows for the ordering of categories and custom taxonomy terms through a simple drag-and-drop interface.
|
6 |
+
Version: 2.9.4
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl/
|
9 |
License: GPLv2 or later
|
40 |
|
41 |
|
42 |
// Plugin Version
|
43 |
+
define('CUSTOMTAXORDER_VER', '2.9.4');
|
44 |
|
45 |
|
46 |
function customtaxorder_register_settings() {
|
237 |
/*
|
238 |
* Flush object cache when order is changed in taxonomy ordering plugin.
|
239 |
*
|
240 |
+
* @since 2.7.8
|
241 |
*
|
242 |
*/
|
243 |
function customtaxorder_flush_cache() {
|
263 |
|
264 |
|
265 |
/*
|
266 |
+
* Function to sort the standard WordPress Queries for terms.
|
|
|
267 |
*
|
268 |
* @return string t.orderby
|
269 |
*
|
345 |
function customtaxorder_wp_get_object_terms_order_filter( $terms ) {
|
346 |
$options = customtaxorder_get_settings();
|
347 |
|
348 |
+
$terms_old_order = $terms;
|
349 |
+
|
350 |
if ( empty($terms) || ! is_array($terms) ) {
|
351 |
return $terms; // only work with an array of terms
|
352 |
}
|
391 |
}
|
392 |
|
393 |
usort($terms, 'customtax_cmp');
|
394 |
+
|
395 |
+
$terms_new_order = $terms;
|
396 |
+
/*
|
397 |
+
* Fires after term array has been ordered with usort.
|
398 |
+
* Please be aware that this can be triggered multiple times during a request.
|
399 |
+
*
|
400 |
+
* @since 2.9.4
|
401 |
+
*
|
402 |
+
* @param array $terms_new_order ordered array with instances of WP_Term_Query.
|
403 |
+
* @param array $terms_old_order original array with instances of WP_Term_Query.
|
404 |
+
*/
|
405 |
+
do_action( 'customtaxorder_terms_ordered', $terms_new_order, $terms_old_order );
|
406 |
+
|
407 |
return $terms;
|
408 |
}
|
409 |
return $terms;
|
444 |
function customtaxorder_order_categories( $categories ) {
|
445 |
$options = customtaxorder_get_settings();
|
446 |
|
447 |
+
$terms_old_order = $categories;
|
448 |
+
|
449 |
if ( !isset ( $options['category'] ) ) {
|
450 |
$options['category'] = 0; // default if not set in options yet
|
451 |
}
|
452 |
+
if ( $options['category'] == 1 && ! isset($_GET['orderby']) ) {
|
453 |
usort($categories, 'customtax_cmp');
|
454 |
+
|
455 |
+
$terms_new_order = $categories;
|
456 |
+
/*
|
457 |
+
* Fires after term array has been ordered with usort.
|
458 |
+
* Please be aware that this can be triggered multiple times during a request.
|
459 |
+
*
|
460 |
+
* @since 2.9.4
|
461 |
+
*
|
462 |
+
* @param array $terms_new_order ordered array with instances of WP_Term_Query.
|
463 |
+
* @param array $terms_old_order original array with instances of WP_Term_Query.
|
464 |
+
*/
|
465 |
+
do_action( 'customtaxorder_terms_ordered', $terms_new_order, $terms_old_order );
|
466 |
+
|
467 |
return $categories;
|
468 |
}
|
469 |
return $categories;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mpol
|
|
3 |
Tags: term order, category order, taxonomy order, order
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 2.9.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
@@ -112,16 +112,29 @@ The function requires a parameter with an array of taxonomy objects.
|
|
112 |
|
113 |
= Is there an API? =
|
114 |
|
115 |
-
There
|
|
|
|
|
116 |
You could add the following example to your functions.php and work from there.
|
117 |
|
118 |
<?php
|
119 |
-
function custom_action($new_order) {
|
120 |
-
print_r($new_order);
|
121 |
}
|
122 |
add_action('customtaxorder_update_order', 'custom_action');
|
123 |
?>
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= How can I add my own translation? =
|
126 |
|
127 |
Translations can be added very easily through [GlotPress](https://translate.wordpress.org/projects/wp-plugins/custom-taxonomy-order-ne).
|
@@ -137,6 +150,10 @@ The left metabox lists the toplevel terms. Right (or below) are the sub-terms.
|
|
137 |
|
138 |
== Changelog ==
|
139 |
|
|
|
|
|
|
|
|
|
140 |
= 2.9.3 =
|
141 |
* 2018-02-16
|
142 |
* Sort terms with numeric values correctly (thanks empiresafe).
|
3 |
Tags: term order, category order, taxonomy order, order
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 2.9.4
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
112 |
|
113 |
= Is there an API? =
|
114 |
|
115 |
+
There are actions that you can use with add_action.
|
116 |
+
|
117 |
+
'customtaxorder_update_order' is being run when saving the order of terms in the admin page.
|
118 |
You could add the following example to your functions.php and work from there.
|
119 |
|
120 |
<?php
|
121 |
+
function custom_action( $new_order ) {
|
122 |
+
print_r( $new_order );
|
123 |
}
|
124 |
add_action('customtaxorder_update_order', 'custom_action');
|
125 |
?>
|
126 |
|
127 |
+
'customtaxorder_terms_ordered' is being run after term array has been ordered with usort.
|
128 |
+
Please be aware that this can be triggered multiple times during a request.
|
129 |
+
You could add the following example to your functions.php and work from there.
|
130 |
+
|
131 |
+
<?php
|
132 |
+
function custom_action( $terms_new_order, $terms_old_order ) {
|
133 |
+
print_r( $terms_new_order );
|
134 |
+
}
|
135 |
+
add_action('customtaxorder_terms_ordered', 'custom_action', 10, 2);
|
136 |
+
?>
|
137 |
+
|
138 |
= How can I add my own translation? =
|
139 |
|
140 |
Translations can be added very easily through [GlotPress](https://translate.wordpress.org/projects/wp-plugins/custom-taxonomy-order-ne).
|
150 |
|
151 |
== Changelog ==
|
152 |
|
153 |
+
= 2.9.4 =
|
154 |
+
* 2018-07-02
|
155 |
+
* Add action 'customtaxorder_terms_ordered'.
|
156 |
+
|
157 |
= 2.9.3 =
|
158 |
* 2018-02-16
|
159 |
* Sort terms with numeric values correctly (thanks empiresafe).
|
taxonomies.php
CHANGED
@@ -115,7 +115,7 @@ function customtaxorder_update_taxonomies() {
|
|
115 |
*
|
116 |
* Returns: array with list of taxonomies, ordered correctly.
|
117 |
*
|
118 |
-
*
|
119 |
*
|
120 |
*/
|
121 |
function customtaxorder_sort_taxonomies( $taxonomies = array() ) {
|
115 |
*
|
116 |
* Returns: array with list of taxonomies, ordered correctly.
|
117 |
*
|
118 |
+
* @since: 2.7.0
|
119 |
*
|
120 |
*/
|
121 |
function customtaxorder_sort_taxonomies( $taxonomies = array() ) {
|