Category Order and Taxonomy Terms Order - Version 1.5.3

Version Description

  • Use JSON instead serialize method when sending order through AJAX
    • Updated PO language file
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 Category Order and Taxonomy Terms Order
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.5.2.2 to 1.5.3

include/interface.php CHANGED
@@ -166,7 +166,6 @@
166
  <script type="text/javascript">
167
  jQuery(document).ready(function() {
168
 
169
- var NestedSortableSerializedData;
170
  jQuery("ul.sortable").sortable({
171
  'tolerance':'intersect',
172
  'cursor':'pointer',
@@ -175,11 +174,8 @@
175
  'placeholder':'placeholder',
176
  'nested': 'ul'
177
  });
178
- });
179
-
180
-
181
- jQuery(".save-order").bind( "click", function() {
182
-
183
  var mySortable = new Array();
184
  jQuery(".sortable").each( function(){
185
 
@@ -201,13 +197,17 @@
201
  });
202
 
203
  //serialize the array
204
- var serialize_data = serialize(mySortable);
205
 
206
- jQuery.post( ajaxurl, { action:'update-taxonomy-order', order: serialize_data, taxonomy : '<?php echo $taxonomy ?>' }, function() {
207
  jQuery("#ajax-response").html('<div class="message updated fade"><p><?php _e( "Items Order Updated", 'taxonomy-terms-order' ) ?></p></div>');
208
  jQuery("#ajax-response div").delay(3000).hide("slow");
209
  });
210
  });
 
 
 
 
211
  </script>
212
 
213
  </div>
166
  <script type="text/javascript">
167
  jQuery(document).ready(function() {
168
 
 
169
  jQuery("ul.sortable").sortable({
170
  'tolerance':'intersect',
171
  'cursor':'pointer',
174
  'placeholder':'placeholder',
175
  'nested': 'ul'
176
  });
177
+
178
+ jQuery(".save-order").bind( "click", function() {
 
 
 
179
  var mySortable = new Array();
180
  jQuery(".sortable").each( function(){
181
 
197
  });
198
 
199
  //serialize the array
200
+ var serialize_data = JSON.stringify( convArrToObj(mySortable));
201
 
202
+ jQuery.post( ajaxurl, { action:'update-taxonomy-order', order: serialize_data }, function() {
203
  jQuery("#ajax-response").html('<div class="message updated fade"><p><?php _e( "Items Order Updated", 'taxonomy-terms-order' ) ?></p></div>');
204
  jQuery("#ajax-response div").delay(3000).hide("slow");
205
  });
206
  });
207
+
208
+
209
+ });
210
+
211
  </script>
212
 
213
  </div>
include/terms_walker.php CHANGED
@@ -1,48 +1,48 @@
1
- <?php
2
-
3
-
4
- class TO_Terms_Walker extends Walker
5
- {
6
-
7
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
8
-
9
-
10
- function start_lvl(&$output, $depth = 0, $args = array() )
11
- {
12
- extract($args, EXTR_SKIP);
13
-
14
- $indent = str_repeat("\t", $depth);
15
- $output .= "\n$indent<ul class='children sortable'>\n";
16
- }
17
-
18
-
19
- function end_lvl(&$output, $depth = 0, $args = array())
20
- {
21
- extract($args, EXTR_SKIP);
22
-
23
- $indent = str_repeat("\t", $depth);
24
- $output .= "$indent</ul>\n";
25
- }
26
-
27
-
28
- function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0)
29
- {
30
- if ( $depth )
31
- $indent = str_repeat("\t", $depth);
32
- else
33
- $indent = '';
34
-
35
- //extract($args, EXTR_SKIP);
36
- $taxonomy = get_taxonomy($term->term_taxonomy_id);
37
- $output .= $indent . '<li class="term_type_li" id="item_'.$term->term_id.'"><div class="item"><span>'.apply_filters( 'to/term_title', $term->name, $term ).' </span></div>';
38
- }
39
-
40
-
41
- function end_el(&$output, $object, $depth = 0, $args = array())
42
- {
43
- $output .= "</li>\n";
44
- }
45
-
46
- }
47
-
48
  ?>
