Custom Taxonomy Order NE - Version 2.8.0

Version Description

  • 2016-10-04
  • Remove global var, add function customtaxorder_get_settings().
  • Fix PHP notices in customtaxorder_apply_order_filter.
Download this release

Release Info

Developer mpol
Plugin Icon 128x128 Custom Taxonomy Order NE
Version 2.8.0
Comparing to
See all releases

Version 2.8.0

css/customtaxorder.css ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Plugin Name: Custom Taxonomy Order NE
3
+ Plugin URI: http://timelord.nl/
4
+ */
5
+
6
+ /* Menu Icon */
7
+ #icon-customtaxorder {
8
+ background-image: url('../images/icon-128x128.png');
9
+ background-repeat: no-repeat;
10
+ margin: 0 10px 10px 0;
11
+ float: left;
12
+ width: 45px;
13
+ height: 45px;
14
+ background-size: contain;
15
+ }
16
+ .customtaxorder h1 {
17
+ line-height: 45px;
18
+ }
19
+
20
+ .customtaxorder .order-widget {
21
+ width: 512px;
22
+ }
23
+ .customtaxorder #poststuff .order-widget {
24
+ float: left;
25
+ margin: 0 20px 20px 0;
26
+ }
27
+ .customtaxorder #sub-posts,
28
+ .customtaxorder #go-sub-posts {
29
+ margin-top: 13px;
30
+ }
31
+
32
+ .customtaxorder .order-widget th {
33
+ padding-left: 12px;
34
+ }
35
+ .customtaxorder .metabox-holder h2.widget-top {
36
+ padding: 8px 12px;
37
+ }
38
+
39
+ .customtaxorder ul#custom-order-list {
40
+ list-style: none;
41
+ }
42
+ .customtaxorder li.lineitem {
43
+ border: 1px solid #dfdfdf;
44
+ -moz-border-radius: 3px;
45
+ -webkit-border-radius: 3px;
46
+ background-color: #fff;
47
+ cursor: move;
48
+ margin: 3px auto;
49
+ padding: 4px 8px 2px;
50
+ height: 24px;
51
+ line-height: 24px;
52
+ }
53
+ .customtaxorder li.outer {
54
+ background-color: #f5f5f5;
55
+ }
56
+ .customtaxorder .sortable-placeholder{
57
+ border: 1px dashed #dfdfdf;
58
+ margin: 3px auto;
59
+ height: 30px;
60
+ }
customtaxorder.php ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.0
7
+ Author: Marcel Pol
8
+ Author URI: http://zenoweb.nl/
9
+ License: GPLv2 or later
10
+ Text Domain: custom-taxonomy-order-ne
11
+ Domain Path: /lang/
12
+
13
+ /*
14
+ Copyright 2011 - 2011 Drew Gourley
15
+ Copyright 2013 - 2016 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
19
+ as published by the Free Software Foundation; either version 2
20
+ of the License, or (at your option) any later version.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program; if not, write to the Free Software
29
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
+ */
31
+
32
+
33
+ /* TODO:
34
+ * - Find a proper fix for tree of terms/subterms and ordering.
35
+ * - Add pagination, just like next_post_link().
36
+ * - 3.0: Switch to term_meta.
37
+ */
38
+
39
+
40
+ // Plugin Version
41
+ define('CUSTOMTAXORDER_VER', '2.8.0');
42
+
43
+
44
+ function customtaxorder_register_settings() {
45
+ register_setting('customtaxorder_settings', 'customtaxorder_settings', 'customtaxorder_settings_validate');
46
+ }
47
+ add_action('admin_init', 'customtaxorder_register_settings');
48
+
49
+
50
+ function customtaxorder_update_settings() {
51
+ $options = customtaxorder_get_settings();
52
+ if ( isset($options['update']) ) {
53
+ echo '<div class="updated fade notice is-dismissible" id="message"><p>' . __('Custom Taxonomy Order NE settings', 'custom-taxonomy-order-ne') . ' ' . $options['update'] . '</p></div>';
54
+ unset($options['update']);
55
+ update_option('customtaxorder_settings', $options);
56
+ }
57
+ }
58
+
59
+
60
+ function customtaxorder_settings_validate($input) {
61
+ $args = array( 'public' => true );
62
+ $output = 'objects';
63
+ $taxonomies = get_taxonomies( $args, $output );
64
+ foreach ( $taxonomies as $taxonomy ) {
65
+ if ( $input[$taxonomy->name] != 1 ) {
66
+ if ( $input[$taxonomy->name] != 2 ) {
67
+ $input[$taxonomy->name] = 0; //default
68
+ }
69
+ }
70
+ }
71
+ return $input;
72
+ }
73
+
74
+
75
+ function customtaxorder_menu() {
76
+ $args = array( 'public' => true );
77
+ $output = 'objects';
78
+ $taxonomies = get_taxonomies($args, $output);
79
+
80
+ // Also make the link_category available if activated.
81
+ $linkplugin = "link-manager/link-manager.php";
82
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
83
+ if ( is_plugin_active($linkplugin) ) {
84
+ $args = array( 'name' => 'link_category' );
85
+ $taxonomies2 = get_taxonomies( $args, $output );
86
+ $taxonomies = array_merge($taxonomies, $taxonomies2);
87
+ }
88
+
89
+ $taxonomies = customtaxorder_sort_taxonomies( $taxonomies );
90
+ // Set your custom capability through this filter.
91
+ $custom_cap = apply_filters( 'customtaxorder_custom_cap', 'manage_categories' );
92
+
93
+ add_menu_page(__('Term Order', 'customtaxorder'), __('Term Order', 'custom-taxonomy-order-ne'), $custom_cap, 'customtaxorder', 'customtaxorder', 'dashicons-list-view', 122.35);
94
+ add_submenu_page('customtaxorder', __('Order Taxonomies', 'custom-taxonomy-order-ne'), __('Order Taxonomies', 'custom-taxonomy-order-ne'), $custom_cap, 'customtaxorder-taxonomies', 'custom_taxonomy_order');
95
+
96
+ foreach ($taxonomies as $taxonomy ) {
97
+ // Set your finegrained capability for this taxonomy for this custom filter.
98
+ $custom_cap_tax = apply_filters( 'customtaxorder_custom_cap_' . $taxonomy->name, $custom_cap );
99
+ add_submenu_page('customtaxorder', __('Order ', 'custom-taxonomy-order-ne') . $taxonomy->label, __('Order ', 'custom-taxonomy-order-ne') . $taxonomy->label, $custom_cap_tax, 'customtaxorder-'.$taxonomy->name, 'customtaxorder');
100
+ }
101
+ add_submenu_page('customtaxorder', __('About', 'custom-taxonomy-order-ne'), __('About', 'custom-taxonomy-order-ne'), $custom_cap, 'customtaxorder-about', 'customtaxorder_about');
102
+ }
103
+ add_action('admin_menu', 'customtaxorder_menu');
104
+
105
+
106
+ function customtaxorder_css() {
107
+ if ( isset($_GET['page']) ) {
108
+ $pos_page = $_GET['page'];
109
+ $pos_args = 'customtaxorder';
110
+ $pos = strpos($pos_page,$pos_args);
111
+ if ( $pos === false ) {} else {
112
+ wp_enqueue_style('customtaxorder', plugins_url( 'css/customtaxorder.css', __FILE__), false, CUSTOMTAXORDER_VER, 'screen' );
113
+ }
114
+ }
115
+ }
116
+ add_action('admin_print_styles', 'customtaxorder_css');
117
+
118
+
119
+ function customtaxorder_js_libs() {
120
+ if ( isset($_GET['page']) ) {
121
+ $pos_page = $_GET['page'];
122
+ $pos_args = 'customtaxorder';
123
+ $pos = strpos($pos_page,$pos_args);
124
+ if ( $pos === false ) {} else {
125
+ wp_enqueue_script( 'jquery' );
126
+ wp_enqueue_script( 'jquery-ui-core' );
127
+ wp_enqueue_script( 'jquery-ui-sortable' );
128
+ wp_enqueue_script( 'customtaxorder', plugins_url( '/js/script.js', __FILE__ ), 'jquery-ui-sortable', CUSTOMTAXORDER_VER, true );
129
+ }
130
+ }
131
+ }
132
+ add_action('admin_print_scripts', 'customtaxorder_js_libs');
133
+
134
+
135
+ /*
136
+ * customtax_cmp
137
+ * Sorting of an array with objects, ordered by term_order
138
+ * Sorting the query with get_terms() doesn't allow sorting with term_order
139
+ */
140
+ function customtax_cmp( $a, $b ) {
141
+ if ( $a->term_order == $b->term_order ) {
142
+ return 0;
143
+ } else if ( $a->term_order < $b->term_order ) {
144
+ return -1;
145
+ } else {
146
+ return 1;
147
+ }
148
+ }
149
+
150
+
151
+ /*
152
+ * customtaxorder_update_order
153
+ * Function to update the database with the submitted order
154
+ */
155
+ function customtaxorder_update_order() {
156
+ if (isset($_POST['hidden-custom-order']) && $_POST['hidden-custom-order'] != "") {
157
+ global $wpdb;
158
+ $parent_ID_order = 0;
159
+ if ( isset($_POST['hidden-parent-id-order']) && $_POST['hidden-parent-id-order'] > 0 ) {
160
+ $parent_ID_order = (int) $_POST['hidden-parent-id-order'] + 1;
161
+ }
162
+ $new_order = $_POST['hidden-custom-order'];
163
+ $IDs = explode(",", $new_order);
164
+ $ids = Array();
165
+ $result = count($IDs);
166
+ for($i = 0; $i < $result; $i++) {
167
+ $id = (int) str_replace("id_", "", $IDs[$i]);
168
+ $j = $i + $parent_ID_order;
169
+ $wpdb->query( $wpdb->prepare(
170
+ "
171
+ UPDATE $wpdb->terms SET term_order = '%d' WHERE term_id ='%d'
172
+ ",
173
+ $j,
174
+ $id
175
+ ) );
176
+ $wpdb->query( $wpdb->prepare(
177
+ "
178
+ UPDATE $wpdb->term_relationships SET term_order = '%d' WHERE term_taxonomy_id ='%d'
179
+ ",
180
+ $j,
181
+ $id
182
+ ) );
183
+ $ids[] = $id;
184
+ }
185
+ echo '<div id="message" class="updated fade notice is-dismissible"><p>'. __('Order updated successfully.', 'custom-taxonomy-order-ne').'</p></div>';
186
+ do_action('customtaxorder_update_order', $ids);
187
+ } else {
188
+ echo '<div id="message" class="error fade notice is-dismissible"><p>'. __('An error occured, order has not been saved.', 'custom-taxonomy-order-ne').'</p></div>';
189
+ }
190
+ }
191
+
192
+
193
+ /*
194
+ * Flush object cache when order is changed in taxonomy ordering plugin.
195
+ *
196
+ * Since 2.7.8
197
+ *
198
+ */
199
+ function customtaxorder_flush_cache() {
200
+ wp_cache_flush();
201
+ }
202
+ add_action( 'customtaxorder_update_order', 'customtaxorder_flush_cache' );
203
+
204
+
205
+ /*
206
+ * customtaxorder_sub_query
207
+ * Function to give an option for the list of sub-taxonomies
208
+ */
209
+ function customtaxorder_sub_query( $terms, $tax ) {
210
+ $options = '';
211
+ foreach ( $terms as $term ) :
212
+ $subterms = get_term_children( $term->term_id, $tax );
213
+ if ( $subterms ) {
214
+ $options .= '<option value="' . $term->term_id . '">' . $term->name . '</option>';
215
+ }
216
+ endforeach;
217
+ return $options;
218
+ }
219
+
220
+
221
+ /*
222
+ * customtaxorder_apply_order_filter
223
+ * Function to sort the standard WordPress Queries.
224
+ *
225
+ * @return string t.orderby
226
+ *
227
+ */
228
+ function customtaxorder_apply_order_filter( $orderby, $args ) {
229
+ $options = customtaxorder_get_settings();
230
+
231
+ $taxonomy = 'category';
232
+ if ( isset( $args['taxonomy'] ) ) {
233
+ if ( is_string( $args['taxonomy'] ) && ! empty( $args['taxonomy'] ) ) {
234
+ $taxonomy = $args['taxonomy'];
235
+ } else if ( is_array( $args['taxonomy'] ) && ! empty( $args['taxonomy'] ) ) {
236
+ // Bug: if $args[$taxonomy] is an array with tax->names it will return the orderby for the first tax.
237
+ $taxonomy = array_shift( $args['taxonomy'] );
238
+ }
239
+ }
240
+
241
+ if ( ! isset( $options[$taxonomy] ) ) {
242
+ $options[$taxonomy] = 0; // Default if it was not set in options yet.
243
+ }
244
+
245
+ if ( $args['orderby'] == 'term_order' ) {
246
+ return 't.term_order';
247
+ } elseif ( $args['orderby'] == 'name' ) {
248
+ return 't.name';
249
+ } elseif ( $options[$taxonomy] == 1 && !isset($_GET['orderby']) ) {
250
+ return 't.term_order';
251
+ } elseif ( $options[$taxonomy] == 2 && !isset($_GET['orderby']) ) {
252
+ return 't.name';
253
+ } else {
254
+ return $orderby;
255
+ }
256
+ }
257
+ add_filter('get_terms_orderby', 'customtaxorder_apply_order_filter', 10, 2);
258
+
259
+
260
+ /*
261
+ * customtaxorder_wp_get_object_terms_order_filter
262
+ * wp_get_object_terms is used to sort in wp_get_object_terms and wp_get_post_terms functions.
263
+ * get_terms is used in wp_list_categories and get_terms functions.
264
+ * get_the_terms is used in the the_tags function.
265
+ * 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).
266
+ * Default sorting is by name (according to the codex).
267
+ *
268
+ */
269
+ function customtaxorder_wp_get_object_terms_order_filter( $terms ) {
270
+ $options = customtaxorder_get_settings();
271
+
272
+ if ( empty($terms) || ! is_array($terms) ) {
273
+ return $terms; // only work with an array of terms
274
+ }
275
+ foreach ($terms as $term) {
276
+ if ( is_object($term) && isset( $term->taxonomy ) ) {
277
+ $taxonomy = $term->taxonomy;
278
+ } else {
279
+ return $terms; // not an array with objects
280
+ }
281
+ break; // just the first one :)
282
+ }
283
+
284
+ if ( !isset ( $options[$taxonomy] ) ) {
285
+ $options[$taxonomy] = 0; // default if not set in options yet
286
+ }
287
+ if ( $options[$taxonomy] == 1 && !isset($_GET['orderby']) ) {
288
+ if (current_filter() == 'get_terms' ) {
289
+ $customtaxorder_exclude_taxonomies = array('post_tag', 'product_tag');
290
+ if ( in_array($taxonomy, apply_filters( 'customtaxorder_exclude_taxonomies', $customtaxorder_exclude_taxonomies )) ) {
291
+ // no filtering so the test in wp_generate_tag_cloud() works out right for us
292
+ // filtering will happen in the tag_cloud_sort filter sometime later
293
+ // post_tag = default tags
294
+ // product_tag = woocommerce product tags
295
+ return $terms;
296
+ }
297
+ }
298
+ usort($terms, 'customtax_cmp');
299
+ return $terms;
300
+ }
301
+ return $terms;
302
+ }
303
+ add_filter( 'wp_get_object_terms', 'customtaxorder_wp_get_object_terms_order_filter', 10, 3 );
304
+ add_filter( 'get_terms', 'customtaxorder_wp_get_object_terms_order_filter', 10, 3 );
305
+ add_filter( 'get_the_terms', 'customtaxorder_wp_get_object_terms_order_filter', 10, 3 );
306
+ add_filter( 'tag_cloud_sort', 'customtaxorder_wp_get_object_terms_order_filter', 10, 3 );
307
+
308
+
309
+ /*
310
+ * Support Advanced Custom Fields with its Taxonomy Fields.
311
+ */
312
+ function customtaxorder_wp_get_object_terms_order_filter_acf( $terms ) {
313
+
314
+ if ( empty($terms) || ! is_array($terms) ) {
315
+ return $terms; // only work with an array of terms
316
+ }
317
+ foreach ($terms as $term) {
318
+ if ( ! is_object($term) || ! is_a($term, 'WP_Term') ) {
319
+ return $terms; // not an array with terms
320
+ }
321
+ }
322
+
323
+ $terms = customtaxorder_wp_get_object_terms_order_filter( $terms );
324
+
325
+ return $terms;
326
+ }
327
+ add_filter('acf/format_value_for_api', 'customtaxorder_wp_get_object_terms_order_filter_acf', 99 );
328
+
329
+
330
+ /*
331
+ * customtaxorder_order_categories
332
+ * Filter to sort the categories according to term_order
333
+ *
334
+ */
335
+ function customtaxorder_order_categories( $categories ) {
336
+ $options = customtaxorder_get_settings();
337
+ if ( !isset ( $options['category'] ) ) {
338
+ $options['category'] = 0; // default if not set in options yet
339
+ }
340
+ if ( $options['category'] == 1 && !isset($_GET['orderby']) ) {
341
+ usort($categories, 'customtax_cmp');
342
+ return $categories;
343
+ }
344
+ return $categories;
345
+ }
346
+ add_filter('get_the_categories', 'customtaxorder_order_categories', 10, 3);
347
+
348
+
349
+ /*
350
+ * About page with text.
351
+ */
352
+ function customtaxorder_about() {
353
+ ?>
354
+ <div class='wrap'>
355
+ <h1><?php _e('About Custom Taxonomy Order NE', 'custom-taxonomy-order-ne'); ?></h1>
356
+ <div id="poststuff" class="metabox-holder">
357
+ <div class="widget">
358
+ <h2 class="widget-top"><?php _e('About this plugin.', 'custom-taxonomy-order-ne'); ?></h2>
359
+ <p><?php _e('This plugin is being maintained by Marcel Pol from', 'custom-taxonomy-order-ne'); ?>
360
+ <a href="http://zenoweb.nl" target="_blank" title="ZenoWeb">ZenoWeb</a>.
361
+ </p>
362
+
363
+ <h2 class="widget-top"><?php _e('Review this plugin.', 'custom-taxonomy-order-ne'); ?></h2>
364
+ <p><?php _e('If this plugin has any value to you, then please leave a review at', 'custom-taxonomy-order-ne'); ?>
365
+ <a href="https://wordpress.org/support/view/plugin-reviews/custom-taxonomy-order-ne?rate=5#postform" target="_blank" title="<?php esc_attr_e('The plugin page at wordpress.org.', 'custom-taxonomy-order-ne'); ?>">
366
+ <?php _e('the plugin page at wordpress.org', 'custom-taxonomy-order-ne'); ?></a>.
367
+ </p>
368
+
369
+ <h2 class="widget-top"><?php _e('Donate to the maintainer.', 'custom-taxonomy-order-ne'); ?></h2>
370
+ <p><?php _e('If you want to donate to the maintainer of the plugin, you can donate through PayPal.', 'custom-taxonomy-order-ne'); ?></p>
371
+ <p><?php _e('Donate through', 'custom-taxonomy-order-ne'); ?> <a href="https://www.paypal.com" target="_blank" title="<?php esc_attr_e('Donate to the maintainer.', 'custom-taxonomy-order-ne'); ?>"><?php _e('PayPal', 'custom-taxonomy-order-ne'); ?></a>
372
+ <?php _e('to', 'custom-taxonomy-order-ne'); ?> marcel@timelord.nl.
373
+ </p>
374
+ </div>
375
+ </div>
376
+ </div>
377
+ <?php
378
+ }
379
+
380
+
381
+ /*
382
+ * customtaxorder_links
383
+ * Add Settings link to the main plugin page
384
+ *
385
+ */
386
+ function customtaxorder_links( $links, $file ) {
387
+ if ( $file == plugin_basename( dirname(__FILE__).'/customtaxorder.php' ) ) {
388
+ $links[] = '<a href="' . admin_url( 'admin.php?page=customtaxorder' ) . '">' . __( 'Settings', 'custom-taxonomy-order-ne' ) . '</a>';
389
+ }
390
+ return $links;
391
+ }
392
+ add_filter( 'plugin_action_links', 'customtaxorder_links', 10, 2 );
393
+
394
+
395
+ /*
396
+ * Load language files.
397
+ */
398
+ function customtaxorder_load_lang() {
399
+ load_plugin_textdomain('custom-taxonomy-order-ne', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/');
400
+ }
401
+ add_action('plugins_loaded', 'customtaxorder_load_lang');
402
+
403
+
404
+ /*
405
+ * - set defaults
406
+ * - get settings
407
+ *
408
+ * $customtaxorder_settings is an array with key: $taxonomy->name and value: setting (0, 1, 2).
409
+ */
410
+ function customtaxorder_get_settings() {
411
+ $customtaxorder_defaults = array('category' => 0);
412
+
413
+ $args = array( 'public' => true, '_builtin' => false );
414
+ $output = 'objects';
415
+ $taxonomies = get_taxonomies( $args, $output );
416
+ foreach ( $taxonomies as $taxonomy ) {
417
+ $customtaxorder_defaults[$taxonomy->name] = 0;
418
+ }
419
+
420
+ $customtaxorder_defaults = apply_filters( 'customtaxorder_defaults', $customtaxorder_defaults );
421
+ $customtaxorder_settings = get_option( 'customtaxorder_settings' );
422
+ $customtaxorder_settings = wp_parse_args( $customtaxorder_settings, $customtaxorder_defaults );
423
+
424
+ return $customtaxorder_settings;
425
+ }
426
+
427
+
428
+ /*
429
+ * customtaxorder_activate
430
+ * Function called at activation time.
431
+ */
432
+ function _customtaxorder_activate() {
433
+ global $wpdb;
434
+ $init_query = $wpdb->query("SHOW COLUMNS FROM $wpdb->terms LIKE 'term_order'");
435
+ if ($init_query == 0) { $wpdb->query("ALTER TABLE $wpdb->terms ADD term_order INT( 4 ) NULL DEFAULT '0'"); }
436
+ }
437
+
438
+
439
+ function customtaxorder_activate($networkwide) {
440
+ global $wpdb;
441
+ if (function_exists('is_multisite') && is_multisite()) {
442
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
443
+ foreach ($blogids as $blog_id) {
444
+ switch_to_blog($blog_id);
445
+ _customtaxorder_activate();
446
+ restore_current_blog();
447
+ }
448
+ } else {
449
+ _customtaxorder_activate();
450
+ }
451
+ }
452
+ register_activation_hook( __FILE__, 'customtaxorder_activate' );
453
+
454
+
455
+ function customtaxorder_activate_new_site($blog_id) {
456
+ switch_to_blog($blog_id);
457
+ _customtaxorder_activate();
458
+ restore_current_blog();
459
+ }
460
+ add_action( 'wpmu_new_blog', 'customtaxorder_activate_new_site' );
461
+
462
+
463
+ // Include Settingspage
464
+ include('page-customtaxorder.php');
465
+ // Include functions for sorting taxonomies
466
+ include('taxonomies.php');
images/icon-128x128.png ADDED
Binary file
images/icon-256x256.png ADDED
Binary file
index.html ADDED
File without changes
js/script.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*
3
+ * Custom Taxonomy Order NE
4
+ */
5
+
6
+
7
+ jQuery(document).ready(function(jQuery) {
8
+
9
+ /* Submit button click event */
10
+ jQuery("#custom-loading").hide();
11
+ jQuery("#order-submit").click(function() {
12
+ customtaxorder_ordersubmit();
13
+ });
14
+
15
+ /* Button to sort the list alphabetically */
16
+ jQuery("#order-alpha").click(function(e) {
17
+ e.preventDefault();
18
+ jQuery("#custom-loading").show();
19
+ customtaxorder_orderalpha();
20
+ //jQuery("#order-submit").trigger("click");
21
+ setTimeout(function(){
22
+ jQuery("#custom-loading").hide();
23
+ },500);
24
+ jQuery("#order-alpha").blur();
25
+ });
26
+
27
+ });
28
+
29
+
30
+ function customtaxorder_addloadevent(){
31
+
32
+ /* Make the Terms sortable */
33
+ jQuery("#custom-order-list").sortable({
34
+ placeholder: "sortable-placeholder",
35
+ revert: false,
36
+ tolerance: "pointer"
37
+ });
38
+
39
+ /* The same for the Taxonomies */
40
+ jQuery("#custom-taxonomy-list").sortable({
41
+ placeholder: "sortable-placeholder",
42
+ revert: false,
43
+ tolerance: "pointer"
44
+ });
45
+
46
+ };
47
+ addLoadEvent(customtaxorder_addloadevent);
48
+
49
+
50
+ function customtaxorder_ordersubmit() {
51
+
52
+ /* Terms */
53
+ var newOrder = jQuery("#custom-order-list").sortable("toArray");
54
+ jQuery("#custom-loading").show();
55
+ jQuery("#hidden-custom-order").val(newOrder);
56
+
57
+ /* Taxonomies */
58
+ var newOrder_tax = jQuery("#custom-taxonomy-list").sortable("toArray");
59
+ jQuery("#custom-loading").show();
60
+ jQuery("#hidden-taxonomy-order").val(newOrder_tax);
61
+
62
+ return true;
63
+ }
64
+
65
+
66
+ function customtaxorder_orderalpha() {
67
+ jQuery("#custom-order-list li").sort(customtaxorder_asc_sort).appendTo('#custom-order-list');
68
+ var newOrder = jQuery("#custom-order-list").sortable("toArray");
69
+ jQuery("#custom-loading").show();
70
+ jQuery("#hidden-custom-order").val(newOrder);
71
+ return true;
72
+ }
73
+
74
+
75
+ // Ascending sort
76
+ function customtaxorder_asc_sort(a, b) {
77
+ //return (jQuery(b).text()) < (jQuery(a).text()) ? 1 : -1;
78
+ //console.log (jQuery(a).text());
79
+ return jQuery(a).text().toUpperCase().localeCompare(jQuery(b).text().toUpperCase());
80
+ }
81
+
lang/custom-taxonomy-order-ne-de_DE.mo ADDED
Binary file
lang/custom-taxonomy-order-ne-de_DE.po ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Custom Taxonomy Order NE 2.5.9\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2015-02-28 16:25+0100\n"
11
+ "PO-Revision-Date: 2015-02-28 16:33+0100\n"
12
+ "Last-Translator: Patrick Skiebe <patrick@skie.be>\n"
13
+ "Language-Team: \n"
14
+ "Language: de_DE\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 1.7.4\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ "X-Poedit-Basepath: .\n"
21
+ "X-Poedit-KeywordsList: __;_e\n"
22
+ "X-Poedit-SearchPath-0: ..\n"
23
+
24
+ #: ../customtaxorder.php:61
25
+ msgid "Term Order"
26
+ msgstr "Begriffs&shy;reihenfolge"
27
+
28
+ #: ../customtaxorder.php:63 ../customtaxorder.php:186
29
+ msgid "Order "
30
+ msgstr "Reihenfolge "
31
+
32
+ #: ../customtaxorder.php:112
33
+ msgid "Cheatin&#8217; uh?"
34
+ msgstr "Zugriff verweigert!"
35
+
36
+ #: ../customtaxorder.php:128
37
+ msgid ""
38
+ "The ordering of categories and custom taxonomy terms through a simple drag-"
39
+ "and-drop interface."
40
+ msgstr ""
41
+ "Die Sortierung von Kategorien und Begriffen eigener Taxonomien über eine "
42
+ "einfache Drag and Drop Oberfläche."
43
+
44
+ #: ../customtaxorder.php:130
45
+ msgid "Go to the plugin's Homepage"
46
+ msgstr "Die Homepage des Plugins besuchen"
47
+
48
+ #: ../customtaxorder.php:137
49
+ msgid "Taxonomies"
50
+ msgstr "Taxonomien"
51
+
52
+ #: ../customtaxorder.php:155
53
+ msgid "Order by ID (default)."
54
+ msgstr "Sortierung nach ID (Standard)."
55
+
56
+ #: ../customtaxorder.php:156
57
+ msgid "Custom Order as defined above."
58
+ msgstr "Eigene Reihenfolge, wie oben festgelegt."
59
+
60
+ #: ../customtaxorder.php:157
61
+ msgid "Alphabetical Order."
62
+ msgstr "Alphabetische Sortierung."
63
+
64
+ #: ../customtaxorder.php:201
65
+ msgid ""
66
+ "Order the taxonomies by dragging and dropping them into the desired order."
67
+ msgstr ""
68
+ "Sortieren Sie die Taxonomien, indem Sie sie mittels Drag and Drop an die "
69
+ "gewünschte Position ziehen."
70
+
71
+ #: ../customtaxorder.php:211
72
+ msgid "Return to Parent"
73
+ msgstr "Zum Elternelement"
74
+
75
+ #: ../customtaxorder.php:215
76
+ msgid "Update Order"
77
+ msgstr "Reihenfolge aktualisieren"
78
+
79
+ #: ../customtaxorder.php:216
80
+ msgid "Sort Alphabetical"
81
+ msgstr "Alphabetisch sortieren"
82
+
83
+ #: ../customtaxorder.php:225
84
+ msgid "Sub-"
85
+ msgstr "Unter-"
86
+
87
+ #: ../customtaxorder.php:225
88
+ msgid "Choose a term from the drop down to order its sub-terms."
89
+ msgstr ""
90
+ "Wählen Sie einen Begriff aus der Liste, um dessen Unterbegriffe zu sortieren."
91
+
92
+ #: ../customtaxorder.php:230
93
+ msgid "Order Sub-terms"
94
+ msgstr "Unterbegriffe sortieren"
95
+
96
+ #: ../customtaxorder.php:236
97
+ msgid "No terms found"
98
+ msgstr "Keine Begriffe gefunden"
99
+
100
+ #: ../customtaxorder.php:243 ../customtaxorder.php:481
101
+ msgid "Settings"
102
+ msgstr "Einstellungen"
103
+
104
+ #: ../customtaxorder.php:246
105
+ msgid "Auto-Sort Queries of this Taxonomy"
106
+ msgstr "Abfragen dieser Taxonomie automatisch sortieren"
107
+
108
+ #: ../customtaxorder.php:254
109
+ msgid "Save Settings"
110
+ msgstr "Einstellungen speichern"
111
+
112
+ #: ../customtaxorder.php:348
113
+ msgid "Order updated successfully."
114
+ msgstr "Reihenfolge erfolgreich aktualisiert."
115
+
116
+ #: ../customtaxorder.php:351
117
+ msgid "An error occured, order has not been saved."
118
+ msgstr "Ein Fehler ist aufgetreten, die Reihenfolge wurde nicht gespeichert."
lang/custom-taxonomy-order-ne-es_ES.mo ADDED
Binary file
lang/custom-taxonomy-order-ne-es_ES.po ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom Tax Order NE.
2
+ # Copyright (C) 2013 Marcel Pol
3
+ # This file is distributed under the same license as the Custom Tax Order NE package.
4
+ # Marcel Pol <marcel@timelord.nl>, 2013.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: 2.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-06 14:49+0200\n"
11
+ "PO-Revision-Date: 2013-12-10 15:22+0100\n"
12
+ "Last-Translator: Marcel Pol <marcel@timelord.nl>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+ "Language: es_ES\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 1.5.4\n"
19
+
20
+ #: customtaxorder.php:61
21
+ msgid "Term Order"
22
+ msgstr "Orden del Término"
23
+
24
+ #: customtaxorder.php:63 customtaxorder.php:176
25
+ msgid "Order "
26
+ msgstr "Orden "
27
+
28
+ #: customtaxorder.php:118
29
+ msgid ""
30
+ "The ordering of categories and custom taxonomy terms through a simple drag-"
31
+ "and-drop interface."
32
+ msgstr ""
33
+
34
+ #: customtaxorder.php:120
35
+ msgid "Go to the plugin's Homepage"
36
+ msgstr ""
37
+
38
+ #: customtaxorder.php:127
39
+ msgid "Taxonomies"
40
+ msgstr ""
41
+
42
+ #: customtaxorder.php:145
43
+ msgid "Order by ID (default)."
44
+ msgstr ""
45
+
46
+ #: customtaxorder.php:146
47
+ msgid "Custom Order as defined above."
48
+ msgstr ""
49
+
50
+ #: customtaxorder.php:147
51
+ msgid "Alphabetical Order."
52
+ msgstr ""
53
+
54
+ #: customtaxorder.php:191
55
+ msgid ""
56
+ "Order the taxonomies by dragging and dropping them into the desired order."
57
+ msgstr ""
58
+ "Ordene las taxonomías arrastrándolas y soltándolas en el orden deseado."
59
+
60
+ #: customtaxorder.php:201
61
+ msgid "Return to Parent"
62
+ msgstr "Volver al Padre"
63
+
64
+ #: customtaxorder.php:205
65
+ msgid "Update Order"
66
+ msgstr "Orden de Actualización"
67
+
68
+ #: customtaxorder.php:206
69
+ msgid "Sort Alphabetical"
70
+ msgstr ""
71
+
72
+ #: customtaxorder.php:215
73
+ msgid "Sub-"
74
+ msgstr "Sub-"
75
+
76
+ #: customtaxorder.php:215
77
+ msgid "Choose a term from the drop down to order its sub-terms."
78
+ msgstr ""
79
+ "Escoja un término desde el menú desplegable para ordenar sus sub términos."
80
+
81
+ #: customtaxorder.php:220
82
+ msgid "Order Sub-terms"
83
+ msgstr "Ordenar Sub términos"
84
+
85
+ #: customtaxorder.php:226
86
+ msgid "No terms found"
87
+ msgstr "No se encontraron términos"
88
+
89
+ #: customtaxorder.php:233 customtaxorder.php:465
90
+ msgid "Settings"
91
+ msgstr ""
92
+
93
+ #: customtaxorder.php:236
94
+ msgid "Auto-Sort Queries of this Taxonomy"
95
+ msgstr ""
96
+
97
+ #: customtaxorder.php:244
98
+ msgid "Save Settings"
99
+ msgstr "Salvar Ajustes"
100
+
101
+ #: customtaxorder.php:337
102
+ msgid "Order updated successfully."
103
+ msgstr "Ordenamiento actualizado satisfactoriamente."
104
+
105
+ #: customtaxorder.php:339
106
+ msgid "An error occured, order has not been saved."
107
+ msgstr "Un error ocurrió, el orden no ha sido salvado."
108
+
109
+ #~ msgid "Order Categories"
110
+ #~ msgstr "Categorías del Orden"
111
+
112
+ #~ msgid ""
113
+ #~ "Check this box if you want to enable Automatic Sorting of all instances "
114
+ #~ "from this taxonomy."
115
+ #~ msgstr ""
116
+ #~ "Seleccione esta casilla si desea habilitar el Ordenamiento Automático "
117
+ #~ "para todas las instancias de esta taxonomía."
118
+
119
+ #~ msgid "Auto-Sort Queries"
120
+ #~ msgstr "Consultas de auto ordenamiento"
lang/custom-taxonomy-order-ne-fr_FR.mo ADDED
Binary file
lang/custom-taxonomy-order-ne-fr_FR.po ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Custom Taxonomy Order NE\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-06 14:49+0200\n"
11
+ "PO-Revision-Date: 2014-05-13 10:58+0100\n"
12
+ "Last-Translator: Jean-Christophe Brebion <pro@jcbrebion.com>\n"
13
+ "Language-Team: Jean-Christophe Brebion <pro@jcbrebion.com>\n"
14
+ "Language: fr_FR\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 1.6.5\n"
19
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
20
+ "X-Poedit-SourceCharset: UTF-8\n"
21
+
22
+ #: customtaxorder.php:61
23
+ msgid "Term Order"
24
+ msgstr "Ordre"
25
+
26
+ #: customtaxorder.php:63 customtaxorder.php:176
27
+ msgid "Order "
28
+ msgstr "Ordre des "
29
+
30
+ #: customtaxorder.php:118
31
+ msgid ""
32
+ "The ordering of categories and custom taxonomy terms through a simple drag-"
33
+ "and-drop interface."
34
+ msgstr ""
35
+
36
+ #: customtaxorder.php:120
37
+ msgid "Go to the plugin's Homepage"
38
+ msgstr ""
39
+
40
+ #: customtaxorder.php:127
41
+ msgid "Taxonomies"
42
+ msgstr ""
43
+
44
+ #: customtaxorder.php:145
45
+ msgid "Order by ID (default)."
46
+ msgstr "Ordre par ID (par défaut)."
47
+
48
+ #: customtaxorder.php:146
49
+ msgid "Custom Order as defined above."
50
+ msgstr "Ordre personnalisé (tel que défini ci-dessus)."
51
+
52
+ #: customtaxorder.php:147
53
+ msgid "Alphabetical Order."
54
+ msgstr "Ordre alphabétique."
55
+
56
+ #: customtaxorder.php:191
57
+ msgid ""
58
+ "Order the taxonomies by dragging and dropping them into the desired order."
59
+ msgstr ""
60
+ "Triez les taxonomies en effectuant un glissé-déposé des termes dans l'ordre "
61
+ "souhaité."
62
+
63
+ #: customtaxorder.php:201
64
+ msgid "Return to Parent"
65
+ msgstr "Retour au Parent"
66
+
67
+ #: customtaxorder.php:205
68
+ msgid "Update Order"
69
+ msgstr "Mettre à jour"
70
+
71
+ #: customtaxorder.php:206
72
+ msgid "Sort Alphabetical"
73
+ msgstr "Tri alphabétique"
74
+
75
+ #: customtaxorder.php:215
76
+ msgid "Sub-"
77
+ msgstr "Sous-"
78
+
79
+ #: customtaxorder.php:215
80
+ msgid "Choose a term from the drop down to order its sub-terms."
81
+ msgstr ""
82
+ "Choisissez un terme dans la liste déroulante pour ordonner ses termes "
83
+ "enfants."
84
+
85
+ #: customtaxorder.php:220
86
+ msgid "Order Sub-terms"
87
+ msgstr "Ordre des termes enfants"
88
+
89
+ #: customtaxorder.php:226
90
+ msgid "No terms found"
91
+ msgstr "Aucun terme trouvé."
92
+
93
+ #: customtaxorder.php:233 customtaxorder.php:465
94
+ msgid "Settings"
95
+ msgstr "Réglages"
96
+
97
+ #: customtaxorder.php:236
98
+ msgid "Auto-Sort Queries of this Taxonomy"
99
+ msgstr "Tri automatique des requêtes pour cette Taxonomie."
100
+
101
+ #: customtaxorder.php:244
102
+ msgid "Save Settings"
103
+ msgstr "Enregistrer les réglages"
104
+
105
+ #: customtaxorder.php:337
106
+ msgid "Order updated successfully."
107
+ msgstr "Ordre mis à jour avec succès."
108
+
109
+ #: customtaxorder.php:339
110
+ msgid "An error occured, order has not been saved."
111
+ msgstr "Une erreur s'est produite, l'ordre n'a pas été enregistré."
112
+
113
+ #~ msgid "Order Categories"
114
+ #~ msgstr "Ordre des Catégories"
115
+
116
+ #~ msgid "Categories"
117
+ #~ msgstr "Catégories"
lang/custom-taxonomy-order-ne-it_IT.mo ADDED
Binary file
lang/custom-taxonomy-order-ne-it_IT.po ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Custom Taxonomy Order NE -2.3.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-06 14:49+0200\n"
11
+ "PO-Revision-Date: 2014-01-03 11:16+0100\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: Matteo Boria <matteo@8-p.it>\n"
14
+ "Language: it\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 1.6.3\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+ "X-Poedit-SourceCharset: UTF-8\n"
21
+
22
+ #: customtaxorder.php:61
23
+ msgid "Term Order"
24
+ msgstr "Ordina Categorie"
25
+
26
+ #: customtaxorder.php:63 customtaxorder.php:176
27
+ msgid "Order "
28
+ msgstr "Ordina "
29
+
30
+ #: customtaxorder.php:118
31
+ msgid ""
32
+ "The ordering of categories and custom taxonomy terms through a simple drag-"
33
+ "and-drop interface."
34
+ msgstr ""
35
+
36
+ #: customtaxorder.php:120
37
+ msgid "Go to the plugin's Homepage"
38
+ msgstr ""
39
+
40
+ #: customtaxorder.php:127
41
+ msgid "Taxonomies"
42
+ msgstr ""
43
+
44
+ #: customtaxorder.php:145
45
+ msgid "Order by ID (default)."
46
+ msgstr ""
47
+
48
+ #: customtaxorder.php:146
49
+ msgid "Custom Order as defined above."
50
+ msgstr ""
51
+
52
+ #: customtaxorder.php:147
53
+ msgid "Alphabetical Order."
54
+ msgstr ""
55
+
56
+ #: customtaxorder.php:191
57
+ msgid ""
58
+ "Order the taxonomies by dragging and dropping them into the desired order."
59
+ msgstr ""
60
+ "Ordina le tassonomie trascinandole (<em>drag&drop</em>) nell'ordine voluto"
61
+
62
+ #: customtaxorder.php:201
63
+ msgid "Return to Parent"
64
+ msgstr "Torna al genitore "
65
+
66
+ #: customtaxorder.php:205
67
+ msgid "Update Order"
68
+ msgstr "Aggiorna l'ordine"
69
+
70
+ #: customtaxorder.php:206
71
+ msgid "Sort Alphabetical"
72
+ msgstr ""
73
+
74
+ #: customtaxorder.php:215
75
+ msgid "Sub-"
76
+ msgstr "Sotto-"
77
+
78
+ #: customtaxorder.php:215
79
+ msgid "Choose a term from the drop down to order its sub-terms."
80
+ msgstr "Seleziona un termine dalla tendina per ordinare i suoi sotto-termini."
81
+
82
+ #: customtaxorder.php:220
83
+ msgid "Order Sub-terms"
84
+ msgstr "Ordina i Sotto-termini"
85
+
86
+ #: customtaxorder.php:226
87
+ msgid "No terms found"
88
+ msgstr "Nessun termine trovato"
89
+
90
+ #: customtaxorder.php:233 customtaxorder.php:465
91
+ msgid "Settings"
92
+ msgstr ""
93
+
94
+ #: customtaxorder.php:236
95
+ msgid "Auto-Sort Queries of this Taxonomy"
96
+ msgstr ""
97
+
98
+ #: customtaxorder.php:244
99
+ msgid "Save Settings"
100
+ msgstr "Salva i settaggi"
101
+
102
+ #: customtaxorder.php:337
103
+ msgid "Order updated successfully."
104
+ msgstr "Ordinamento aggiornato correttamente"
105
+
106
+ #: customtaxorder.php:339
107
+ msgid "An error occured, order has not been saved."
108
+ msgstr "Si è verificato un errore, ordine non salvato."
109
+
110
+ #~ msgid "Order Categories"
111
+ #~ msgstr "Ordina le Categorie"
112
+
113
+ #~ msgid ""
114
+ #~ "Check this box if you want to enable Automatic Sorting of all instances "
115
+ #~ "from this taxonomy."
116
+ #~ msgstr ""
117
+ #~ "Spunta se vuoi attivare l'Ordinamento Automatico di tutte le voci in "
118
+ #~ "questa tassonomia"
119
+
120
+ #~ msgid "Auto-Sort Queries"
121
+ #~ msgstr "Queries di auto-ordinamento"
lang/custom-taxonomy-order-ne-pl_PL.mo ADDED
Binary file
lang/custom-taxonomy-order-ne-pl_PL.po ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: Custom Taxonomy Order NE\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-06 14:49+0200\n"
11
+ "PO-Revision-Date: 2014-03-24 10:33+0100\n"
12
+ "Last-Translator: \n"
13
+ "Language-Team: Webidea.pl <paweldata@webidea.pl>\n"
14
+ "Language: pl_PL\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "X-Generator: Poedit 1.6.4\n"
19
+ "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
20
+ "|| n%100>=20) ? 1 : 2);\n"
21
+ "X-Poedit-SourceCharset: UTF-8\n"
22
+
23
+ #: customtaxorder.php:61
24
+ msgid "Term Order"
25
+ msgstr "Kolejność terminów"
26
+
27
+ #: customtaxorder.php:63 customtaxorder.php:176
28
+ msgid "Order "
29
+ msgstr "Sortuj "
30
+
31
+ #: customtaxorder.php:118
32
+ msgid ""
33
+ "The ordering of categories and custom taxonomy terms through a simple drag-"
34
+ "and-drop interface."
35
+ msgstr ""
36
+
37
+ #: customtaxorder.php:120
38
+ msgid "Go to the plugin's Homepage"
39
+ msgstr ""
40
+
41
+ #: customtaxorder.php:127
42
+ msgid "Taxonomies"
43
+ msgstr ""
44
+
45
+ #: customtaxorder.php:145
46
+ msgid "Order by ID (default)."
47
+ msgstr "Sortuj po ID (domyślnie)."
48
+
49
+ #: customtaxorder.php:146
50
+ msgid "Custom Order as defined above."
51
+ msgstr "Własna kolejność zdefiniowana powyżej."
52
+
53
+ #: customtaxorder.php:147
54
+ msgid "Alphabetical Order."
55
+ msgstr "Kolejność alfabetyczna."
56
+
57
+ #: customtaxorder.php:191
58
+ msgid ""
59
+ "Order the taxonomies by dragging and dropping them into the desired order."
60
+ msgstr "Sortuj terminy za pomocą metody przeciągnij i upuść."
61
+
62
+ #: customtaxorder.php:201
63
+ msgid "Return to Parent"
64
+ msgstr "Powróć do rodzica"
65
+
66
+ #: customtaxorder.php:205
67
+ msgid "Update Order"
68
+ msgstr "Zapisz kolejność"
69
+
70
+ #: customtaxorder.php:206
71
+ msgid "Sort Alphabetical"
72
+ msgstr "Sortuj alfabetycznie"
73
+
74
+ #: customtaxorder.php:215
75
+ msgid "Sub-"
76
+ msgstr "Pod-"
77
+
78
+ #: customtaxorder.php:215
79
+ msgid "Choose a term from the drop down to order its sub-terms."
80
+ msgstr "Wybierz termin z listy rozwijanej aby sortować terminy podrzędne"
81
+
82
+ #: customtaxorder.php:220
83
+ msgid "Order Sub-terms"
84
+ msgstr "Sortuj terminy podrzędne"
85
+
86
+ #: customtaxorder.php:226
87
+ msgid "No terms found"
88
+ msgstr "Nie znaleziono żadnego terminu"
89
+
90
+ #: customtaxorder.php:233 customtaxorder.php:465
91
+ msgid "Settings"
92
+ msgstr ""
93
+
94
+ #: customtaxorder.php:236
95
+ msgid "Auto-Sort Queries of this Taxonomy"
96
+ msgstr "Włącz funkcję Auto-Sort dla zapytań dla tej taksonomii"
97
+
98
+ #: customtaxorder.php:244
99
+ msgid "Save Settings"
100
+ msgstr "Zapisz ustawienia"
101
+
102
+ #: customtaxorder.php:337
103
+ msgid "Order updated successfully."
104
+ msgstr "Kolejność zapisana."
105
+
106
+ #: customtaxorder.php:339
107
+ msgid "An error occured, order has not been saved."
108
+ msgstr "Wystąpił błąd podczas zapisywania kolejności."
109
+
110
+ #~ msgid "Order Categories"
111
+ #~ msgstr "Sortuj kategorie"
112
+
113
+ #~ msgid ""
114
+ #~ "Check this box if you want to enable Automatic Sorting of all instances "
115
+ #~ "from this taxonomy."
116
+ #~ msgstr ""
117
+ #~ "Zaznacz to pole jeśli chcesz aby ta kolejność była wymuszona dla "
118
+ #~ "wszystkich instacji tej taksonomii"
119
+
120
+ #~ msgid "Auto-Sort Queries"
121
+ #~ msgstr "Zapytania auto-sortowania"
page-customtaxorder.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Admin Settingspage for Custom Taxonomy Order NE
4
+ */
5
+
6
+
7
+ function customtaxorder() {
8
+ global $sitepress;
9
+
10
+ customtaxorder_update_settings();
11
+ $options = customtaxorder_get_settings();
12
+ $settings = ''; // The input and text for the taxonomy that's shown
13
+ $parent_ID = 0;
14
+
15
+ // Get list of taxonomies
16
+ $args = array( 'public' => true );
17
+ $output = 'objects';
18
+ $taxonomies = get_taxonomies( $args, $output );
19
+
20
+ // Also make the link_category available if activated.
21
+ $linkplugin = "link-manager/link-manager.php";
22
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
23
+ if ( is_plugin_active($linkplugin) ) {
24
+ $args = array( 'name' => 'link_category' );
25
+ $taxonomies2 = get_taxonomies( $args, $output );
26
+ $taxonomies = array_merge($taxonomies, $taxonomies2);
27
+ }
28
+
29
+ if ( !empty( $taxonomies ) ) {
30
+ foreach ( $taxonomies as $taxonomy ) {
31
+ $com_page = 'customtaxorder-'.$taxonomy->name;
32
+ if ( !isset($options[$taxonomy->name]) ) {
33
+ $options[$taxonomy->name] = 0; // default if not set in options yet
34
+ }
35
+ if ( $_GET['page'] == $com_page ) {
36
+
37
+ // Set your custom capability through this filter.
38
+ $custom_cap = apply_filters( 'customtaxorder_custom_cap', 'manage_categories' );
39
+
40
+ // Set your finegrained capability for this taxonomy for this custom filter.
41
+ $custom_cap_tax = apply_filters( 'customtaxorder_custom_cap_' . $taxonomy->name, $custom_cap );
42
+
43
+ if ( function_exists('current_user_can') && !current_user_can( $custom_cap_tax ) ) {
44
+ die(__( 'Cheatin&#8217; uh?', 'custom-taxonomy-order-ne' ));
45
+ }
46
+ }
47
+ }
48
+ }
49
+
50
+ // Remove filter for WPML
51
+ remove_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10, 4 );
52
+ remove_filter( 'get_terms', array( $sitepress, 'get_terms_filter' ) );
53
+ ?>
54
+ <div class='wrap customtaxorder'>
55
+ <div id="icon-customtaxorder"></div>
56
+
57
+ <?php
58
+ if ( $_GET['page'] == 'customtaxorder' ) {
59
+ // Main admin page with just a set of links to the taxonomy pages.
60
+
61
+ // Set your custom capability through this filter.
62
+ $custom_cap = apply_filters( 'customtaxorder_custom_cap', 'manage_categories' );
63
+
64
+ if ( function_exists('current_user_can') && !current_user_can( $custom_cap ) ) {
65
+ die(__( 'Cheatin&#8217; uh?', 'custom-taxonomy-order-ne' ));
66
+ }
67
+
68
+ ?>
69
+ <h1>Custom Taxonomy Order NE</h1>
70
+ <div class="order-widget">
71
+ <p><?php _e('The ordering of categories and custom taxonomy terms through a simple drag-and-drop interface.', 'custom-taxonomy-order-ne'); ?></p>
72
+ <?php
73
+ if ( !empty( $taxonomies ) ) {
74
+ echo "<h2>" . __('Taxonomies', 'custom-taxonomy-order-ne') . "</h2><ul>";
75
+ $taxonomies = customtaxorder_sort_taxonomies( $taxonomies );
76
+ echo '<li class="lineitem"><a href="' . admin_url( 'admin.php?page=customtaxorder-taxonomies' ) . '">' . __('Taxonomies', 'custom-taxonomy-order-ne') . '</a></li>
77
+ ';
78
+ foreach ( $taxonomies as $taxonomy ) {
79
+ echo '<li class="lineitem"><a href="' . admin_url( 'admin.php?page=customtaxorder-' . $taxonomy->name ) . '">' . $taxonomy->label . '</a></li>
80
+ ';
81
+ }
82
+ }
83
+ echo '</ul></div></div><!-- #wrap -->';
84
+ return;
85
+ } else {
86
+ if ( !empty( $taxonomies ) ) {
87
+ foreach ( $taxonomies as $taxonomy ) {
88
+ $com_page = 'customtaxorder-'.$taxonomy->name;
89
+ if ( !isset($options[$taxonomy->name]) ) {
90
+ $options[$taxonomy->name] = 0; // default if not set in options yet
91
+ }
92
+ if ( $_GET['page'] == $com_page ) {
93
+ $settings .= '<label><input type="radio" name="customtaxorder_settings[' . $taxonomy->name . ']" value="0" ' . checked('0', $options[$taxonomy->name], false) . ' /> ' . __('Order by ID (default).', 'custom-taxonomy-order-ne') . '</label><br />
94
+ ';
95
+ $settings .= '<label><input type="radio" name="customtaxorder_settings[' . $taxonomy->name . ']" value="1" ' . checked('1', $options[$taxonomy->name], false) . ' /> ' . __('Custom Order as defined above.', 'custom-taxonomy-order-ne') . '</label><br />
96
+ ';
97
+ $settings .= '<label><input type="radio" name="customtaxorder_settings[' . $taxonomy->name . ']" value="2" ' . checked('2', $options[$taxonomy->name], false) . ' /> ' . __('Alphabetical Order.', 'custom-taxonomy-order-ne') . '</label><br />
98
+ ';
99
+ $tax_label = $taxonomy->label;
100
+ $tax = $taxonomy->name;
101
+ } else {
102
+ if ( !isset($options[$taxonomy->name]) ) {
103
+ $options[$taxonomy->name] = 0; // default if not set in options yet
104
+ }
105
+ $settings .= '<input name="customtaxorder_settings[' . $taxonomy->name . ']" type="hidden" value="' . $options[$taxonomy->name] . '" />';
106
+ }
107
+ }
108
+ }
109
+ }
110
+ $parent_ID_order = 0;
111
+ if (isset($_POST['go-sub-posts'])) {
112
+ $parent_ID = $_POST['sub-posts'];
113
+ }
114
+ elseif (isset($_POST['hidden-parent-id'])) {
115
+ $parent_term = get_term($_POST['hidden-parent-id'], $tax);
116
+ $parent_ID = $_POST['hidden-parent-id'];
117
+ if ( is_object($parent_term) && isset($parent_term->term_order) ) {
118
+ $parent_ID_order = $parent_term->term_order;
119
+ }
120
+ }
121
+ if (isset($_POST['return-sub-posts'])) {
122
+ $parent_term = get_term($_POST['hidden-parent-id'], $tax);
123
+ $parent_ID = $parent_term->parent;
124
+ }
125
+ $message = "";
126
+ if (isset($_POST['order-submit'])) {
127
+ customtaxorder_update_order();
128
+ }
129
+ ?>
130
+
131
+ <h1><?php echo __('Order ', 'custom-taxonomy-order-ne') . $tax_label; ?></h1>
132
+ <form name="custom-order-form" method="post" action="">
133
+ <?php
134
+ $args = array(
135
+ 'orderby' => 'term_order',
136
+ 'order' => 'ASC',
137
+ 'hide_empty' => false,
138
+ 'parent' => $parent_ID,
139
+ );
140
+ $terms = get_terms( $tax, $args );
141
+ if ( $terms ) {
142
+ usort($terms, 'customtax_cmp');
143
+ ?>
144
+ <div id="poststuff" class="metabox-holder">
145
+ <div class="widget order-widget">
146
+ <h2 class="widget-top"><?php _e( $tax_label) ?> | <small><?php _e('Order the taxonomies by dragging and dropping them into the desired order.', 'custom-taxonomy-order-ne') ?></small></h2>
147
+ <div class="misc-pub-section">
148
+ <ul id="custom-order-list">
149
+ <?php foreach ( $terms as $term ) : ?>
150
+ <li id="id_<?php echo $term->term_id; ?>" class="lineitem"><?php echo $term->name; ?></li>
151
+ <?php endforeach; ?>
152
+ </ul>
153
+ </div>
154
+ <div class="misc-pub-section misc-pub-section-last">
155
+ <?php if ($parent_ID != 0) { ?>
156
+ <input type="submit" class="button" style="float:left" id="return-sub-posts" name="return-sub-posts" value="<?php _e('Return to Parent', 'custom-taxonomy-order-ne'); ?>" />
157
+ <?php } ?>
158
+ <div id="publishing-action">
159
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" id="custom-loading" style="display:none" alt="" />
160
+ <input type="submit" name="order-submit" id="order-submit" class="button-primary" value="<?php _e('Update Order', 'custom-taxonomy-order-ne') ?>" />
161
+ <input type="submit" name="order-alpha" id="order-alpha" class="button" value="<?php _e('Sort Alphabetical', 'custom-taxonomy-order-ne') ?>" />
162
+ </div>
163
+ <div class="clear"></div>
164
+ </div>
165
+ <input type="hidden" id="hidden-custom-order" name="hidden-custom-order" />
166
+ <input type="hidden" id="hidden-parent-id" name="hidden-parent-id" value="<?php echo $parent_ID; ?>" />
167
+ <input type="hidden" id="hidden-parent-id-order" name="hidden-parent-id-order" value="<?php echo $parent_ID_order; ?>" />
168
+ </div>
169
+ <?php $dropdown = customtaxorder_sub_query( $terms, $tax ); if( !empty($dropdown) ) { ?>
170
+ <div class="widget order-widget">
171
+ <h2 class="widget-top"><?php print(__('Sub-', 'custom-taxonomy-order-ne').$tax_label); ?> | <small><?php _e('Choose a term from the drop down to order its sub-terms.', 'custom-taxonomy-order-ne'); ?></small></h2>
172
+ <div class="misc-pub-section misc-pub-section-last">
173
+ <select id="sub-posts" name="sub-posts">
174
+ <?php echo $dropdown; ?>
175
+ </select>
176
+ <input type="submit" name="go-sub-posts" class="button" id="go-sub-posts" value="<?php _e('Order Sub-terms', 'custom-taxonomy-order-ne') ?>" />
177
+ </div>
178
+ </div>
179
+ <?php } ?>
180
+ </div>
181
+ <?php } else { ?>
182
+ <p><?php _e('No terms found', 'custom-taxonomy-order-ne'); ?></p>
183
+ <?php } ?>
184
+ </form>
185
+ <form method="post" action="options.php" class="clear">
186
+ <?php settings_fields('customtaxorder_settings'); ?>
187
+ <div class="metabox-holder">
188
+ <div class="order-widget">
189
+ <h2 class="widget-top"><?php _e( 'Settings', 'custom-taxonomy-order-ne' ); ?></h2>
190
+ <table class="form-table">
191
+ <tr valign="top">
192
+ <th scope="row"><?php _e('Auto-Sort Queries of this Taxonomy', 'custom-taxonomy-order-ne') ?></th>
193
+ </tr>
194
+ <tr valign="top">
195
+ <td><?php echo $settings; ?></td>
196
+ </tr>
197
+ </table>
198
+ <input type="hidden" name="customtaxorder_settings[update]" value="Updated" />
199
+ <p class="submit">
200
+ <input type="submit" class="button-primary" value="<?php _e('Save Settings', 'custom-taxonomy-order-ne') ?>" />
201
+ </p>
202
+ </div>
203
+ </div>
204
+ </form>
205
+ </div>
206
+
207
+ <?php
208
+ }
readme.txt ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
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
6
+ Stable tag: 2.8.0
7
+ License: GPLv2 or later
8
+
9
+
10
+ Allows for the ordering of categories and custom taxonomy terms through a simple drag-and-drop interface
11
+
12
+ == Description ==
13
+
14
+ Custom Taxonomy Order New Edition is a plugin for WordPress which allows for the ordering of taxonomy terms.
15
+
16
+ It supports the following features:
17
+
18
+ * Order (custom) terms through a simple drag-and-drop interface.
19
+ * No custom coding needed. It uses standard WordPress filters.
20
+ * It uses the available WordPress scripts and styles.
21
+ * The plugin is lightweight, without any unnecessary scripts to load into the admin.
22
+ * It falls in line gracefully with the look and feel of the WordPress interface.
23
+ * It uses it's own menu in the backend.
24
+ * Translated or translatable.
25
+ * Custom functions to order the taxonomies themselves.
26
+ * There is no Pro version, everything works in the Free version.
27
+
28
+ It is a continuation (or fork) of Custom Taxonomy Order, which has been discontinued.
29
+
30
+
31
+ == Installation ==
32
+
33
+ 1. Upload the plugin folder to the `/wp-content/plugins/` directory
34
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
35
+ 3. Order posts from the 'Term Order' menu in the admin
36
+ 4. Optionally set whether or not to have queries of the selected taxonomy be sorted by this order automatically.
37
+ 5. Optionally set `'orderby' => 'term_order', 'order' => 'ASC'` to manually sort queries by this order.
38
+ 6. Enjoy!
39
+
40
+ == Upgrade Notice ==
41
+
42
+ If you update from the original Custom Taxonomy Order please deactivate that first, then activate this plugin.
43
+
44
+ == Frequently Asked Questions ==
45
+
46
+ = I sorted the terms in the WordPress backend, but I don't see it changed in the frontend =
47
+
48
+ Did you set the option for that taxonomy to use that custom order? Make sure to check it so the filters run
49
+ with your taxonomy.
50
+
51
+ = My custom taxonomy is not available in the menu page =
52
+
53
+ This plugin will only offer to sort them when the taxonomy is set to public. Make sure you use 'register_taxonomy'
54
+ with the public parameter set to true (default).
55
+
56
+ = How do I sort the terms when using a custom query? =
57
+
58
+ When you use default functions like get_terms or get_categories, this should not be needed.
59
+
60
+ If you do need to, you can apply the sorting for the taxonomy by using:
61
+ 'orderby' => 'term_order'.
62
+
63
+ = I use get_term_children but the terms do not get sorted =
64
+
65
+ This function only fetches the ID's of the terms, so it is impossible to sort them by term_order. If you do need the sort_order, use a function like get_terms with the 'child_of' parameter. That will fetch an array of WP_Term objects that can be sorted.
66
+
67
+ = I have a custom taxonomy that uses the Tag Cloud functionality, but it doesn't sort like it should. =
68
+
69
+ If it is a much used plugin, can you tell me what is the name for the taxonomy?
70
+ In the customtaxorder_wp_get_object_terms_order_filter it needs to be added, and the get_terms filter should not run
71
+ on that taxonomy. The tag_cloud_sort filter should do that.
72
+
73
+ If it is a custom taxonomy, you can also use a filter:
74
+
75
+ <?php
76
+ add_filter( 'customtaxorder_exclude_taxonomies', 'add_taxonomy_to_customtaxorder_exclude_taxonomies' );
77
+ function add_taxonomy_to_customtaxorder_exclude_taxonomies( $taxonomies ) {
78
+ $taxonomies[] = 'directory'; // name of your tag taxonomy.
79
+ return $taxonomies;
80
+ }
81
+ ?>
82
+
83
+ = I'm using the_tags function, but it doesn't sort as it should. =
84
+
85
+ There is a bug with the the_tags function, where it will sort according to the setting for categories.
86
+ This happens in the 'customtaxorder_apply_order_filter' function where the $args has two taxonomies but only one orderby can be returned.
87
+
88
+ = What capabilities are needed? =
89
+
90
+ For sorting the terms you need the manage_categories capability.
91
+
92
+ = Can I sort the taxonomies themselves? =
93
+
94
+ There is an admin page to sort them, and save them in the database.
95
+
96
+ You can use a function to sort taxonomies themselves like this:
97
+
98
+ <?php
99
+ $taxonomy_objects = get_object_taxonomies( 'post', 'objects' );
100
+ $taxonomy_objects = customtaxorder_sort_taxonomies($taxonomy_objects);
101
+ foreach ( $taxonomy_objects as $tax ) {
102
+ echo $tax->name . "<br />";
103
+ }
104
+ ?>
105
+
106
+ The function requires a parameter with an array of taxonomy objects.
107
+
108
+ = Is there an API? =
109
+
110
+ There is an action that you can use with add_action. It is being run when saving the order of terms in the admin page.
111
+ You could add the following example to your functions.php and work from there.
112
+
113
+ <?php
114
+ function custom_action($new_order) {
115
+ print_r($new_order);
116
+ }
117
+ add_action('customtaxorder_update_order', 'custom_action');
118
+ ?>
119
+
120
+ = How can I add my own translation? =
121
+
122
+ Translations can be added very easily through [GlotPress](https://translate.wordpress.org/projects/wp-plugins/custom-taxonomy-order-ne).
123
+ You can start translating strings there for your locale. They need to be validated though, so if there's no validator yet,
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.
132
+ The WordPress menu completely left lists the different taxonomies.
133
+ The left metabox lists the toplevel terms. Right (or below) are the sub-terms.
134
+
135
+ == Changelog ==
136
+
137
+ = 2.8.0 =
138
+ * 2016-10-04
139
+ * Remove global var, add function customtaxorder_get_settings().
140
+ * Fix PHP notices in customtaxorder_apply_order_filter.
141
+
142
+ = 2.7.8 =
143
+ * 2016-07-26
144
+ * Flush object cache when order is changed in taxonomy ordering plugin (props James Bonham).
145
+
146
+ = 2.7.7 =
147
+ * 2016-07-24
148
+ * Fix PHP warnings.
149
+ * Remove ru_RU translation, it is at 100% in GlotPress.
150
+ * Update Donate text.
151
+
152
+ = 2.7.6 =
153
+ * 2016-03-01
154
+ * Add filters for custom capabilities.
155
+
156
+ = 2.7.5 =
157
+ * 2016-01-11
158
+ * Support Advanced Custom Fields with its Taxonomy Fields.
159
+
160
+ = 2.7.4 =
161
+ * 2016-01-06
162
+ * Really fix Woo get_attribute() (thanks eddy_boy).
163
+
164
+ = 2.7.3 =
165
+ * 2015-11-26
166
+ * Fix for Woo get_attribute() (thanks mantish).
167
+
168
+ = 2.7.2 =
169
+ * 2015-11-26
170
+ * Properly enqueue admin scripts.
171
+ * Rename and prefix js functions properly.
172
+
173
+ = 2.7.1 =
174
+ * 2015-11-07
175
+ * Explode() expects parameter to be a string, not an array.
176
+ * Better dashicon.
177
+ * Drop pot, nl_NL, they are maintained at GlotPress.
178
+
179
+ = 2.7.0 =
180
+ * 2015-11-07
181
+ * Offer page and functions to support the taxonomies themselves.
182
+ * Support WooCommerce attributes.
183
+ * Only support WordPress 3.7+, since they really are supported.
184
+ * More specific CSS.
185
+ * Add icon on admin pages.
186
+ * Update pot, nl_NL.
187
+
188
+ = 2.6.6 =
189
+ * 2015-09-05
190
+ * Add filter for (not) sorting a tagcloud (thanks sunriseweb).
191
+ * For sub-term, start counting at term_order of parent-term, so sorting looks reasonable.
192
+ * "Order Alphabetically" button is no button-primary.
193
+ * Change textdomain to slug.
194
+ * Make admin_notices dismissible.
195
+ * Add version to admin CSS.
196
+
197
+ = 2.6.5 =
198
+ * 2015-08-05
199
+ * Use correct headings on admin pages.
200
+
201
+ = 2.6.4 =
202
+ * 2015-05-31
203
+ * Add About page.
204
+ * Update pot and nl_NL.
205
+
206
+ = 2.6.3 =
207
+ * 2015-03-25
208
+ * Support Link Manager plugin.
209
+
210
+ = 2.6.2 =
211
+ * 2015-03-21
212
+ * Better suppport for WPMU, also set up new blogs (thanks Andrew Patton).
213
+
214
+ = 2.6.1 =
215
+ * 2015-03-13
216
+ * Wrap radio buttons inside label, so the label works (thanks Andrew Patton).
217
+
218
+ = 2.6.0 =
219
+ * 2015-02-28
220
+ * Separate settingspage to own php-file.
221
+ * Add de_DE (thanks Patrick Skiebe).
222
+
223
+ = 2.5.9 =
224
+ * 2015-01-21
225
+ * Add test for capability inside admin page as well.
226
+
227
+ = 2.5.8 =
228
+ * 2014-12-11
229
+ * Fix conflict with wp-catalogue plugin
230
+
231
+ = 2.5.7 =
232
+ * 2014-09-12
233
+ * Fix notices with defensive programming
234
+
235
+ = 2.5.6 =
236
+ * 2014-08-22
237
+ * More compatibility with WPML
238
+
239
+ = 2.5.5 =
240
+ * 2014-08-20
241
+ * Some Compatibility with WPML Plugin
242
+
243
+ = 2.5.4 =
244
+ * 2014-08-15
245
+ * Add action for saving the terms
246
+
247
+ = 2.5.3 =
248
+ * 2014-08-06
249
+ * New default settings page
250
+ * Filter added for get_the_terms
251
+ * Don't filter tags at get_terms filtering
252
+ * Updated nl_NL
253
+
254
+ = 2.5.2 =
255
+ * 2014-06-30
256
+ * Also be able to sort the builtin taxonomies
257
+ * Fix bug with sorting tags
258
+
259
+ = 2.5.1 =
260
+ * 2014--5-13
261
+ * Added fr_FR (Jean-Christophe Brebion)
262
+
263
+ = 2.5.0 =
264
+ * 2014-05-02
265
+ * Added ru_RU (Alex Rumyantsev)
266
+ * Small gettext fixes
267
+ * update nl_NL
268
+
269
+ = 2.4.9 =
270
+ * 2014-04-15
271
+ * Multisite activation doesn't work if it isn't done network wide
272
+
273
+ = 2.4.8 =
274
+ * 2014-04-11
275
+ * Don't usort on an array which doesn't contain objects
276
+
277
+ = 2.4.7 =
278
+ * 2014-03-29
279
+ * Also filter at the get_terms hook for get_terms() and wp_list_categories()
280
+
281
+ = 2.4.6 =
282
+ * 2014-03-24
283
+ * Update pl_PL
284
+
285
+ = 2.4.5 =
286
+ * 2014-03-23
287
+ * Improve html/css
288
+
289
+ = 2.4.4 =
290
+ * 2014-03-23
291
+ * Remove obsolete images
292
+
293
+ = 2.4.3 =
294
+ * 2014-03-22
295
+ * Add settings link
296
+
297
+ = 2.4.2 =
298
+ * 2014-03-22
299
+ * New dashicon
300
+
301
+ = 2.4.1 =
302
+ * 2014-03-22
303
+ * Add alphabetical sorting to options as well
304
+ * Update Polish and Dutch
305
+
306
+ = 2.4.0 =
307
+ * 2014-03-18
308
+ * Add Polish translation (Paweł Data)
309
+ * Sort Alphabetically (landwire)
310
+
311
+ = 2.3.9 =
312
+ * 2014-02-25
313
+ * Fix activation code to really generate term_order column
314
+
315
+ = 2.3.8 =
316
+ * 2014-02-18
317
+ * Ouch, remove testing code
318
+
319
+ = 2.3.7 =
320
+ * 2014-02-18
321
+ * Fix activation on network install (Matteo Boria)
322
+
323
+ = 2.3.6 =
324
+ * 2014-01-26
325
+ * Also add filter for wp_get_object_terms and wp_get_post_terms
326
+
327
+ = 2.3.5 =
328
+ * 2014-01-26
329
+ * Only filter categories when auto-sort is enabled
330
+
331
+ = 2.3.4 =
332
+ * 2014-01-25
333
+ * Filter added for get_the_categories
334
+
335
+ = 2.3.3 =
336
+ * 2014-01-25
337
+ * Fix errors "undefined index" for undefined options
338
+
339
+ = 2.3.2 =
340
+ * 2014-01-03
341
+ * Use print for translated substring (Matteo Boria)
342
+ * Add Italian Translation (Matteo Boria)
343
+
344
+ = 2.3.1 =
345
+ * 2013-12-30
346
+ * Fix PHP error-notice when activating
347
+
348
+ = 2.3 =
349
+ * 2013-12-10
350
+ * Add es_ES translataion, thanks Andrew and Jelena
351
+
352
+ = 2.2 =
353
+ * 2013-10-20
354
+ * do init stuff in the init function
355
+ * also update term_order in term_relationships table
356
+ * security update: validate input with $wpdb->prepare()
357
+
358
+ = 2.1 =
359
+ * 2013-10-10
360
+ * renamed/forked as Custom Taxonomy Order New Edition
361
+ * fixed a bug with ordering in the backend
362
+ * add localisation
363
+ * add nl_NL lang
364
+
365
+ = 2.0 =
366
+ * Complete code overhaul and general rewrite to bring things up to speed
367
+ * Updated for WordPress 3.2 Admin Design
368
+ * Added auto-sort query option
369
+ * Several text fixes for overall consistency and clarity.
370
+ * Various small bugfixes and optimizations
371
+
372
+ = 1.0 =
373
+ * First Version
taxonomies.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ function custom_taxonomy_order() {
5
+
6
+ // Set your custom capability through this filter.
7
+ $custom_cap = apply_filters( 'customtaxorder_custom_cap', 'manage_categories' );
8
+
9
+ if ( function_exists('current_user_can') && !current_user_can( $custom_cap ) ) {
10
+ die(__( 'Cheatin&#8217; uh?', 'custom-taxonomy-order-ne' ));
11
+ }
12
+
13
+ if (isset($_POST['order-submit'])) {
14
+ customtaxorder_update_taxonomies();
15
+ }
16
+
17
+ ?>
18
+ <div class='wrap customtaxorder'>
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
+ <?php
24
+ $args = array();
25
+ $output = 'objects';
26
+ $taxonomies = get_taxonomies( $args, $output );
27
+
28
+ // Also make the link_category available if activated.
29
+ $linkplugin = "link-manager/link-manager.php";
30
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
31
+ if ( is_plugin_active($linkplugin) ) {
32
+ $args = array( 'name' => 'link_category' );
33
+ $taxonomies2 = get_taxonomies( $args, $output );
34
+ $taxonomies = array_merge($taxonomies, $taxonomies2);
35
+ }
36
+
37
+ if ( $taxonomies ) {
38
+
39
+ $taxonomies_ordered = customtaxorder_sort_taxonomies( $taxonomies );
40
+ ?>
41
+
42
+ <div id="poststuff" class="metabox-holder">
43
+ <div class="widget order-widget">
44
+ <h2 class="widget-top">
45
+ <?php _e('Order Taxonomies', 'custom-taxonomy-order-ne'); ?> |
46
+ <small><?php _e('Order the taxonomies by dragging and dropping them into the desired order.', 'custom-taxonomy-order-ne') ?></small>
47
+ </h2>
48
+ <div class="misc-pub-section">
49
+ <ul id="custom-taxonomy-list">
50
+ <?php
51
+ foreach ( $taxonomies_ordered as $taxonomy ) { ?>
52
+ <li id="<?php echo $taxonomy->name; ?>" class="lineitem"><?php echo $taxonomy->name; ?></li>
53
+ <?php
54
+ } ?>
55
+ </ul>
56
+ </div>
57
+ <div class="misc-pub-section misc-pub-section-last">
58
+ <div id="publishing-action">
59
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" id="custom-loading" style="display:none" alt="" />
60
+ <input type="submit" name="order-submit" id="order-submit" class="button-primary" value="<?php _e('Update Order', 'custom-taxonomy-order-ne') ?>" />
61
+ </div>
62
+ <div class="clear"></div>
63
+ </div>
64
+ <input type="hidden" id="hidden-taxonomy-order" name="hidden-taxonomy-order" />
65
+ </div>
66
+ </div>
67
+
68
+ <?php } else { ?>
69
+ <p><?php _e('No taxonomies found', 'custom-taxonomy-order-ne'); ?></p>
70
+ <?php }
71
+ ?>
72
+ </form>
73
+ </div>
74
+ <?php
75
+ }
76
+
77
+
78
+ /*
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>';
90
+ } else {
91
+ echo '<div id="message" class="error fade notice is-dismissible"><p>'. __('An error occured, order has not been saved.', 'custom-taxonomy-order-ne').'</p></div>';
92
+ }
93
+ }
94
+
95
+
96
+ /*
97
+ * Sort the taxonomies
98
+ *
99
+ * Parameter: $taxonomies, array with a list of taxonomy objects.
100
+ *
101
+ * Returns: array with list of taxonomies, ordered correctly.
102
+ *
103
+ * Since: 2.7.0
104
+ *
105
+ */
106
+ function customtaxorder_sort_taxonomies( $taxonomies = array() ) {
107
+ $order = get_option( 'customtaxorder_taxonomies', '' );
108
+ $order = explode( ",", $order );
109
+ $taxonomies_ordered = array();
110
+
111
+ // Main sorted taxonomies.
112
+ if ( ! empty($order) && is_array($order) && ! empty($taxonomies) && is_array($taxonomies) ) {
113
+ foreach ( $order as $tax ) {
114
+ foreach ( $taxonomies as $tax_name => $tax_obj ) {
115
+ if ( is_object( $tax_obj ) && $tax === $tax_name ) {
116
+ $taxonomies_ordered[ $tax_name ] = $tax_obj;
117
+ unset( $taxonomies[ $tax_name ] );
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ // Unsorted taxonomies, the leftovers.
124
+ foreach ( $taxonomies as $tax_name => $tax_obj ) {
125
+ $taxonomies_ordered[ $tax_name ] = $tax_obj;
126
+ }
127
+
128
+ return $taxonomies_ordered;
129
+ }
130
+
131
+
132
+ /*
133
+ * Same as customtaxorder_sort_taxonomies, but for WooCommerce.
134
+ *
135
+ * Parameter: $taxonomies, array with a list of taxonomy arrays.
136
+ *
137
+ * Returns: array with list of taxonomies, ordered correctly.
138
+ *
139
+ * Since: 2.7.0
140
+ *
141
+ */
142
+ function customtaxorder_sort_taxonomies_array( $taxonomies = array() ) {
143
+ $order = get_option( 'customtaxorder_taxonomies', '' );
144
+ $order = explode( ",", $order );
145
+ $taxonomies_woo = array();
146
+
147
+ // Main sorted taxonomies.
148
+ if ( ! empty($order) && is_array($order) && ! empty($taxonomies) && is_array($taxonomies) ) {
149
+ foreach ( $order as $tax ) {
150
+ foreach ( $taxonomies as $key => $taxonomy ) {
151
+ if ( is_array( $taxonomy ) && $tax === $taxonomy['name'] ) {
152
+ $taxonomies_woo[ $taxonomy['name'] ] = $taxonomy;
153
+ unset( $taxonomies[$taxonomy['name']] );
154
+ }
155
+ }
156
+ }
157
+ }
158
+
159
+ // Unsorted taxonomies, the leftovers.
160
+ foreach ( $taxonomies as $key => $taxonomy ) {
161
+ $taxonomies_woo[ $key ] = $taxonomy;
162
+ }
163
+
164
+ return $taxonomies_woo;
165
+ }
166
+ add_filter( 'woocommerce_get_product_attributes', 'customtaxorder_sort_taxonomies_array' );