Version Description
- 2017-03-29
- Add Nonce check to admin pages.
- Register setting for taxonomies too, with callback function.
- Run sanitize_text_field on the keyname in the option for customtaxorder_settings.
Download this release
Release Info
Developer | mpol |
Plugin | Custom Taxonomy Order NE |
Version | 2.8.3 |
Comparing to | |
See all releases |
Code changes from version 2.8.2 to 2.8.3
- customtaxorder.php +33 -4
- page-customtaxorder.php +6 -2
- readme.txt +8 -4
- taxonomies.php +18 -3
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.8.
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl/
|
9 |
License: GPLv2 or later
|
@@ -12,7 +12,7 @@ Domain Path: /lang/
|
|
12 |
|
13 |
/*
|
14 |
Copyright 2011 - 2011 Drew Gourley
|
15 |
-
Copyright 2013 -
|
16 |
|
17 |
This program is free software; you can redistribute it and/or
|
18 |
modify it under the terms of the GNU General Public License
|
@@ -32,15 +32,21 @@ Domain Path: /lang/
|
|
32 |
|
33 |
/* TODO:
|
34 |
* - Add pagination, just like next_post_link().
|
|
|
|
|
|
|
|
|
|
|
35 |
*/
|
36 |
|
37 |
|
38 |
// Plugin Version
|
39 |
-
define('CUSTOMTAXORDER_VER', '2.8.
|
40 |
|
41 |
|
42 |
function customtaxorder_register_settings() {
|
43 |
register_setting('customtaxorder_settings', 'customtaxorder_settings', 'customtaxorder_settings_validate');
|
|
|
44 |
}
|
45 |
add_action('admin_init', 'customtaxorder_register_settings');
|
46 |
|
@@ -87,10 +93,18 @@ function customtaxorder_settings_validate($input) {
|
|
87 |
}
|
88 |
}
|
89 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
return $input;
|
91 |
}
|
92 |
|
93 |
-
|
94 |
function customtaxorder_menu() {
|
95 |
$args = array( 'public' => true );
|
96 |
$output = 'objects';
|
@@ -172,6 +186,18 @@ function customtax_cmp( $a, $b ) {
|
|
172 |
* Function to update the database with the submitted order
|
173 |
*/
|
174 |
function customtaxorder_update_order() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
if (isset($_POST['hidden-custom-order']) && $_POST['hidden-custom-order'] != "") {
|
176 |
global $wpdb;
|
177 |
$parent_ID_order = 0;
|
@@ -278,10 +304,13 @@ add_filter('get_terms_orderby', 'customtaxorder_apply_order_filter', 10, 2);
|
|
278 |
|
279 |
/*
|
280 |
* customtaxorder_wp_get_object_terms_order_filter
|
|
|
|
|
281 |
* wp_get_object_terms is used to sort in wp_get_object_terms and wp_get_post_terms functions.
|
282 |
* get_terms is used in wp_list_categories and get_terms functions.
|
283 |
* get_the_terms is used in the the_tags function.
|
284 |
* tag_cloud_sort is used in the wp_tag_cloud and wp_generate_tag_cloud functions (but then the get_terms filter here does nothing).
|
|
|
285 |
* Default sorting is by name (according to the codex).
|
286 |
*
|
287 |
*/
|
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.8.3
|
7 |
Author: Marcel Pol
|
8 |
Author URI: http://zenoweb.nl/
|
9 |
License: GPLv2 or later
|
12 |
|
13 |
/*
|
14 |
Copyright 2011 - 2011 Drew Gourley
|
15 |
+
Copyright 2013 - 2017 Marcel Pol (email: marcel@timelord.nl)
|
16 |
|
17 |
This program is free software; you can redistribute it and/or
|
18 |
modify it under the terms of the GNU General Public License
|
32 |
|
33 |
/* TODO:
|
34 |
* - Add pagination, just like next_post_link().
|
35 |
+
* https://wordpress.org/support/topic/how-to-create-a-navigation-in-archivephp-with-the-given-order/
|
36 |
+
* - Order by post count (and other orderby's)
|
37 |
+
* https://wordpress.org/support/topic/order-terms-by-post-count/
|
38 |
+
* - Order Woo terms, also after filtering products with widgets:
|
39 |
+
* https://wordpress.org/support/topic/plugin-does-not-keep-custom-order-when-using-filter/
|
40 |
*/
|
41 |
|
42 |
|
43 |
// Plugin Version
|
44 |
+
define('CUSTOMTAXORDER_VER', '2.8.3');
|
45 |
|
46 |
|
47 |
function customtaxorder_register_settings() {
|
48 |
register_setting('customtaxorder_settings', 'customtaxorder_settings', 'customtaxorder_settings_validate');
|
49 |
+
register_setting('customtaxorder_settings', 'customtaxorder_taxonomies', 'customtaxorder_taxonomies_validate');
|
50 |
}
|
51 |
add_action('admin_init', 'customtaxorder_register_settings');
|
52 |
|
93 |
}
|
94 |
}
|
95 |
}
|
96 |
+
$output = array();
|
97 |
+
foreach ( $input as $key => $value) {
|
98 |
+
$key = (string) sanitize_text_field( $key );
|
99 |
+
$output[$key] = (int) $value;
|
100 |
+
}
|
101 |
+
return $output;
|
102 |
+
}
|
103 |
+
function customtaxorder_taxonomies_validate($input) {
|
104 |
+
$input = (string) sanitize_text_field( $input );
|
105 |
return $input;
|
106 |
}
|
107 |
|
|
|
108 |
function customtaxorder_menu() {
|
109 |
$args = array( 'public' => true );
|
110 |
$output = 'objects';
|
186 |
* Function to update the database with the submitted order
|
187 |
*/
|
188 |
function customtaxorder_update_order() {
|
189 |
+
|
190 |
+
/* Check Nonce */
|
191 |
+
$verified = false;
|
192 |
+
if ( isset($_POST['custom-taxonomy-order-ne-nonce']) ) {
|
193 |
+
$verified = wp_verify_nonce( $_POST['custom-taxonomy-order-ne-nonce'], 'custom-taxonomy-order-ne-nonce' );
|
194 |
+
}
|
195 |
+
if ( $verified == false ) {
|
196 |
+
// Nonce is invalid.
|
197 |
+
echo '<div id="message" class="error fade notice is-dismissible"><p>' . __('The Nonce did not validate. Please try again.', 'custom-taxonomy-order-ne') . '</p></div>';
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
if (isset($_POST['hidden-custom-order']) && $_POST['hidden-custom-order'] != "") {
|
202 |
global $wpdb;
|
203 |
$parent_ID_order = 0;
|
304 |
|
305 |
/*
|
306 |
* customtaxorder_wp_get_object_terms_order_filter
|
307 |
+
*
|
308 |
+
* Filters:
|
309 |
* wp_get_object_terms is used to sort in wp_get_object_terms and wp_get_post_terms functions.
|
310 |
* get_terms is used in wp_list_categories and get_terms functions.
|
311 |
* get_the_terms is used in the the_tags function.
|
312 |
* tag_cloud_sort is used in the wp_tag_cloud and wp_generate_tag_cloud functions (but then the get_terms filter here does nothing).
|
313 |
+
*
|
314 |
* Default sorting is by name (according to the codex).
|
315 |
*
|
316 |
*/
|
page-customtaxorder.php
CHANGED
@@ -129,8 +129,12 @@ function customtaxorder() {
|
|
129 |
?>
|
130 |
|
131 |
<h1><?php echo __('Order ', 'custom-taxonomy-order-ne') . $tax_label; ?></h1>
|
132 |
-
<form name="custom-order-form" method="post" action=""
|
133 |
-
|
|
|
|
|
|
|
|
|
134 |
$args = array(
|
135 |
'orderby' => 'term_order',
|
136 |
'order' => 'ASC',
|
129 |
?>
|
130 |
|
131 |
<h1><?php echo __('Order ', 'custom-taxonomy-order-ne') . $tax_label; ?></h1>
|
132 |
+
<form name="custom-order-form" method="post" action=""><?php
|
133 |
+
|
134 |
+
/* Nonce */
|
135 |
+
$nonce = wp_create_nonce( 'custom-taxonomy-order-ne-nonce' );
|
136 |
+
echo '<input type="hidden" id="custom-taxonomy-order-ne-nonce" name="custom-taxonomy-order-ne-nonce" value="' . $nonce . '" />';
|
137 |
+
|
138 |
$args = array(
|
139 |
'orderby' => 'term_order',
|
140 |
'order' => 'ASC',
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: mpol
|
3 |
Tags: order, ordering, sorting, terms, term order, term ordering, terms order, terms ordering, categories, category order, category ordering, categories order, categories ordering, custom taxonomies, taxonomy order, taxonomy ordering, taxonomies order, taxonomies ordering
|
4 |
Requires at least: 3.7
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 2.8.
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
@@ -124,8 +124,6 @@ You can start translating strings there for your locale. They need to be validat
|
|
124 |
and you want to apply for being validator, please post it on the support forum. I will make a request on make/polyglots to
|
125 |
have you added as validator for this plugin/locale.
|
126 |
|
127 |
-
Email any other questions to marcel at timelord dot nl.
|
128 |
-
|
129 |
== Screenshots ==
|
130 |
|
131 |
1. Screenshot of the menu page for Custom Taxonomy Order.
|
@@ -134,6 +132,12 @@ The left metabox lists the toplevel terms. Right (or below) are the sub-terms.
|
|
134 |
|
135 |
== Changelog ==
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
= 2.8.2 =
|
138 |
* 2016-10-19
|
139 |
* Only skip one sort for tags on frontend, not admin.
|
2 |
Contributors: mpol
|
3 |
Tags: order, ordering, sorting, terms, term order, term ordering, terms order, terms ordering, categories, category order, category ordering, categories order, categories ordering, custom taxonomies, taxonomy order, taxonomy ordering, taxonomies order, taxonomies ordering
|
4 |
Requires at least: 3.7
|
5 |
+
Tested up to: 4.8
|
6 |
+
Stable tag: 2.8.3
|
7 |
License: GPLv2 or later
|
8 |
|
9 |
|
124 |
and you want to apply for being validator, please post it on the support forum. I will make a request on make/polyglots to
|
125 |
have you added as validator for this plugin/locale.
|
126 |
|
|
|
|
|
127 |
== Screenshots ==
|
128 |
|
129 |
1. Screenshot of the menu page for Custom Taxonomy Order.
|
132 |
|
133 |
== Changelog ==
|
134 |
|
135 |
+
= 2.8.3 =
|
136 |
+
* 2017-03-29
|
137 |
+
* Add Nonce check to admin pages.
|
138 |
+
* Register setting for taxonomies too, with callback function.
|
139 |
+
* Run sanitize_text_field on the keyname in the option for customtaxorder_settings.
|
140 |
+
|
141 |
= 2.8.2 =
|
142 |
* 2016-10-19
|
143 |
* Only skip one sort for tags on frontend, not admin.
|
taxonomies.php
CHANGED
@@ -19,8 +19,12 @@ function custom_taxonomy_order() {
|
|
19 |
<div id="icon-customtaxorder"></div>
|
20 |
<h1><?php _e('Order Taxonomies', 'custom-taxonomy-order-ne'); ?></h1>
|
21 |
|
22 |
-
<form name="custom-order-form" method="post" action=""
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
$args = array();
|
25 |
$output = 'objects';
|
26 |
$taxonomies = get_taxonomies( $args, $output );
|
@@ -79,11 +83,22 @@ function custom_taxonomy_order() {
|
|
79 |
* Save order of the taxonomies in an option
|
80 |
*/
|
81 |
function customtaxorder_update_taxonomies() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
if (isset($_POST['hidden-taxonomy-order']) && $_POST['hidden-taxonomy-order'] != "") {
|
83 |
|
84 |
$new_order = $_POST['hidden-taxonomy-order'];
|
85 |
$new_order = sanitize_text_field( $new_order );
|
86 |
-
|
87 |
update_option('customtaxorder_taxonomies', $new_order);
|
88 |
|
89 |
echo '<div id="message" class="updated fade notice is-dismissible"><p>'. __('Order updated successfully.', 'custom-taxonomy-order-ne').'</p></div>';
|
19 |
<div id="icon-customtaxorder"></div>
|
20 |
<h1><?php _e('Order Taxonomies', 'custom-taxonomy-order-ne'); ?></h1>
|
21 |
|
22 |
+
<form name="custom-order-form" method="post" action=""><?php
|
23 |
+
|
24 |
+
/* Nonce */
|
25 |
+
$nonce = wp_create_nonce( 'custom-taxonomy-order-ne-nonce' );
|
26 |
+
echo '<input type="hidden" id="custom-taxonomy-order-ne-nonce" name="custom-taxonomy-order-ne-nonce" value="' . $nonce . '" />';
|
27 |
+
|
28 |
$args = array();
|
29 |
$output = 'objects';
|
30 |
$taxonomies = get_taxonomies( $args, $output );
|
83 |
* Save order of the taxonomies in an option
|
84 |
*/
|
85 |
function customtaxorder_update_taxonomies() {
|
86 |
+
|
87 |
+
/* Check Nonce */
|
88 |
+
$verified = false;
|
89 |
+
if ( isset($_POST['custom-taxonomy-order-ne-nonce']) ) {
|
90 |
+
$verified = wp_verify_nonce( $_POST['custom-taxonomy-order-ne-nonce'], 'custom-taxonomy-order-ne-nonce' );
|
91 |
+
}
|
92 |
+
if ( $verified == false ) {
|
93 |
+
// Nonce is invalid.
|
94 |
+
echo '<div id="message" class="error fade notice is-dismissible"><p>' . __('The Nonce did not validate. Please try again.', 'custom-taxonomy-order-ne') . '</p></div>';
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
if (isset($_POST['hidden-taxonomy-order']) && $_POST['hidden-taxonomy-order'] != "") {
|
99 |
|
100 |
$new_order = $_POST['hidden-taxonomy-order'];
|
101 |
$new_order = sanitize_text_field( $new_order );
|
|
|
102 |
update_option('customtaxorder_taxonomies', $new_order);
|
103 |
|
104 |
echo '<div id="message" class="updated fade notice is-dismissible"><p>'. __('Order updated successfully.', 'custom-taxonomy-order-ne').'</p></div>';
|