Version Description
- 2022-03-14
- Support order by post count.
- Add filter 'customtaxorder_get_taxonomies'.
Download this release
Release Info
Developer | mpol |
Plugin | Custom Taxonomy Order NE |
Version | 3.4.0 |
Comparing to | |
See all releases |
Code changes from version 3.3.3 to 3.4.0
- customtaxorder.php +12 -4
- page-customtaxorder.php +7 -3
- readme.txt +7 -1
customtaxorder.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Custom Taxonomy Order
|
4 |
Plugin URI: https://wordpress.org/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: 3.
|
7 |
Author: Marcel Pol
|
8 |
Author URI: https://timelord.nl/
|
9 |
License: GPLv2 or later
|
@@ -34,13 +34,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
34 |
* TODO:
|
35 |
* - Add pagination, just like next_post_link().
|
36 |
* https://wordpress.org/support/topic/how-to-create-a-navigation-in-archivephp-with-the-given-order/
|
37 |
-
* -
|
38 |
-
* https://wordpress.org/support/topic/order-terms-by-post-count/
|
39 |
*/
|
40 |
|
41 |
|
42 |
// Plugin Version
|
43 |
-
define('CUSTOMTAXORDER_VER', '3.
|
44 |
|
45 |
|
46 |
/*
|
@@ -50,6 +49,7 @@ define('CUSTOMTAXORDER_VER', '3.3.3');
|
|
50 |
* 1: orderby Custom Order
|
51 |
* 2: orderby Term Name (alphabetical)
|
52 |
* 3: orderby Term Slug (alphabetical)
|
|
|
53 |
*
|
54 |
* @return array $customtaxorder_settings an array with key: $taxonomy->name and value:
|
55 |
*/
|
@@ -114,12 +114,16 @@ function customtaxorder_apply_order_filter( $orderby, $args ) {
|
|
114 |
return 't.term_order';
|
115 |
} else if ( $args['orderby'] == 'name' ) {
|
116 |
return 't.name';
|
|
|
|
|
117 |
} else if ( $options[$taxonomy] == 1 && ! customtaxorder_is_get_orderby_set() ) {
|
118 |
return 't.term_order';
|
119 |
} else if ( $options[$taxonomy] == 2 && ! customtaxorder_is_get_orderby_set() ) {
|
120 |
return 't.name';
|
121 |
} else if ( $options[$taxonomy] == 3 && ! customtaxorder_is_get_orderby_set() ) {
|
122 |
return 't.slug';
|
|
|
|
|
123 |
} else {
|
124 |
return $orderby;
|
125 |
}
|
@@ -151,6 +155,8 @@ function customtaxorder_get_terms_defaults( $query_var_defaults, $taxonomies ) {
|
|
151 |
$query_var_defaults['orderby'] = 'name';
|
152 |
} else if ( $options[$taxonomy] == 3 ) {
|
153 |
$query_var_defaults['orderby'] = 'slug';
|
|
|
|
|
154 |
}
|
155 |
|
156 |
return $query_var_defaults;
|
@@ -320,6 +326,8 @@ function customtaxorder_get_taxonomies() {
|
|
320 |
$output = 'objects';
|
321 |
$taxonomies = get_taxonomies( $args, $output );
|
322 |
|
|
|
|
|
323 |
return $taxonomies;
|
324 |
|
325 |
}
|
3 |
Plugin Name: Custom Taxonomy Order
|
4 |
Plugin URI: https://wordpress.org/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: 3.4.0
|
7 |
Author: Marcel Pol
|
8 |
Author URI: https://timelord.nl/
|
9 |
License: GPLv2 or later
|
34 |
* TODO:
|
35 |
* - Add pagination, just like next_post_link().
|
36 |
* https://wordpress.org/support/topic/how-to-create-a-navigation-in-archivephp-with-the-given-order/
|
37 |
+
* - Support other orderby's.
|
|
|
38 |
*/
|
39 |
|
40 |
|
41 |
// Plugin Version
|
42 |
+
define('CUSTOMTAXORDER_VER', '3.4.0');
|
43 |
|
44 |
|
45 |
/*
|
49 |
* 1: orderby Custom Order
|
50 |
* 2: orderby Term Name (alphabetical)
|
51 |
* 3: orderby Term Slug (alphabetical)
|
52 |
+
* 4: orderby Post Count (based on term_taxonomy table)
|
53 |
*
|
54 |
* @return array $customtaxorder_settings an array with key: $taxonomy->name and value:
|
55 |
*/
|
114 |
return 't.term_order';
|
115 |
} else if ( $args['orderby'] == 'name' ) {
|
116 |
return 't.name';
|
117 |
+
} else if ( $args['orderby'] == 'count' ) {
|
118 |
+
return 'tt.count'; // term_taxonomy table
|
119 |
} else if ( $options[$taxonomy] == 1 && ! customtaxorder_is_get_orderby_set() ) {
|
120 |
return 't.term_order';
|
121 |
} else if ( $options[$taxonomy] == 2 && ! customtaxorder_is_get_orderby_set() ) {
|
122 |
return 't.name';
|
123 |
} else if ( $options[$taxonomy] == 3 && ! customtaxorder_is_get_orderby_set() ) {
|
124 |
return 't.slug';
|
125 |
+
} else if ( $options[$taxonomy] == 4 && ! customtaxorder_is_get_orderby_set() ) {
|
126 |
+
return 'tt.count';
|
127 |
} else {
|
128 |
return $orderby;
|
129 |
}
|
155 |
$query_var_defaults['orderby'] = 'name';
|
156 |
} else if ( $options[$taxonomy] == 3 ) {
|
157 |
$query_var_defaults['orderby'] = 'slug';
|
158 |
+
}else if ( $options[$taxonomy] == 4 ) {
|
159 |
+
$query_var_defaults['orderby'] = 'count';
|
160 |
}
|
161 |
|
162 |
return $query_var_defaults;
|
326 |
$output = 'objects';
|
327 |
$taxonomies = get_taxonomies( $args, $output );
|
328 |
|
329 |
+
$taxonomies = apply_filters( 'customtaxorder_get_taxonomies', $taxonomies );
|
330 |
+
|
331 |
return $taxonomies;
|
332 |
|
333 |
}
|
page-customtaxorder.php
CHANGED
@@ -94,9 +94,11 @@ function customtaxorder_subpage() {
|
|
94 |
';
|
95 |
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="1" ' . checked('1', $options[$tax_name], false) . ' /> ' . esc_html__('Custom Order as defined above.', 'custom-taxonomy-order-ne') . '</label><br />
|
96 |
';
|
97 |
-
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="2" ' . checked('2', $options[$tax_name], false) . ' /> ' . esc_html__('Alphabetical Order by
|
98 |
';
|
99 |
-
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="3" ' . checked('3', $options[$tax_name], false) . ' /> ' . esc_html__('Alphabetical Order by
|
|
|
|
|
100 |
';
|
101 |
$settings .= '<input name="customtaxorder_taxname" type="hidden" value="' . esc_attr( $tax_name ) . '" />';
|
102 |
}
|
@@ -372,7 +374,9 @@ function customtaxorder_settings_validate( $input ) {
|
|
372 |
if ( $input[$taxonomy->name] != 1 ) {
|
373 |
if ( $input[$taxonomy->name] != 2 ) {
|
374 |
if ( $input[$taxonomy->name] != 3 ) {
|
375 |
-
$input[$taxonomy->name]
|
|
|
|
|
376 |
}
|
377 |
}
|
378 |
}
|
94 |
';
|
95 |
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="1" ' . checked('1', $options[$tax_name], false) . ' /> ' . esc_html__('Custom Order as defined above.', 'custom-taxonomy-order-ne') . '</label><br />
|
96 |
';
|
97 |
+
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="2" ' . checked('2', $options[$tax_name], false) . ' /> ' . esc_html__('Alphabetical Order by Name.', 'custom-taxonomy-order-ne') . '</label><br />
|
98 |
';
|
99 |
+
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="3" ' . checked('3', $options[$tax_name], false) . ' /> ' . esc_html__('Alphabetical Order by Slug.', 'custom-taxonomy-order-ne') . '</label><br />
|
100 |
+
';
|
101 |
+
$settings .= '<label><input type="radio" name="customtaxorder_settings" value="4" ' . checked('4', $options[$tax_name], false) . ' /> ' . esc_html__('Order by Post Count.', 'custom-taxonomy-order-ne') . '</label><br />
|
102 |
';
|
103 |
$settings .= '<input name="customtaxorder_taxname" type="hidden" value="' . esc_attr( $tax_name ) . '" />';
|
104 |
}
|
374 |
if ( $input[$taxonomy->name] != 1 ) {
|
375 |
if ( $input[$taxonomy->name] != 2 ) {
|
376 |
if ( $input[$taxonomy->name] != 3 ) {
|
377 |
+
if ( $input[$taxonomy->name] != 4 ) {
|
378 |
+
$input[$taxonomy->name] = 0; //default
|
379 |
+
}
|
380 |
}
|
381 |
}
|
382 |
}
|
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: 5.9
|
6 |
-
Stable tag: 3.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
@@ -160,6 +160,7 @@ You could add the following example to your functions.php and work from there.
|
|
160 |
* 1: orderby Custom Order
|
161 |
* 2: orderby Term Name (alphabetical)
|
162 |
* 3: orderby Term Slug (alphabetical)
|
|
|
163 |
*
|
164 |
* Taken from:
|
165 |
* https://wordpress.org/support/topic/product-categories-sort-how-to-sort-just-the-sub-terms-sub-categories/
|
@@ -212,6 +213,11 @@ The left metabox lists the toplevel terms. Right (or below) are the sub-terms.
|
|
212 |
|
213 |
== Changelog ==
|
214 |
|
|
|
|
|
|
|
|
|
|
|
215 |
= 3.3.3 =
|
216 |
* 2022-01-24
|
217 |
* Traverse all parents for sorting child terms, not just the toplevel ancestor.
|
3 |
Tags: term order, category order, taxonomy order, order
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 5.9
|
6 |
+
Stable tag: 3.4.0
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
160 |
* 1: orderby Custom Order
|
161 |
* 2: orderby Term Name (alphabetical)
|
162 |
* 3: orderby Term Slug (alphabetical)
|
163 |
+
* 4: orderby Post Count (based on term_taxonomy table)
|
164 |
*
|
165 |
* Taken from:
|
166 |
* https://wordpress.org/support/topic/product-categories-sort-how-to-sort-just-the-sub-terms-sub-categories/
|
213 |
|
214 |
== Changelog ==
|
215 |
|
216 |
+
= 3.4.0 =
|
217 |
+
* 2022-03-14
|
218 |
+
* Support order by post count.
|
219 |
+
* Add filter 'customtaxorder_get_taxonomies'.
|
220 |
+
|
221 |
= 3.3.3 =
|
222 |
* 2022-01-24
|
223 |
* Traverse all parents for sorting child terms, not just the toplevel ancestor.
|