1
+ <?php
2
+
3
+
4
+ class TO_Terms_Walker extends Walker
5
+ {
6
+
7
+ var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
8
+
9
+
10
+ function start_lvl(&$output, $depth = 0, $args = array() )
11
+ {
12
+ extract($args, EXTR_SKIP);
13
+
14
+ $indent = str_repeat("\t", $depth);
15
+ $output .= "\n$indent<ul class='children sortable'>\n";
16
+ }
17
+
18
+
19
+ function end_lvl(&$output, $depth = 0, $args = array())
20
+ {
21
+ extract($args, EXTR_SKIP);
22
+
23
+ $indent = str_repeat("\t", $depth);
24
+ $output .= "$indent</ul>\n";
25
+ }
26
+
27
+
28
+ function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0)
29
+ {
30
+ if ( $depth )
31
+ $indent = str_repeat("\t", $depth);
32
+ else
33
+ $indent = '';
34
+
35
+ //extract($args, EXTR_SKIP);
36
+ $taxonomy = get_taxonomy($term->term_taxonomy_id);
37
+ $output .= $indent . '<li class="term_type_li" id="item_'.$term->term_id.'"><div class="item"><span>'.apply_filters( 'to/term_title', $term->name, $term ).' </span></div>';
38
+ }
39
+
40
+
41
+ function end_el(&$output, $object, $depth = 0, $args = array())
42
+ {
43
+ $output .= "</li>\n";
44
+ }
45
+
46
+ }
47
+
48
  ?>
