Version Description
Make sure you get the latest version
Download this release
Release Info
Developer | nsp-code |
Plugin | Post Types Order |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.3 to 1.4.6
- post-types-order.php +153 -1
- readme.txt +9 -4
post-types-order.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.nsp-code.com
|
|
5 |
Description: Order Post Types Objects using a Drag and Drop Sortable javascript capability
|
6 |
Author: NSP CODE
|
7 |
Author URI: http://www.nsp-code.com
|
8 |
-
Version: 1.4.
|
9 |
*/
|
10 |
|
11 |
define('CPTPATH', ABSPATH.'wp-content/plugins/post-types-order');
|
@@ -137,6 +137,158 @@ function initCPTO()
|
|
137 |
}
|
138 |
}
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
class Post_Types_Order_Walker extends Walker
|
142 |
{
|
5 |
Description: Order Post Types Objects using a Drag and Drop Sortable javascript capability
|
6 |
Author: NSP CODE
|
7 |
Author URI: http://www.nsp-code.com
|
8 |
+
Version: 1.4.6
|
9 |
*/
|
10 |
|
11 |
define('CPTPATH', ABSPATH.'wp-content/plugins/post-types-order');
|
137 |
}
|
138 |
}
|
139 |
|
140 |
+
add_filter('get_previous_post_where', 'cpto_get_previous_post_where');
|
141 |
+
add_filter('get_previous_post_sort', 'cpto_get_previous_post_sort');
|
142 |
+
add_filter('get_next_post_where', 'cpto_get_next_post_where');
|
143 |
+
add_filter('get_next_post_sort', 'cpto_get_next_post_sort');
|
144 |
+
function cpto_get_previous_post_where($where)
|
145 |
+
{
|
146 |
+
global $post, $wpdb;
|
147 |
+
|
148 |
+
if ( empty( $post ) )
|
149 |
+
return $where;
|
150 |
+
|
151 |
+
$current_post_date = $post->post_date;
|
152 |
+
|
153 |
+
$join = '';
|
154 |
+
$posts_in_ex_cats_sql = '';
|
155 |
+
if ( $in_same_cat || !empty($excluded_categories) )
|
156 |
+
{
|
157 |
+
$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
|
158 |
+
|
159 |
+
if ( $in_same_cat ) {
|
160 |
+
$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
|
161 |
+
$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
|
162 |
+
}
|
163 |
+
|
164 |
+
$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
|
165 |
+
if ( !empty($excluded_categories) ) {
|
166 |
+
$excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
|
167 |
+
if ( !empty($cat_array) ) {
|
168 |
+
$excluded_categories = array_diff($excluded_categories, $cat_array);
|
169 |
+
$posts_in_ex_cats_sql = '';
|
170 |
+
}
|
171 |
+
|
172 |
+
if ( !empty($excluded_categories) ) {
|
173 |
+
$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
$current_menu_order = $post->menu_order;
|
178 |
+
|
179 |
+
//check if there are more posts with lower menu_order
|
180 |
+
$query = "SELECT p.* FROM $wpdb->posts AS p
|
181 |
+
WHERE p.menu_order < '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql";
|
182 |
+
$results = $wpdb->get_results($query);
|
183 |
+
|
184 |
+
if (count($results) > 0)
|
185 |
+
{
|
186 |
+
$where = $wpdb->prepare("WHERE p.menu_order < '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql");
|
187 |
+
}
|
188 |
+
else
|
189 |
+
{
|
190 |
+
$where = $wpdb->prepare("WHERE p.post_date < '".$current_post_date."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' AND p.ID != '". $post->ID ."' $posts_in_ex_cats_sql");
|
191 |
+
}
|
192 |
+
|
193 |
+
return $where;
|
194 |
+
}
|
195 |
+
|
196 |
+
function cpto_get_previous_post_sort($sort)
|
197 |
+
{
|
198 |
+
global $post, $wpdb;
|
199 |
+
|
200 |
+
$current_menu_order = $post->menu_order;
|
201 |
+
|
202 |
+
$query = "SELECT p.* FROM $wpdb->posts AS p
|
203 |
+
WHERE p.menu_order < '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql";
|
204 |
+
$results = $wpdb->get_results($query);
|
205 |
+
|
206 |
+
if (count($results) > 0)
|
207 |
+
{
|
208 |
+
$sort = 'ORDER BY p.menu_order DESC, p.post_date ASC LIMIT 1';
|
209 |
+
}
|
210 |
+
else
|
211 |
+
{
|
212 |
+
$sort = 'ORDER BY p.post_date DESC LIMIT 1';
|
213 |
+
}
|
214 |
+
|
215 |
+
return $sort;
|
216 |
+
}
|
217 |
+
|
218 |
+
function cpto_get_next_post_where($where)
|
219 |
+
{
|
220 |
+
global $post, $wpdb;
|
221 |
+
|
222 |
+
if ( empty( $post ) )
|
223 |
+
return null;
|
224 |
+
|
225 |
+
$current_post_date = $post->post_date;
|
226 |
+
|
227 |
+
$join = '';
|
228 |
+
$posts_in_ex_cats_sql = '';
|
229 |
+
if ( $in_same_cat || !empty($excluded_categories) )
|
230 |
+
{
|
231 |
+
$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
|
232 |
+
|
233 |
+
if ( $in_same_cat ) {
|
234 |
+
$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
|
235 |
+
$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
|
236 |
+
}
|
237 |
+
|
238 |
+
$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
|
239 |
+
if ( !empty($excluded_categories) ) {
|
240 |
+
$excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
|
241 |
+
if ( !empty($cat_array) ) {
|
242 |
+
$excluded_categories = array_diff($excluded_categories, $cat_array);
|
243 |
+
$posts_in_ex_cats_sql = '';
|
244 |
+
}
|
245 |
+
|
246 |
+
if ( !empty($excluded_categories) ) {
|
247 |
+
$posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
$current_menu_order = $post->menu_order;
|
253 |
+
|
254 |
+
//check if there are more posts with lower menu_order
|
255 |
+
$query = "SELECT p.* FROM $wpdb->posts AS p
|
256 |
+
WHERE p.menu_order > '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql";
|
257 |
+
$results = $wpdb->get_results($query);
|
258 |
+
|
259 |
+
if (count($results) > 0)
|
260 |
+
{
|
261 |
+
$where = $wpdb->prepare("WHERE p.menu_order > '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql");
|
262 |
+
}
|
263 |
+
else
|
264 |
+
{
|
265 |
+
$where = $wpdb->prepare("WHERE p.post_date > '".$current_post_date."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' AND p.ID != '". $post->ID ."' $posts_in_ex_cats_sql");
|
266 |
+
}
|
267 |
+
|
268 |
+
return $where;
|
269 |
+
}
|
270 |
+
|
271 |
+
function cpto_get_next_post_sort($sort)
|
272 |
+
{
|
273 |
+
global $post, $wpdb;
|
274 |
+
|
275 |
+
$current_menu_order = $post->menu_order;
|
276 |
+
|
277 |
+
$query = "SELECT p.* FROM $wpdb->posts AS p
|
278 |
+
WHERE p.menu_order > '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish' $posts_in_ex_cats_sql";
|
279 |
+
$results = $wpdb->get_results($query);
|
280 |
+
if (count($results) > 0)
|
281 |
+
{
|
282 |
+
$sort = 'ORDER BY p.menu_order ASC, p.post_date DESC LIMIT 1';
|
283 |
+
}
|
284 |
+
else
|
285 |
+
{
|
286 |
+
$sort = 'ORDER BY p.post_date ASC LIMIT 1';
|
287 |
+
}
|
288 |
+
|
289 |
+
return $sort;
|
290 |
+
}
|
291 |
+
|
292 |
|
293 |
class Post_Types_Order_Walker extends Walker
|
294 |
{
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Post Types Order ===
|
2 |
Contributors: Nsp Code
|
3 |
Donate link: http://www.nsp-code.com/donate.php
|
4 |
-
Tags: post type order, custom post type order, post types order,
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1
|
7 |
-
Stable tag: 1.4.
|
8 |
|
9 |
Order Post Types Objects (posts, pages, custom post types) using a Drag and Drop Sortable javascript capability
|
10 |
|
@@ -12,6 +12,7 @@ Order Post Types Objects (posts, pages, custom post types) using a Drag and Drop
|
|
12 |
|
13 |
Order Post Types Objects using a Drag and Drop Sortable javascript capability
|
14 |
It allow to reorder the posts for any custom post types you defined, including the default Posts and Pages. Also you can have the admin posts interface sorted per your new sort.
|
|
|
15 |
|
16 |
== Installation ==
|
17 |
|
@@ -47,10 +48,13 @@ All ideas are welcome and i put them on my list to be implemented into the new v
|
|
47 |
|
48 |
== Change Log ==
|
49 |
|
50 |
-
= 1.4.
|
|
|
|
|
|
|
51 |
- Small improvments
|
52 |
|
53 |
-
= 1.4.1
|
54 |
- Re-Order Menu Item Appearance fix for update versions
|
55 |
|
56 |
= 1.3.9 =
|
@@ -89,3 +93,4 @@ Make sure you get the latest version
|
|
89 |
|
90 |
Currently only available in English and Brazilian Portuguese.
|
91 |
Want to contribute with a translation to your language? Please contact me at electronice_delphi@yahoo.com
|
|
1 |
=== Post Types Order ===
|
2 |
Contributors: Nsp Code
|
3 |
Donate link: http://www.nsp-code.com/donate.php
|
4 |
+
Tags: post type order, custom post type order, post types order, pages order, posts order, admin posts order
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1
|
7 |
+
Stable tag: 1.4.6
|
8 |
|
9 |
Order Post Types Objects (posts, pages, custom post types) using a Drag and Drop Sortable javascript capability
|
10 |
|
12 |
|
13 |
Order Post Types Objects using a Drag and Drop Sortable javascript capability
|
14 |
It allow to reorder the posts for any custom post types you defined, including the default Posts and Pages. Also you can have the admin posts interface sorted per your new sort.
|
15 |
+
<br />This plugin it's developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
|
16 |
|
17 |
== Installation ==
|
18 |
|
48 |
|
49 |
== Change Log ==
|
50 |
|
51 |
+
= 1.4.6
|
52 |
+
- Get Previous / Next Posts Update
|
53 |
+
|
54 |
+
= 1.4.3
|
55 |
- Small improvments
|
56 |
|
57 |
+
= 1.4.1
|
58 |
- Re-Order Menu Item Appearance fix for update versions
|
59 |
|
60 |
= 1.3.9 =
|
93 |
|
94 |
Currently only available in English and Brazilian Portuguese.
|
95 |
Want to contribute with a translation to your language? Please contact me at electronice_delphi@yahoo.com
|
96 |
+
http://www.nsp-code.com
|