Version Description
Make sure you get the latest version
Download this release
Release Info
Developer | nsp-code |
Plugin | Category Order and Taxonomy Terms Order |
Version | 1.2.4 |
Comparing to | |
See all releases |
Version 1.2.4
- css/to.css +37 -0
- images/Thumbs.db +0 -0
- images/admin-icon-settings.gif +0 -0
- images/menu-icon.gif +0 -0
- images/wpspin_light.gif +0 -0
- include/interface.php +241 -0
- include/options.php +141 -0
- include/terms_walker.php +48 -0
- js/to-javascript.js +135 -0
- readme.txt +59 -0
- screenshot-1.gif +0 -0
- screenshot-2.gif +0 -0
- taxonomy-terms-order.php +162 -0
css/to.css
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold}
|
3 |
+
|
4 |
+
#order-terms img {vertical-align: middle}
|
5 |
+
#order-terms #sortable { list-style-type: none; margin: 10px 0 0; padding: 0; width: 100%; }
|
6 |
+
#order-terms ul {list-style: none;}
|
7 |
+
#order-terms ul.children {margin-left: 25px}
|
8 |
+
.term_type_li .item {border: 1px solid #DDDDDD; border-radius: 6px 6px 6px 6px; cursor: move; margin: 4px 0; padding: 2px 0;line-height: 140%;margin-bottom: 6px;}
|
9 |
+
.term_type_li .item span { background: none repeat scroll 0 0 #F7F7F7; color: #808080; display: block; font-weight: bold; padding: 5px;}
|
10 |
+
.term_type_li .item span.edit {position: absolute; right: 10px; top: 6px; padding: 0px; margin: 0px}
|
11 |
+
#order-terms .placeholder{border-color:#bbb;background-color:#f5f5f5; height:30px; background-image: none; -moz-border-radius: 6px 6px 6px 6px; border: 1px solid #E6E6E6;}
|
12 |
+
.term_type_li ul {margin-top: 6px}
|
13 |
+
#dragHelper li, #dragHelper ul {background: transparent !important;}
|
14 |
+
#dragHelper ul {list-style: none;}
|
15 |
+
|
16 |
+
.wp-list-taxonomy {width: 100%}
|
17 |
+
.wp-list-taxonomy thead tr th{padding-bottom: 7px}
|
18 |
+
.wp-list-taxonomy tr {background-color: #FCFCFC;}
|
19 |
+
.wp-list-taxonomy tbody th.check-column { padding: 9px 0 22px;}
|
20 |
+
.wp-list-taxonomy td { color: #555555;}
|
21 |
+
.wp-list-taxonomy td, .wp-list-taxonomy th { border-bottom-color: #DFDFDF; border-top-color: #FFFFFF;}
|
22 |
+
.wp-list-taxonomy th, .wp-list-taxonomy td { overflow: hidden;}
|
23 |
+
.wp-list-taxonomy td { font-size: 12px; padding: 9px 7px 4px 7px; vertical-align: top;}
|
24 |
+
.wp-list-taxonomy td, .wp-list-taxonomy th { border-style: solid; border-width: 1px 0;}
|
25 |
+
.wp-list-taxonomy * { word-wrap: break-word;}
|
26 |
+
|
27 |
+
#cpt_info_box {padding: 0 10px; border: 1px dashed #21759B; background-color: #F1F1F1}
|
28 |
+
#cpt_info_box p {font-size: 12px}
|
29 |
+
#cpt_info_box #donate_form {float: right; padding: 10px 0 10px 10px}
|
30 |
+
|
31 |
+
#p_right {float: right; width: 170px; }
|
32 |
+
.p_s_item {float: left; padding: 0px 5px; margin-top: 15px; margin-bottom: 5px}
|
33 |
+
.p_s_item.s_gp {padding-top: 2px; margin-left: 10px}
|
34 |
+
|
35 |
+
.clear {clear: both}
|
36 |
+
|
37 |
+
|
images/Thumbs.db
ADDED
Binary file
|
images/admin-icon-settings.gif
ADDED
Binary file
|
images/menu-icon.gif
ADDED
Binary file
|
images/wpspin_light.gif
ADDED
Binary file
|
include/interface.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
function TOPluginInterface()
|
5 |
+
{
|
6 |
+
global $wpdb, $wp_locale;
|
7 |
+
|
8 |
+
$taxonomy = isset($_GET['taxonomy']) ? $_GET['taxonomy'] : '';
|
9 |
+
$post_type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
|
10 |
+
|
11 |
+
$post_type_data = get_post_type_object($post_type);
|
12 |
+
|
13 |
+
if (!taxonomy_exists($taxonomy))
|
14 |
+
$taxonomy = '';
|
15 |
+
|
16 |
+
?>
|
17 |
+
<div class="wrap">
|
18 |
+
<div class="icon32" id="icon-edit"><br></div>
|
19 |
+
<h2>Taxonomy Order</h2>
|
20 |
+
|
21 |
+
<div id="cpt_info_box">
|
22 |
+
<div id="p_right">
|
23 |
+
|
24 |
+
<div id="p_socialize">
|
25 |
+
<div class="p_s_item s_gp">
|
26 |
+
<!-- Place this tag in your head or just before your close body tag -->
|
27 |
+
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
|
28 |
+
|
29 |
+
<!-- Place this tag where you want the +1 button to render -->
|
30 |
+
<div class="g-plusone" data-size="small" data-annotation="none" data-href="http://nsp-code.com/"></div>
|
31 |
+
</div>
|
32 |
+
<div class="p_s_item s_t">
|
33 |
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.nsp-code.com" data-text="Define custom order for your taxonomies terms through an easy to use javascript AJAX drag and drop interface. No theme code updates are necessarily, this plugin will take care of query update." data-count="none">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<div class="p_s_item s_f">
|
37 |
+
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.nsp-code.com%2F&send=false&layout=button_count&width=50&show_faces=false&action=like&colorscheme=light&font=arial&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe>
|
38 |
+
</div>
|
39 |
+
|
40 |
+
<div class="clear"></div>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<div id="donate_form">
|
44 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
45 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
46 |
+
<input type="hidden" name="hosted_button_id" value="CU22TFDKJMLAE">
|
47 |
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
48 |
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
49 |
+
</form>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
<p>Did you found useful this plug-in? Please support our work with a donation or write an article about this plugin in your blog with a link to our site <br /><strong>http://www.nsp-code.com/</strong>.</p>
|
53 |
+
<h4>Did you know there is available a more advanced version of this plug-in? <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-taxonomy-terms-order/">Read more</a></h4>
|
54 |
+
<p>Check our <a target="_blank" href="http://wordpress.org/extend/plugins/post-types-order/">Post Types Order</a> plugin which allow to custom sort all posts, pages, custom post types </p>
|
55 |
+
</div>
|
56 |
+
<div id="ajax-response"></div>
|
57 |
+
|
58 |
+
<noscript>
|
59 |
+
<div class="error message">
|
60 |
+
<p>This plugin can't work without javascript, because it's use drag and drop and AJAX.</p>
|
61 |
+
</div>
|
62 |
+
</noscript>
|
63 |
+
|
64 |
+
<div class="clear"></div>
|
65 |
+
|
66 |
+
<form action="edit.php" method="get" id="to_form">
|
67 |
+
<input type="hidden" name="page" value="to-interface-<?php echo $post_type ?>" />
|
68 |
+
<?php
|
69 |
+
|
70 |
+
if ($post_type != 'post')
|
71 |
+
echo '<input type="hidden" name="post_type" value="'. $post_type .'" />';
|
72 |
+
|
73 |
+
//output all available taxonomies for this post type
|
74 |
+
|
75 |
+
$post_type_taxonomies = get_object_taxonomies($post_type);
|
76 |
+
|
77 |
+
foreach ($post_type_taxonomies as $key => $taxonomy_name)
|
78 |
+
{
|
79 |
+
$taxonomy_info = get_taxonomy($taxonomy_name);
|
80 |
+
if ($taxonomy_info->hierarchical !== TRUE)
|
81 |
+
unset($post_type_taxonomies[$key]);
|
82 |
+
}
|
83 |
+
|
84 |
+
//use the first taxonomy if emtpy taxonomy
|
85 |
+
if ($taxonomy == '' || !taxonomy_exists($taxonomy))
|
86 |
+
{
|
87 |
+
reset($post_type_taxonomies);
|
88 |
+
$taxonomy = current($post_type_taxonomies);
|
89 |
+
}
|
90 |
+
|
91 |
+
if (count($post_type_taxonomies) > 1)
|
92 |
+
{
|
93 |
+
|
94 |
+
?>
|
95 |
+
|
96 |
+
<h2 class="subtitle"><?php echo ucfirst($post_type_data->labels->name) ?> Taxonomies</h2>
|
97 |
+
<table cellspacing="0" class="wp-list-taxonomy">
|
98 |
+
<thead>
|
99 |
+
<tr>
|
100 |
+
<th style="" class="column-cb check-column" id="cb" scope="col"> </th><th style="" class="" id="author" scope="col">Taxonomy Title</th><th style="" class="manage-column" id="categories" scope="col">Total Posts</th> </tr>
|
101 |
+
</thead>
|
102 |
+
|
103 |
+
|
104 |
+
<tbody id="the-list">
|
105 |
+
<?php
|
106 |
+
|
107 |
+
$alternate = FALSE;
|
108 |
+
foreach ($post_type_taxonomies as $post_type_taxonomy)
|
109 |
+
{
|
110 |
+
$taxonomy_info = get_taxonomy($post_type_taxonomy);
|
111 |
+
|
112 |
+
$alternate = $alternate === TRUE ? FALSE :TRUE;
|
113 |
+
|
114 |
+
$taxonomy_terms = get_terms($key);
|
115 |
+
|
116 |
+
?>
|
117 |
+
<tr valign="top" class="<?php if ($alternate === TRUE) {echo 'alternate ';} ?>" id="taxonomy-<?php echo $taxonomy ?>">
|
118 |
+
<th class="check-column" scope="row"><input type="radio" onclick="to_change_taxonomy(this)" value="<?php echo $post_type_taxonomy ?>" <?php if ($post_type_taxonomy == $taxonomy) {echo 'checked="checked"';} ?> name="taxonomy"> </th>
|
119 |
+
<td class="categories column-categories"><b><?php echo $taxonomy_info->label ?></b> (<?php echo $taxonomy_info->labels->singular_name; ?>)</td>
|
120 |
+
<td class="categories column-categories"><?php echo count($taxonomy_terms) ?></td>
|
121 |
+
</tr>
|
122 |
+
|
123 |
+
<?php
|
124 |
+
}
|
125 |
+
?>
|
126 |
+
</tbody>
|
127 |
+
</table>
|
128 |
+
<br /><br />
|
129 |
+
<?php
|
130 |
+
}
|
131 |
+
?>
|
132 |
+
|
133 |
+
<div id="order-terms">
|
134 |
+
|
135 |
+
|
136 |
+
|
137 |
+
<div id="post-body">
|
138 |
+
|
139 |
+
<ul class="sortable" id="sortable">
|
140 |
+
<?php
|
141 |
+
listTerms($taxonomy);
|
142 |
+
?>
|
143 |
+
</ul>
|
144 |
+
|
145 |
+
<div class="clear"></div>
|
146 |
+
</div>
|
147 |
+
|
148 |
+
<div class="alignleft actions">
|
149 |
+
<p class="submit">
|
150 |
+
<a href="javascript:;" class="save-order button-primary">Update</a>
|
151 |
+
</p>
|
152 |
+
</div>
|
153 |
+
|
154 |
+
</div>
|
155 |
+
|
156 |
+
</form>
|
157 |
+
|
158 |
+
<script type="text/javascript">
|
159 |
+
jQuery(document).ready(function() {
|
160 |
+
|
161 |
+
var NestedSortableSerializedData;
|
162 |
+
jQuery("ul.sortable").sortable({
|
163 |
+
'tolerance':'intersect',
|
164 |
+
'cursor':'pointer',
|
165 |
+
'items':'> li',
|
166 |
+
'axi': 'y',
|
167 |
+
'placeholder':'placeholder',
|
168 |
+
'nested': 'ul'
|
169 |
+
});
|
170 |
+
});
|
171 |
+
|
172 |
+
|
173 |
+
jQuery(".save-order").bind( "click", function() {
|
174 |
+
|
175 |
+
var mySortable = new Array();
|
176 |
+
jQuery(".sortable").each( function(){
|
177 |
+
|
178 |
+
var serialized = jQuery(this).sortable("serialize");
|
179 |
+
|
180 |
+
var parent_tag = jQuery(this).parent().get(0).tagName;
|
181 |
+
parent_tag = parent_tag.toLowerCase()
|
182 |
+
if (parent_tag == 'li')
|
183 |
+
{
|
184 |
+
//
|
185 |
+
var tag_id = jQuery(this).parent().attr('id');
|
186 |
+
mySortable[tag_id] = serialized;
|
187 |
+
}
|
188 |
+
else
|
189 |
+
{
|
190 |
+
//
|
191 |
+
mySortable[0] = serialized;
|
192 |
+
}
|
193 |
+
});
|
194 |
+
|
195 |
+
//serialize the array
|
196 |
+
var serialize_data = serialize(mySortable);
|
197 |
+
|
198 |
+
jQuery.post( ajaxurl, { action:'update-taxonomy-order', order: serialize_data, taxonomy : '<?php echo $taxonomy ?>' }, function() {
|
199 |
+
jQuery("#ajax-response").html('<div class="message updated fade"><p>Items Order Updates</p></div>');
|
200 |
+
jQuery("#ajax-response div").delay(3000).hide("slow");
|
201 |
+
});
|
202 |
+
});
|
203 |
+
</script>
|
204 |
+
|
205 |
+
</div>
|
206 |
+
<?php
|
207 |
+
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
|
212 |
+
function listTerms($taxonomy)
|
213 |
+
{
|
214 |
+
|
215 |
+
// Query pages.
|
216 |
+
$args = array(
|
217 |
+
'orderby' => 'menu_order',
|
218 |
+
'depth' => 0,
|
219 |
+
'child_of' => 0,
|
220 |
+
'hide_empty' => 0
|
221 |
+
);
|
222 |
+
$taxonomy_terms = get_terms($taxonomy, $args);
|
223 |
+
|
224 |
+
$output = '';
|
225 |
+
if (count($taxonomy_terms) > 0)
|
226 |
+
{
|
227 |
+
$output = TOwalkTree($taxonomy_terms, $args['depth'], $args);
|
228 |
+
}
|
229 |
+
|
230 |
+
echo $output;
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
function TOwalkTree($taxonomy_terms, $depth, $r)
|
235 |
+
{
|
236 |
+
$walker = new TO_Terms_Walker;
|
237 |
+
$args = array($taxonomy_terms, $depth, $r);
|
238 |
+
return call_user_func_array(array(&$walker, 'walk'), $args);
|
239 |
+
}
|
240 |
+
|
241 |
+
?>
|
include/options.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
function to_plugin_options()
|
5 |
+
{
|
6 |
+
$options = get_option('tto_options');
|
7 |
+
|
8 |
+
if (isset($_POST['form_submit']))
|
9 |
+
{
|
10 |
+
|
11 |
+
$options['level'] = $_POST['level'];
|
12 |
+
|
13 |
+
$options['autosort'] = isset($_POST['autosort']) ? $_POST['autosort'] : '';
|
14 |
+
$options['adminsort'] = isset($_POST['adminsort']) ? $_POST['adminsort'] : '';
|
15 |
+
|
16 |
+
echo '<div class="updated fade"><p>' . __('Settings Saved', 'tto') . '</p></div>';
|
17 |
+
|
18 |
+
update_option('tto_options', $options);
|
19 |
+
}
|
20 |
+
|
21 |
+
?>
|
22 |
+
<div class="wrap">
|
23 |
+
<div id="icon-settings" class="icon32"></div>
|
24 |
+
<h2>General Settings</h2>
|
25 |
+
|
26 |
+
<div id="cpt_info_box">
|
27 |
+
|
28 |
+
<div id="p_right">
|
29 |
+
|
30 |
+
<div id="p_socialize">
|
31 |
+
<div class="p_s_item s_gp">
|
32 |
+
<!-- Place this tag in your head or just before your close body tag -->
|
33 |
+
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
|
34 |
+
|
35 |
+
<!-- Place this tag where you want the +1 button to render -->
|
36 |
+
<div class="g-plusone" data-size="small" data-annotation="none" data-href="http://nsp-code.com/"></div>
|
37 |
+
</div>
|
38 |
+
<div class="p_s_item s_t">
|
39 |
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.nsp-code.com" data-text="Define custom order for your taxonomies terms through an easy to use javascript AJAX drag and drop interface. No theme code updates are necessarily, this plugin will take care of query update." data-count="none">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
<div class="p_s_item s_f">
|
43 |
+
<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.nsp-code.com%2F&send=false&layout=button_count&width=50&show_faces=false&action=like&colorscheme=light&font=arial&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe>
|
44 |
+
</div>
|
45 |
+
<div class="clear"></div>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div id="donate_form">
|
49 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
50 |
+
<input type="hidden" name="cmd" value="_s-xclick">
|
51 |
+
<input type="hidden" name="hosted_button_id" value="CU22TFDKJMLAE">
|
52 |
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
53 |
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
54 |
+
</form>
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
|
58 |
+
<p>Did you found useful this plug-in? Please support our work with a donation or write an article about this plugin in your blog with a link to our site <br /><strong>http://www.nsp-code.com/</strong>.</p>
|
59 |
+
<h4>Did you know there is available a more advanced version of this plug-in? <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-taxonomy-terms-order/">Read more</a></h4>
|
60 |
+
<p>Check our Post Types Order plugin which allow to custom sort all posts, pages, custom post types </p>
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<form id="form_data" name="form" method="post">
|
64 |
+
<br />
|
65 |
+
<h2 class="subtitle">General</h2>
|
66 |
+
<table class="form-table">
|
67 |
+
<tbody>
|
68 |
+
|
69 |
+
<tr valign="top">
|
70 |
+
<th scope="row" style="text-align: right;"><label>Minimum Level to use this plugin</label></th>
|
71 |
+
<td>
|
72 |
+
<select id="role" name="level">
|
73 |
+
<option value="0" <?php if ($options['level'] == "0") echo 'selected="selected"'?>><?php _e('Subscriber', 'tto') ?></option>
|
74 |
+
<option value="1" <?php if ($options['level'] == "1") echo 'selected="selected"'?>><?php _e('Contributor', 'tto') ?></option>
|
75 |
+
<option value="2" <?php if ($options['level'] == "2") echo 'selected="selected"'?>><?php _e('Author', 'tto') ?></option>
|
76 |
+
<option value="5" <?php if ($options['level'] == "5") echo 'selected="selected"'?>><?php _e('Editor', 'tto') ?></option>
|
77 |
+
<option value="8" <?php if ($options['level'] == "8") echo 'selected="selected"'?>><?php _e('Administrator', 'tto') ?></option>
|
78 |
+
</select>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
|
82 |
+
|
83 |
+
<tr valign="top">
|
84 |
+
<th scope="row" style="text-align: right;"><label>Auto Sort</label></th>
|
85 |
+
<td>
|
86 |
+
<select id="role" name="autosort">
|
87 |
+
<option value="0" <?php if ($options['autosort'] == "0") echo 'selected="selected"'?>><?php _e('OFF', 'tto') ?></option>
|
88 |
+
<option value="1" <?php if ($options['autosort'] == "1") echo 'selected="selected"'?>><?php _e('ON', 'tto') ?></option>
|
89 |
+
</select> *(global setting)
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
|
93 |
+
<tr valign="top">
|
94 |
+
<th scope="row" style="text-align: right;"><label>Admin Sort</label></th>
|
95 |
+
<td>
|
96 |
+
<label for="users_can_register">
|
97 |
+
<input type="checkbox" <?php if ($options['adminsort'] == "1") {echo ' checked="checked"';} ?> value="1" name="adminsort">
|
98 |
+
<?php _e("This will change the order of terms within the admin interface", 'cpt') ?>.</label>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
|
102 |
+
<tr valign="top">
|
103 |
+
<th scope="row" style="text-align: right;"></th>
|
104 |
+
<td>
|
105 |
+
<br /><br /><br />
|
106 |
+
<p><b><u>Autosort OFF</u></b></p>
|
107 |
+
<p class="example"><?php _e('No query will be changed, the terms will appear in the original order. To retrieve the terms in the required order you must use the menu_order on the orderby parameter', 'tto') ?>:</p>
|
108 |
+
<pre class="example">
|
109 |
+
$argv = array(
|
110 |
+
'orderby' => 'menu_order',
|
111 |
+
'hide_empty' => false
|
112 |
+
);
|
113 |
+
get_terms('category', $argv);
|
114 |
+
</pre>
|
115 |
+
<p>See more info on the get_terms usage <a href="http://codex.wordpress.org/Function_Reference/get_terms" target="_blank">here</a></p>
|
116 |
+
|
117 |
+
<p><b><u>Autosort ON</u></b></p>
|
118 |
+
<p class="example"><?php _e('The query will be updated, all terms will appear in the order you manually defined. This is recommended if you don\'t want to change any theme code to apply the terms order') ?></p>
|
119 |
+
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
|
123 |
+
</tbody>
|
124 |
+
</table>
|
125 |
+
|
126 |
+
|
127 |
+
<p class="submit">
|
128 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings', 'tto') ?>">
|
129 |
+
</p>
|
130 |
+
|
131 |
+
<input type="hidden" name="form_submit" value="true" />
|
132 |
+
|
133 |
+
</form>
|
134 |
+
|
135 |
+
<?php
|
136 |
+
echo '</div>';
|
137 |
+
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
?>
|
include/terms_walker.php
ADDED
@@ -0,0 +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, $args)
|
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, $args)
|
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, $args)
|
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( 'the_title', $term->name, $term->term_id ).' </span></div>';
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
function end_el(&$output, $post_type, $depth)
|
42 |
+
{
|
43 |
+
$output .= "</li>\n";
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
js/to-javascript.js
ADDED
@@ -0,0 +1,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 |
+
|
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 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Category Order - Taxonomy Terms Order ===
|
2 |
+
Contributors: Nsp Code
|
3 |
+
Donate link: http://www.nsp-code.com/donate.php
|
4 |
+
Tags: category order,terms order, taxonomy order, admin order
|
5 |
+
Requires at least: 2.8
|
6 |
+
Tested up to: 3.2.1
|
7 |
+
Stable tag: 1.2.4
|
8 |
+
|
9 |
+
Order Categories and all custom taxonomies terms and child terms using a Drag and Drop Sortable javascript capability. <b>No Theme update is required<b/> the code will change the query on the fly.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Order Categories and all custom taxonomies terms using a Drag and Drop Sortable javascript capability. <b>No Theme update is required<b/> the code will change the query on the fly.
|
14 |
+
If multiple taxonomies are created for a custom post type, a menu will allow to chose the one you need sorted. If child categories (terms) are define, tose can be sorder too using the same interface
|
15 |
+
<br />Also you can have the admin terms interface sorted per your new sort.
|
16 |
+
<br />This plugin it's developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
1. Upload `taxonomy-terms-order` folder to your `/wp-content/plugins/` directory.
|
21 |
+
2. Activate the plugin from Admin > Plugins menu.
|
22 |
+
3. Once activated you should check with Settings > Taxonomy Terms Order
|
23 |
+
4. Use Taxonomy Order link which appear into each post type section to make your sort.
|
24 |
+
|
25 |
+
|
26 |
+
== Screenshots ==
|
27 |
+
|
28 |
+
1. Category Order Interface.
|
29 |
+
2. Multiple Taxonomies Interface.
|
30 |
+
|
31 |
+
== Frequently Asked Questions ==
|
32 |
+
|
33 |
+
Feel free to contact me at electronice_delphi@yahoo.com
|
34 |
+
|
35 |
+
= I have no PHP knowledge at all, i will still be able to use this plugin? =
|
36 |
+
|
37 |
+
Yes, this is the right tool for you. The plugin come with a unique feature to update the queries on the fly and return the terms in the required ored without changing any line of code. Or as alternative you can do that manually.
|
38 |
+
|
39 |
+
= What taxonomies will allow me to sort? =
|
40 |
+
|
41 |
+
You can sort ALL taxonomies, including the default Categories.
|
42 |
+
|
43 |
+
= Is there any way i can get my admin interface to use the custom terms order? =
|
44 |
+
|
45 |
+
Absolutelly, the plugin can do that. In fact you can configure so only the admin will update and the front side template will display the terms as before.
|
46 |
+
|
47 |
+
= There is a feature that i want it implemented, can you do something about it? =
|
48 |
+
|
49 |
+
All ideas are welcome and i put them on my list to be implemented into the new versions. Anyway this may take time, but if you are in a rush, please consider a small donation and we can arrange something.
|
50 |
+
|
51 |
+
|
52 |
+
== Upgrade Notice ==
|
53 |
+
|
54 |
+
Make sure you get the latest version
|
55 |
+
|
56 |
+
|
57 |
+
== Localization ==
|
58 |
+
|
59 |
+
Currently only available in English
|
screenshot-1.gif
ADDED
Binary file
|
screenshot-2.gif
ADDED
Binary file
|
taxonomy-terms-order.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Category Order - Taxonomy Terms Order
|
4 |
+
Plugin URI: http://www.nsp-code.com
|
5 |
+
Description: Category Order - Taxonomy Terms Order
|
6 |
+
Version: 1.2.4
|
7 |
+
Author: Nsp-Code
|
8 |
+
Author URI: http://www.nsp-code.com
|
9 |
+
Author Email: electronice_delphi@yahoo.com
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
define('TOPATH', WP_PLUGIN_DIR .'/taxonomy-terms-order');
|
14 |
+
define('TOURL', WP_PLUGIN_URL .'/taxonomy-terms-order');
|
15 |
+
|
16 |
+
|
17 |
+
register_deactivation_hook(__FILE__, 'TO_deactivated');
|
18 |
+
register_activation_hook(__FILE__, 'TO_activated');
|
19 |
+
|
20 |
+
function TO_activated()
|
21 |
+
{
|
22 |
+
global $wpdb;
|
23 |
+
|
24 |
+
//check if the menu_order column exists;
|
25 |
+
$query = "SHOW COLUMNS FROM $wpdb->terms
|
26 |
+
LIKE 'term_order'";
|
27 |
+
$result = $wpdb->query($query);
|
28 |
+
|
29 |
+
if ($result == 0)
|
30 |
+
{
|
31 |
+
$query = "ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'";
|
32 |
+
$result = $wpdb->query($query);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
function TO_deactivated()
|
37 |
+
{
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
add_action('admin_print_scripts', 'TO_admin_scripts');
|
42 |
+
function TO_admin_scripts()
|
43 |
+
{
|
44 |
+
wp_enqueue_script('jquery');
|
45 |
+
|
46 |
+
wp_enqueue_script('jquery-ui-sortable');
|
47 |
+
|
48 |
+
$myJsFile = TOURL . '/js/to-javascript.js';
|
49 |
+
wp_register_script('to-javascript.js', $myJsFile);
|
50 |
+
wp_enqueue_script( 'to-javascript.js');
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
add_action('admin_print_styles', 'TO_admin_styles');
|
55 |
+
function TO_admin_styles()
|
56 |
+
{
|
57 |
+
$myCssFile = TOURL . '/css/to.css';
|
58 |
+
wp_register_style('to.css', $myCssFile);
|
59 |
+
wp_enqueue_style( 'to.css');
|
60 |
+
}
|
61 |
+
|
62 |
+
add_action('admin_menu', 'TOPluginMenu', 99);
|
63 |
+
|
64 |
+
function TOPluginMenu()
|
65 |
+
{
|
66 |
+
include (TOPATH . '/include/interface.php');
|
67 |
+
include (TOPATH . '/include/terms_walker.php');
|
68 |
+
|
69 |
+
include (TOPATH . '/include/options.php');
|
70 |
+
add_options_page('Taxonomy Terms Order', '<img class="menu_pto" src="'. TOURL .'/images/menu-icon.gif" alt="" />Taxonomy Terms Order', 'manage_options', 'to-options', 'to_plugin_options');
|
71 |
+
|
72 |
+
$options = get_option('tto_options');
|
73 |
+
|
74 |
+
//put a menu within all custom types if apply
|
75 |
+
$post_types = get_post_types();
|
76 |
+
foreach( $post_types as $post_type)
|
77 |
+
{
|
78 |
+
|
79 |
+
//check if there are any taxonomy for this post type
|
80 |
+
$post_type_taxonomies = get_object_taxonomies($post_type);
|
81 |
+
|
82 |
+
foreach ($post_type_taxonomies as $key => $taxonomy_name)
|
83 |
+
{
|
84 |
+
$taxonomy_info = get_taxonomy($taxonomy_name);
|
85 |
+
if ($taxonomy_info->hierarchical !== TRUE)
|
86 |
+
unset($post_type_taxonomies[$key]);
|
87 |
+
}
|
88 |
+
|
89 |
+
if (count($post_type_taxonomies) == 0)
|
90 |
+
continue;
|
91 |
+
|
92 |
+
if ($post_type == 'post')
|
93 |
+
add_submenu_page('edit.php', 'Taxonomy Order', 'Taxonomy Order', 'level_'.$options['level'], 'to-interface-'.$post_type, 'TOPluginInterface' );
|
94 |
+
else
|
95 |
+
add_submenu_page('edit.php?post_type='.$post_type, 'Taxonomy Order', 'Taxonomy Order', 'level_'.$options['level'], 'to-interface-'.$post_type, 'TOPluginInterface' );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
add_action( 'wp_ajax_update-custom-type-order-hierarchical', array(&$this, 'saveAjaxOrderHierarchical') );
|
101 |
+
|
102 |
+
|
103 |
+
function mycategoryorder_applyorderfilter($orderby, $args)
|
104 |
+
{
|
105 |
+
$options = get_option('tto_options');
|
106 |
+
|
107 |
+
//if admin make sure use the admin setting
|
108 |
+
if (is_admin())
|
109 |
+
{
|
110 |
+
if ($options['adminsort'] == "1")
|
111 |
+
return 't.term_order';
|
112 |
+
|
113 |
+
return $orderby;
|
114 |
+
}
|
115 |
+
|
116 |
+
//if autosort, then force the menu_order
|
117 |
+
if ($options['autosort'] == 1)
|
118 |
+
{
|
119 |
+
return 't.term_order';
|
120 |
+
}
|
121 |
+
|
122 |
+
return $orderby;
|
123 |
+
}
|
124 |
+
|
125 |
+
add_filter('get_terms_orderby', 'mycategoryorder_applyorderfilter', 10, 2);
|
126 |
+
|
127 |
+
|
128 |
+
add_action( 'wp_ajax_update-taxonomy-order', 'TOsaveAjaxOrder' );
|
129 |
+
function TOsaveAjaxOrder()
|
130 |
+
{
|
131 |
+
global $wpdb;
|
132 |
+
$taxonomy = stripslashes($_POST['taxonomy']);
|
133 |
+
$data = stripslashes($_POST['order']);
|
134 |
+
$unserialised_data = unserialize($data);
|
135 |
+
|
136 |
+
if (is_array($unserialised_data))
|
137 |
+
foreach($unserialised_data as $key => $values )
|
138 |
+
{
|
139 |
+
//$key_parent = str_replace("item_", "", $key);
|
140 |
+
$items = explode("&", $values);
|
141 |
+
unset($item);
|
142 |
+
foreach ($items as $item_key => $item_)
|
143 |
+
{
|
144 |
+
$items[$item_key] = trim(str_replace("item[]=", "",$item_));
|
145 |
+
}
|
146 |
+
|
147 |
+
if (is_array($items) && count($items) > 0)
|
148 |
+
foreach( $items as $item_key => $term_id )
|
149 |
+
{
|
150 |
+
/*
|
151 |
+
$args = array(
|
152 |
+
'parent' => $key_parent
|
153 |
+
);
|
154 |
+
wp_update_term( $term_id, $taxonomy, $args );
|
155 |
+
*/
|
156 |
+
$wpdb->update( $wpdb->terms, array('term_order' => ($item_key + 1)), array('term_id' => $term_id) );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
?>
|