js/to-javascript.js CHANGED
@@ -1,135 +1,20 @@
1
-
2
- function to_change_taxonomy(element)
3
- {
4
- //select the default category (0)
5
- jQuery('#to_form #cat').val(jQuery("#to_form #cat option:first").val());
6
- jQuery('#to_form').submit();
7
- }
8
-
9
-
10
-
11
- function serialize(mixed_value)
12
- {
13
- // http://kevin.vanzonneveld.net
14
- // + original by: Arpad Ray (mailto:arpad@php.net)
15
- // + improved by: Dino
16
- // + bugfixed by: Andrej Pavlovic
17
- // + bugfixed by: Garagoth
18
- // + input by: DtTvB (http://dt.in.th/2008-09-16.string-length-in-bytes.html)
19
- // + bugfixed by: Russell Walker (http://www.nbill.co.uk/)
20
- // + bugfixed by: Jamie Beck (http://www.terabit.ca/)
21
- // + input by: Martin (http://www.erlenwiese.de/)
22
- // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net/)
23
- // + improved by: Le Torbi (http://www.letorbi.de/)
24
- // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net/)
25
- // + bugfixed by: Ben (http://benblume.co.uk/)
26
- // - depends on: utf8_encode
27
- // % note: We feel the main purpose of this function should be to ease the transport of data between php & js
28
- // % note: Aiming for PHP-compatibility, we have to translate objects to arrays
29
- // * example 1: serialize(['Kevin', 'van', 'Zonneveld']);
30
- // * returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'
31
- // * example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'});
32
- // * returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'
33
- var _utf8Size = function (str) {
34
- var size = 0,
35
- i = 0,
36
- l = str.length,
37
- code = '';
38
- for (i = 0; i < l; i++) {
39
- code = str.charCodeAt(i);
40
- if (code < 0x0080) {
41
- size += 1;
42
- } else if (code < 0x0800) {
43
- size += 2;
44
- } else {
45
- size += 3;
46
- }
47
- }
48
- return size;
49
- };
50
- var _getType = function (inp) {
51
- var type = typeof inp,
52
- match;
53
- var key;
54
-
55
- if (type === 'object' && !inp) {
56
- return 'null';
57
- }
58
- if (type === "object") {
59
- if (!inp.constructor) {
60
- return 'object';
61
- }
62
- var cons = inp.constructor.toString();
63
- match = cons.match(/(\w+)\(/);
64
- if (match) {
65
- cons = match[1].toLowerCase();
66
- }
67
- var types = ["boolean", "number", "string", "array"];
68
- for (key in types) {
69
- if (cons == types[key]) {
70
- type = types[key];
71
- break;
72
- }
73
- }
74
- }
75
- return type;
76
- };
77
- var type = _getType(mixed_value);
78
- var val, ktype = '';
79
-
80
- switch (type) {
81
- case "function":
82
- val = "";
83
- break;
84
- case "boolean":
85
- val = "b:" + (mixed_value ? "1" : "0");
86
- break;
87
- case "number":
88
- val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value;
89
- break;
90
- case "string":
91
- val = "s:" + _utf8Size(mixed_value) + ":\"" + mixed_value + "\"";
92
- break;
93
- case "array":
94
- case "object":
95
- val = "a";
96
- /*
97
- if (type == "object") {
98
- var objname = mixed_value.constructor.toString().match(/(\w+)\(\)/);
99
- if (objname == undefined) {
100
- return;
101
- }
102
- objname[1] = this.serialize(objname[1]);
103
- val = "O" + objname[1].substring(1, objname[1].length - 1);
104
- }
105
- */
106
- var count = 0;
107
- var vals = "";
108
- var okey;
109
- var key;
110
- for (key in mixed_value) {
111
- if (mixed_value.hasOwnProperty(key)) {
112
- ktype = _getType(mixed_value[key]);
113
- if (ktype === "function") {
114
- continue;
115
- }
116
-
117
- okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key);
118
- vals += this.serialize(okey) + this.serialize(mixed_value[key]);
119
- count++;
120
- }
121
- }
122
- val += ":" + count + ":{" + vals + "}";
123
- break;
124
- case "undefined":
125
- // Fall-through
126
- default:
127
- // if the JS object has a property which contains a null value, the string cannot be unserialized by PHP
128
- val = "N";
129
- break;
130
- }
131
- if (type !== "object" && type !== "array") {
132
- val += ";";
133
- }
134
- return val;
135
- }
1
+
2
+ function to_change_taxonomy(element)
3
+ {
4
+ //select the default category (0)
5
+ jQuery('#to_form #cat').val(jQuery("#to_form #cat option:first").val());
6
+ jQuery('#to_form').submit();
7
+ }
8
+
9
+ var convArrToObj = function(array){
10
+ var thisEleObj = new Object();
11
+ if(typeof array == "object"){
12
+ for(var i in array){
13
+ var thisEle = convArrToObj(array[i]);
14
+ thisEleObj[i] = thisEle;
15
+ }
16
+ }else {
17
+ thisEleObj = array;
18
+ }
19
+ return thisEleObj;
20
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/taxonomy-terms-order.mo CHANGED
Binary file
languages/taxonomy-terms-order.po CHANGED
@@ -2,54 +2,53 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Category Order and Taxonomy Terms Order\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2015-07-21 21:29+0200\n"
6
- "PO-Revision-Date: 2015-07-21 21:29+0200\n"
7
- "Last-Translator: NspCode <electronice_delphi@yahoo.com>\n"
8
  "Language-Team: nsp-code <electronice_delphi@yahoo.com>\n"
9
  "Language: en\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "X-Poedit-KeywordsList: _;gettext;__;_e\n"
14
- "X-Poedit-Basepath: D:\\htdocs\\develop\\advanced_post_types_order\\wp-content"
15
- "\\plugins\\taxonomy-terms-order\\\n"
16
  "X-Generator: Poedit 1.5.5\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- #: taxonomy-terms-order.php:90
20
  msgid "Taxonomy Terms Order"
21
  msgstr ""
22
 
23
- #: taxonomy-terms-order.php:125 taxonomy-terms-order.php:127
24
- #: taxonomy-terms-order.php:129 include/interface.php:38
25
  msgid "Taxonomy Order"
26
  msgstr ""
27
 
28
- #: include/functions.php:62
29
  msgid ""
30
  "Did you find this plugin useful? Please support our work with a donation or "
31
  "write an article about this plugin in your blog with a link to our site"
32
  msgstr ""
33
 
34
- #: include/functions.php:63
35
  msgid "Did you know there is available an advanced version of this plug-in?"
36
  msgstr ""
37
 
38
- #: include/functions.php:63
39
  msgid "Read more"
40
  msgstr ""
41
 
42
- #: include/functions.php:64 include/functions.php:65
43
  msgid "Check our"
44
  msgstr ""
45
 
46
- #: include/functions.php:64
47
  msgid ""
48
  "plugin which allow to custom sort categories and custom taxonomies terms per "
49
  "post basis"
50
  msgstr ""
51
 
52
- #: include/functions.php:65
53
  msgid "plugin which allow to custom sort all posts, pages, custom post types"
54
  msgstr ""
55
 
@@ -68,10 +67,10 @@ msgid "Taxonomy Title"
68
  msgstr ""
69
 
70
  #: include/interface.php:104
71
- msgid "Total Posts"
72
  msgstr ""
73
 
74
- #: include/interface.php:154
75
  msgid "Update"
76
  msgstr ""
77
 
@@ -119,34 +118,34 @@ msgstr ""
119
  msgid "Auto Sort"
120
  msgstr ""
121
 
122
- #: include/options.php:52
123
  msgid "OFF"
124
  msgstr ""
125
 
126
- #: include/options.php:53
127
  msgid "ON"
128
  msgstr ""
129
 
130
- #: include/options.php:54
131
  msgid "global setting"
132
  msgstr ""
133
 
134
- #: include/options.php:54 include/options.php:62
135
  msgid "Additional description and details at "
136
  msgstr ""
137
 
138
- #: include/options.php:54 include/options.php:62
139
  msgid "Auto Sort Description"
140
  msgstr ""
141
 
142
- #: include/options.php:59
143
  msgid "Admin Sort"
144
  msgstr ""
145
 
146
- #: include/options.php:62
147
  msgid "This will change the order of terms within the admin interface"
148
  msgstr ""
149
 
150
- #: include/options.php:73
151
  msgid "Save Settings"
152
  msgstr ""
2
  msgstr ""
3
  "Project-Id-Version: Category Order and Taxonomy Terms Order\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2018-02-22 19:40+0200\n"
6
+ "PO-Revision-Date: 2018-02-22 19:40+0200\n"
7
+ "Last-Translator: NspCode <contact@nsp-code.com>\n"
8
  "Language-Team: nsp-code <electronice_delphi@yahoo.com>\n"
9
  "Language: en\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
  "X-Poedit-KeywordsList: _;gettext;__;_e\n"
14
+ "X-Poedit-Basepath: ../\n"
 
15
  "X-Generator: Poedit 1.5.5\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
+ #: taxonomy-terms-order.php:80
19
  msgid "Taxonomy Terms Order"
20
  msgstr ""
21
 
22
+ #: taxonomy-terms-order.php:115 taxonomy-terms-order.php:117
23
+ #: taxonomy-terms-order.php:119 include/interface.php:38
24
  msgid "Taxonomy Order"
25
  msgstr ""
26
 
27
+ #: include/functions.php:88
28
  msgid ""
29
  "Did you find this plugin useful? Please support our work with a donation or "
30
  "write an article about this plugin in your blog with a link to our site"
31
  msgstr ""
32
 
33
+ #: include/functions.php:89
34
  msgid "Did you know there is available an advanced version of this plug-in?"
35
  msgstr ""
36
 
37
+ #: include/functions.php:89
38
  msgid "Read more"
39
  msgstr ""
40
 
41
+ #: include/functions.php:90 include/functions.php:91
42
  msgid "Check our"
43
  msgstr ""
44
 
45
+ #: include/functions.php:90
46
  msgid ""
47
  "plugin which allow to custom sort categories and custom taxonomies terms per "
48
  "post basis"
49
  msgstr ""
50
 
51
+ #: include/functions.php:91
52
  msgid "plugin which allow to custom sort all posts, pages, custom post types"
53
  msgstr ""
54
 
67
  msgstr ""
68
 
69
  #: include/interface.php:104
70
+ msgid "Total Posts"
71
  msgstr ""
72
 
73
+ #: include/interface.php:158
74
  msgid "Update"
75
  msgstr ""
76
 
118
  msgid "Auto Sort"
119
  msgstr ""
120
 
121
+ #: include/options.php:52 include/options.php:63
122
  msgid "OFF"
123
  msgstr ""
124
 
125
+ #: include/options.php:53 include/options.php:64
126
  msgid "ON"
127
  msgstr ""
128
 
129
+ #: include/options.php:55
130
  msgid "global setting"
131
  msgstr ""
132
 
133
+ #: include/options.php:55 include/options.php:66
134
  msgid "Additional description and details at "
135
  msgstr ""
136
 
137
+ #: include/options.php:55 include/options.php:66
138
  msgid "Auto Sort Description"
139
  msgstr ""
140
 
141
+ #: include/options.php:60
142
  msgid "Admin Sort"
143
  msgstr ""
144
 
145
+ #: include/options.php:66
146
  msgid "This will change the order of terms within the admin interface"
147
  msgstr ""
148
 
149
+ #: include/options.php:77
150
  msgid "Save Settings"
151
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: nsp-code
3
  Donate link: http://www.nsp-code.com/donate.php
4
  Tags: category order,terms order, taxonomy order, admin order, categories sort, order category
5
  Requires at least: 2.8
6
- Tested up to: 4.8.1
7
- Stable tag: 1.5.2.2
8
 
9
  Order Categories and all custom taxonomies terms (hierarchically) and child terms using a Drag and Drop Sortable javascript capability.
10
 
@@ -57,6 +57,10 @@ Consider upgrading to our advanced version of this plugin at a very resonable pr
57
 
58
  == Change Log ==
59
 
 
 
 
 
60
  = 1.5.2.2 =
61
  - Default admin capability changed from install_plugins to manage_options to prevent DISALLOW_FILE_MODS issue. https://wordpress.org/support/topic/plugin-breaks-when-disallow_file_mods-is-set-to-true/
62
  - Prepare plugin for Composer package
3
  Donate link: http://www.nsp-code.com/donate.php
4
  Tags: category order,terms order, taxonomy order, admin order, categories sort, order category
5
  Requires at least: 2.8
6
+ Tested up to: 4.9.4
7
+ Stable tag: 1.5.3
8
 
9
  Order Categories and all custom taxonomies terms (hierarchically) and child terms using a Drag and Drop Sortable javascript capability.
10
 
57
 
58
  == Change Log ==
59
 
60
+ = 1.5.3 =
61
+ - Use JSON instead serialize method when sending order through AJAX
62
+ - Updated PO language file
63
+
64
  = 1.5.2.2 =
65
  - Default admin capability changed from install_plugins to manage_options to prevent DISALLOW_FILE_MODS issue. https://wordpress.org/support/topic/plugin-breaks-when-disallow_file_mods-is-set-to-true/
66
  - Prepare plugin for Composer package
taxonomy-terms-order.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Category Order and Taxonomy Terms Order
4
  Plugin URI: http://www.nsp-code.com
5
  Description: Order Categories and all custom taxonomies terms (hierarchically) and child terms using a Drag and Drop Sortable javascript capability.
6
- Version: 1.5.2.2
7
  Author: Nsp-Code
8
  Author URI: http://www.nsp-code.com
9
  Author Email: electronice_delphi@yahoo.com
@@ -56,9 +56,9 @@ Domain Path: /languages/
56
  wp_enqueue_script('jquery-ui-sortable');
57
 
58
  $myJsFile = TOURL . '/js/to-javascript.js';
59
- wp_register_script('to-javascript.js', $myJsFile);
60
- wp_enqueue_script( 'to-javascript.js');
61
-
62
  }
63
 
64
  add_action('admin_print_styles', 'TO_admin_styles');
@@ -157,9 +157,8 @@ Domain Path: /languages/
157
  function TOsaveAjaxOrder()
158
  {
159
  global $wpdb;
160
- $taxonomy = stripslashes($_POST['taxonomy']);
161
- $data = stripslashes($_POST['order']);
162
- $unserialised_data = unserialize($data);
163
 
164
  if (is_array($unserialised_data))
165
  foreach($unserialised_data as $key => $values )
3
  Plugin Name: Category Order and Taxonomy Terms Order
4
  Plugin URI: http://www.nsp-code.com
5
  Description: Order Categories and all custom taxonomies terms (hierarchically) and child terms using a Drag and Drop Sortable javascript capability.
6
+ Version: 1.5.3
7
  Author: Nsp-Code
8
  Author URI: http://www.nsp-code.com
9
  Author Email: electronice_delphi@yahoo.com
56
  wp_enqueue_script('jquery-ui-sortable');
57
 
58
  $myJsFile = TOURL . '/js/to-javascript.js';
59
+ wp_register_script('to-javascript', $myJsFile);
60
+ wp_enqueue_script( 'to-javascript');
61
+
62
  }
63
 
64
  add_action('admin_print_styles', 'TO_admin_styles');
157
  function TOsaveAjaxOrder()
158
  {
159
  global $wpdb;
160
+ $data = stripslashes($_POST['order']);
161
+ $unserialised_data = json_decode($data, TRUE);
 
162
 
163
  if (is_array($unserialised_data))
164
  foreach($unserialised_data as $key => $values )