Post Types Order - Version 1.9.3

Version Description

  • Fix for custom post type objects per page when using default archive interface drag & drop sort
    • Plugin code redo and re-structure
    • Improved compatibility with other plugins
    • Security improvments for AJAX order updates
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 Post Types Order
Version 1.9.3
Comparing to
See all releases

Code changes from version 1.9 to 1.9.3

include/{cpto-class.php → class.cpto.php} RENAMED
@@ -1,382 +1,599 @@
1
- <?php
2
-
3
- class CPTO
4
- {
5
- var $current_post_type = null;
6
-
7
- function __construct()
8
- {
9
- add_action( 'admin_init', array(&$this, 'registerFiles'), 11 );
10
- add_action( 'admin_init', array(&$this, 'checkPost'), 10 );
11
- add_action( 'admin_menu', array(&$this, 'addMenu') );
12
-
13
- //load archive drag&drop sorting dependencies
14
- add_action( 'admin_enqueue_scripts', array(&$this, 'archiveDragDrop'), 10 );
15
-
16
- add_action( 'wp_ajax_update-custom-type-order', array(&$this, 'saveAjaxOrder') );
17
- add_action( 'wp_ajax_update-custom-type-order-archive', array(&$this, 'saveArchiveAjaxOrder') );
18
- }
19
-
20
-
21
- /**
22
- * Load archive drag&drop sorting dependencies
23
- *
24
- * Since version 1.8.8
25
- */
26
- function archiveDragDrop()
27
- {
28
- $options = cpt_get_options();
29
-
30
- //if functionality turned off, continue
31
- if( $options['archive_drag_drop'] != '1')
32
- return;
33
-
34
- //if adminsort turned off no need to continue
35
- if( $options['adminsort'] != '1')
36
- return;
37
-
38
- $screen = get_current_screen();
39
-
40
- //check if the right interface
41
- if(!isset($screen->post_type) || empty($screen->post_type))
42
- return;
43
-
44
- //check if post type is sortable
45
- if(isset($options['show_reorder_interfaces'][$screen->post_type]) && $options['show_reorder_interfaces'][$screen->post_type] != 'show')
46
- return;
47
-
48
- //if is taxonomy term filter return
49
- if(is_category() || is_tax())
50
- return;
51
-
52
- //return if use orderby columns
53
- if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
54
- return false;
55
-
56
- //return if post status filtering
57
- if (isset($_GET['post_status']))
58
- return false;
59
-
60
- //return if post author filtering
61
- if (isset($_GET['author']))
62
- return false;
63
-
64
- //load required dependencies
65
- wp_enqueue_style('cpt-archive-dd', CPTURL . '/css/cpt-archive-dd.css');
66
-
67
- wp_enqueue_script('jquery');
68
- wp_enqueue_script('jquery-ui-sortable');
69
- wp_enqueue_script('cpt', CPTURL . '/js/cpt.js', array('jquery'));
70
-
71
- }
72
-
73
- function registerFiles()
74
- {
75
- if ( $this->current_post_type != null )
76
- {
77
- wp_enqueue_script('jQuery');
78
- wp_enqueue_script('jquery-ui-sortable');
79
- }
80
-
81
- wp_register_style('CPTStyleSheets', CPTURL . '/css/cpt.css');
82
- wp_enqueue_style( 'CPTStyleSheets');
83
- }
84
-
85
- function checkPost()
86
- {
87
- if ( isset($_GET['page']) && substr($_GET['page'], 0, 17) == 'order-post-types-' )
88
- {
89
- $this->current_post_type = get_post_type_object(str_replace( 'order-post-types-', '', $_GET['page'] ));
90
- if ( $this->current_post_type == null)
91
- {
92
- wp_die('Invalid post type');
93
- }
94
- }
95
- }
96
-
97
-
98
- /**
99
- * Save the order set through separate interface
100
- *
101
- */
102
- function saveAjaxOrder()
103
- {
104
-
105
- set_time_limit(600);
106
-
107
- global $wpdb;
108
-
109
- parse_str($_POST['order'], $data);
110
-
111
- if (is_array($data))
112
- foreach($data as $key => $values )
113
- {
114
- if ( $key == 'item' )
115
- {
116
- foreach( $values as $position => $id )
117
- {
118
- $data = array('menu_order' => $position);
119
- $data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
120
-
121
- $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
122
- }
123
- }
124
- else
125
- {
126
- foreach( $values as $position => $id )
127
- {
128
- $data = array('menu_order' => $position, 'post_parent' => str_replace('item_', '', $key));
129
- $data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
130
-
131
- $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
132
- }
133
- }
134
- }
135
- }
136
-
137
-
138
- /**
139
- * Save the order set throgh the Archive
140
- *
141
- */
142
- function saveArchiveAjaxOrder()
143
- {
144
-
145
- set_time_limit(600);
146
-
147
- global $wpdb;
148
-
149
- $post_type = filter_var ( $_POST['post_type'], FILTER_SANITIZE_STRING);
150
- $paged = filter_var ( $_POST['paged'], FILTER_SANITIZE_NUMBER_INT);
151
- parse_str($_POST['order'], $data);
152
-
153
- if (!is_array($data) || count($data) < 1)
154
- die();
155
-
156
- //retrieve a list of all objects
157
- $mysql_query = $wpdb->prepare("SELECT ID FROM ". $wpdb->posts ."
158
- WHERE post_type = %s AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
159
- ORDER BY menu_order, post_date DESC", $post_type);
160
- $results = $wpdb->get_results($mysql_query);
161
-
162
- if (!is_array($results) || count($results) < 1)
163
- die();
164
-
165
- //create the list of ID's
166
- $objects_ids = array();
167
- foreach($results as $result)
168
- {
169
- $objects_ids[] = $result->ID;
170
- }
171
-
172
- global $userdata;
173
- $objects_per_page = get_user_meta($userdata->ID ,'edit_post_per_page', TRUE);
174
- if(empty($objects_per_page))
175
- $objects_per_page = 20;
176
-
177
- $edit_start_at = $paged * $objects_per_page - $objects_per_page;
178
- $index = 0;
179
- for($i = $edit_start_at; $i < ($edit_start_at + $objects_per_page); $i++)
180
- {
181
- if(!isset($objects_ids[$i]))
182
- break;
183
-
184
- $objects_ids[$i] = $data['post'][$index];
185
- $index++;
186
- }
187
-
188
- //update the menu_order within database
189
- foreach( $objects_ids as $menu_order => $id )
190
- {
191
- $data = array(
192
- 'menu_order' => $menu_order
193
- );
194
- $data = apply_filters('post-types-order_save-ajax-order', $data, $menu_order, $id);
195
-
196
- $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
197
- }
198
-
199
- }
200
-
201
-
202
- function addMenu()
203
- {
204
- global $userdata;
205
- //put a menu for all custom_type
206
- $post_types = get_post_types();
207
-
208
- $options = cpt_get_options();
209
- //get the required user capability
210
- $capability = '';
211
- if(isset($options['capability']) && !empty($options['capability']))
212
- {
213
- $capability = $options['capability'];
214
- }
215
- else if (is_numeric($options['level']))
216
- {
217
- $capability = userdata_get_user_level();
218
- }
219
- else
220
- {
221
- $capability = 'install_plugins';
222
- }
223
-
224
- foreach( $post_types as $post_type_name )
225
- {
226
- if ($post_type_name == 'page')
227
- continue;
228
-
229
- //ignore bbpress
230
- if ($post_type_name == 'reply' || $post_type_name == 'topic')
231
- continue;
232
-
233
- if(is_post_type_hierarchical($post_type_name))
234
- continue;
235
-
236
- $post_type_data = get_post_type_object( $post_type_name );
237
- if($post_type_data->show_ui === FALSE)
238
- continue;
239
-
240
- if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] != 'show')
241
- continue;
242
-
243
- if ($post_type_name == 'post')
244
- add_submenu_page('edit.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
245
- elseif ($post_type_name == 'attachment')
246
- add_submenu_page('upload.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
247
- else
248
- {
249
- add_submenu_page('edit.php?post_type='.$post_type_name, __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
250
- }
251
- }
252
- }
253
-
254
-
255
- function SortPage()
256
- {
257
- ?>
258
- <div id="cpto" class="wrap">
259
- <div class="icon32" id="icon-edit"><br></div>
260
- <h2><?php echo $this->current_post_type->labels->singular_name . ' - '. __('Re-Order', 'post-types-order') ?></h2>
261
-
262
- <?php cpt_info_box(); ?>
263
-
264
- <div id="ajax-response"></div>
265
-
266
- <noscript>
267
- <div class="error message">
268
- <p><?php _e('This plugin can\'t work without javascript, because it\'s use drag and drop and AJAX.', 'post-types-order') ?></p>
269
- </div>
270
- </noscript>
271
-
272
- <div id="order-post-type">
273
- <ul id="sortable">
274
- <?php $this->listPages('hide_empty=0&title_li=&post_type='.$this->current_post_type->name); ?>
275
- </ul>
276
-
277
- <div class="clear"></div>
278
- </div>
279
-
280
- <p class="submit">
281
- <a href="javascript: void(0)" id="save-order" class="button-primary"><?php _e('Update', 'post-types-order' ) ?></a>
282
- </p>
283
-
284
- <script type="text/javascript">
285
- jQuery(document).ready(function() {
286
- jQuery("#sortable").sortable({
287
- 'tolerance':'intersect',
288
- 'cursor':'pointer',
289
- 'items':'li',
290
- 'placeholder':'placeholder',
291
- 'nested': 'ul'
292
- });
293
-
294
- jQuery("#sortable").disableSelection();
295
- jQuery("#save-order").bind( "click", function() {
296
-
297
- jQuery("html, body").animate({ scrollTop: 0 }, "fast");
298
-
299
- jQuery.post( ajaxurl, { action:'update-custom-type-order', order:jQuery("#sortable").sortable("serialize") }, function() {
300
- jQuery("#ajax-response").html('<div class="message updated fade"><p><?php _e('Items Order Updated', 'post-types-order') ?></p></div>');
301
- jQuery("#ajax-response div").delay(3000).hide("slow");
302
- });
303
- });
304
- });
305
- </script>
306
-
307
- </div>
308
- <?php
309
- }
310
-
311
- function listPages($args = '')
312
- {
313
- $defaults = array(
314
- 'depth' => -1,
315
- 'show_date' => '',
316
- 'date_format' => get_option('date_format'),
317
- 'child_of' => 0,
318
- 'exclude' => '',
319
- 'title_li' => __('Pages'),
320
- 'echo' => 1,
321
- 'authors' => '',
322
- 'sort_column' => 'menu_order',
323
- 'link_before' => '',
324
- 'link_after' => '',
325
- 'walker' => '',
326
- 'post_status' => 'any'
327
- );
328
-
329
- $r = wp_parse_args( $args, $defaults );
330
- extract( $r, EXTR_SKIP );
331
-
332
- $output = '';
333
-
334
- $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
335
- $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
336
- $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
337
-
338
- // Query pages.
339
- $r['hierarchical'] = 0;
340
- $args = array(
341
- 'sort_column' => 'menu_order',
342
- 'post_type' => $post_type,
343
- 'posts_per_page' => -1,
344
- 'post_status' => 'any',
345
- 'orderby' => array(
346
- 'menu_order' => 'ASC',
347
- 'post_date' => 'DESC'
348
- )
349
- );
350
-
351
- $the_query = new WP_Query($args);
352
- $pages = $the_query->posts;
353
-
354
- if ( !empty($pages) )
355
- {
356
- $output .= $this->walkTree($pages, $r['depth'], $r);
357
- }
358
-
359
- $output = apply_filters('wp_list_pages', $output, $r);
360
-
361
- if ( $r['echo'] )
362
- echo $output;
363
- else
364
- return $output;
365
- }
366
-
367
- function walkTree($pages, $depth, $r)
368
- {
369
- if ( empty($r['walker']) )
370
- $walker = new Post_Types_Order_Walker;
371
- else
372
- $walker = $r['walker'];
373
-
374
- $args = array($pages, $depth, $r);
375
- return call_user_func_array(array(&$walker, 'walk'), $args);
376
- }
377
- }
378
-
379
-
380
-
381
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  ?>
1
+ <?php
2
+
3
+ class CPTO
4
+ {
5
+ var $current_post_type = null;
6
+
7
+ var $functions;
8
+
9
+ function __construct()
10
+ {
11
+
12
+ $this->functions = new CptoFunctions();
13
+
14
+ $is_configured = get_option('CPT_configured');
15
+ if ($is_configured == '')
16
+ add_action( 'admin_notices', array($this, 'admin_configure_notices'));
17
+
18
+
19
+ add_filter('init', array($this, 'on_init'));
20
+
21
+
22
+ add_filter('pre_get_posts', array($this, 'pre_get_posts'));
23
+ add_filter('posts_orderby', array($this, 'posts_orderby'), 99, 2);
24
+
25
+
26
+ }
27
+
28
+
29
+ function init()
30
+ {
31
+
32
+ include_once(CPTPATH . '/include/class.walkers.php');
33
+
34
+ add_action( 'admin_init', array(&$this, 'registerFiles'), 11 );
35
+ add_action( 'admin_init', array(&$this, 'checkPost'), 10 );
36
+ add_action( 'admin_menu', array(&$this, 'addMenu') );
37
+
38
+ add_action('admin_menu', array(&$this, 'plugin_options_menu'));
39
+
40
+ //load archive drag&drop sorting dependencies
41
+ add_action( 'admin_enqueue_scripts', array(&$this, 'archiveDragDrop'), 10 );
42
+
43
+ add_action( 'wp_ajax_update-custom-type-order', array(&$this, 'saveAjaxOrder') );
44
+ add_action( 'wp_ajax_update-custom-type-order-archive', array(&$this, 'saveArchiveAjaxOrder') );
45
+
46
+
47
+ }
48
+
49
+
50
+ /**
51
+ * On WordPress Init hook
52
+ * This is being used to set the navigational links
53
+ *
54
+ */
55
+ function on_init()
56
+ {
57
+
58
+ if(is_admin())
59
+ return;
60
+
61
+
62
+ //check the navigation_sort_apply option
63
+ $options = $this->functions->get_options();
64
+
65
+ $navigation_sort_apply = ($options['navigation_sort_apply'] == "1") ? TRUE : FALSE;
66
+ $navigation_sort_apply = apply_filters('cpto/navigation_sort_apply', $navigation_sort_apply);
67
+
68
+ if( ! $navigation_sort_apply)
69
+ return;
70
+
71
+ add_filter('get_previous_post_where', array($this->functions, 'cpto_get_previous_post_where'), 99, 3);
72
+ add_filter('get_previous_post_sort', array($this->functions, 'cpto_get_previous_post_sort') );
73
+ add_filter('get_next_post_where', array($this->functions, 'cpto_get_next_post_where'), 99, 3);
74
+ add_filter('get_next_post_sort', array($this->functions, 'cpto_get_next_post_sort') );
75
+
76
+ }
77
+
78
+
79
+
80
+ function pre_get_posts($query)
81
+ {
82
+
83
+ //no need if it's admin interface
84
+ if (is_admin())
85
+ return $query;
86
+
87
+ //check for ignore_custom_sort
88
+ if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
89
+ return $query;
90
+
91
+ //ignore if "nav_menu_item"
92
+ if(isset($query->query_vars) && isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == "nav_menu_item")
93
+ return $query;
94
+
95
+ $options = $this->functions->get_options();
96
+
97
+ //if auto sort
98
+ if ($options['autosort'] == "1")
99
+ {
100
+ //remove the supresed filters;
101
+ if (isset($query->query['suppress_filters']))
102
+ $query->query['suppress_filters'] = FALSE;
103
+
104
+
105
+ if (isset($query->query_vars['suppress_filters']))
106
+ $query->query_vars['suppress_filters'] = FALSE;
107
+
108
+ }
109
+
110
+ return $query;
111
+ }
112
+
113
+
114
+
115
+ function posts_orderby($orderBy, $query)
116
+ {
117
+ global $wpdb;
118
+
119
+ $options = $this->functions->get_options();
120
+
121
+ //check for ignore_custom_sort
122
+ if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
123
+ return $orderBy;
124
+
125
+ //ignore the bbpress
126
+ if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("reply", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "reply")))
127
+ return $orderBy;
128
+ if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("topic", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "topic")))
129
+ return $orderBy;
130
+
131
+ //check for orderby GET paramether in which case return default data
132
+ if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
133
+ return $orderBy;
134
+
135
+ //check to ignore
136
+ /**
137
+ * Deprecated filter
138
+ * do not rely on this anymore
139
+ */
140
+ if(apply_filters('pto/posts_orderby', $orderBy, $query) === FALSE)
141
+ return $orderBy;
142
+
143
+ $ignore = apply_filters('pto/posts_orderby/ignore', FALSE, $orderBy, $query);
144
+ if($ignore === TRUE)
145
+ return $orderBy;
146
+
147
+ if (is_admin())
148
+ {
149
+
150
+ if ( $options['adminsort'] == "1" || (defined('DOING_AJAX') && isset($_REQUEST['action']) && $_REQUEST['action'] == 'query-attachments') )
151
+ {
152
+
153
+ global $post;
154
+
155
+ //temporary ignore ACF group and admin ajax calls, should be fixed within ACF plugin sometime later
156
+ if (is_object($post) && $post->post_type == "acf-field-group"
157
+ || (defined('DOING_AJAX') && isset($_REQUEST['action']) && strpos($_REQUEST['action'], 'acf/') === 0))
158
+ return $orderBy;
159
+
160
+ if(isset($_POST['query']) && isset($_POST['query']['post__in']) && is_array($_POST['query']['post__in']) && count($_POST['query']['post__in']) > 0)
161
+ return $orderBy;
162
+
163
+ $orderBy = "{$wpdb->posts}.menu_order, {$wpdb->posts}.post_date DESC";
164
+ }
165
+ }
166
+ else
167
+ {
168
+ //ignore search
169
+ if($query->is_search())
170
+ return($orderBy);
171
+
172
+ if ($options['autosort'] == "1")
173
+ {
174
+ if(trim($orderBy) == '')
175
+ $orderBy = "{$wpdb->posts}.menu_order ";
176
+ else
177
+ $orderBy = "{$wpdb->posts}.menu_order, " . $orderBy;
178
+ }
179
+ }
180
+
181
+ return($orderBy);
182
+ }
183
+
184
+
185
+
186
+ /**
187
+ * Show not configured notive
188
+ *
189
+ */
190
+ function admin_configure_notices()
191
+ {
192
+ if (isset($_POST['form_submit']))
193
+ return;
194
+
195
+ ?>
196
+ <div class="error fade">
197
+ <p><strong><?php _e('Post Types Order must be configured. Please go to', 'post-types-order') ?> <a href="<?php echo get_admin_url() ?>options-general.php?page=cpto-options"><?php _e('Settings Page', 'post-types-order') ?></a> <?php _e('make the configuration and save', 'post-types-order') ?></strong></p>
198
+ </div>
199
+ <?php
200
+ }
201
+
202
+
203
+ /**
204
+ * Plugin options menu
205
+ *
206
+ */
207
+ function plugin_options_menu()
208
+ {
209
+
210
+ include (CPTPATH . '/include/class.options.php');
211
+
212
+ $options_interface = new CptoOptionsInterface();
213
+ $options_interface->check_options_update();
214
+
215
+ add_options_page('Post Types Order', '<img class="menu_pto" src="'. CPTURL .'/images/menu-icon.png" alt="" />Post Types Order', 'manage_options', 'cpto-options', array($options_interface, 'plugin_options_interface'));
216
+
217
+ }
218
+
219
+
220
+
221
+ /**
222
+ * Load archive drag&drop sorting dependencies
223
+ *
224
+ * Since version 1.8.8
225
+ */
226
+ function archiveDragDrop()
227
+ {
228
+ $options = $this->functions->get_options();
229
+
230
+ //if functionality turned off, continue
231
+ if( $options['archive_drag_drop'] != '1')
232
+ return;
233
+
234
+ //if adminsort turned off no need to continue
235
+ if( $options['adminsort'] != '1')
236
+ return;
237
+
238
+ $screen = get_current_screen();
239
+
240
+ //check if the right interface
241
+ if(!isset($screen->post_type) || empty($screen->post_type))
242
+ return;
243
+
244
+ //check if post type is sortable
245
+ if(isset($options['show_reorder_interfaces'][$screen->post_type]) && $options['show_reorder_interfaces'][$screen->post_type] != 'show')
246
+ return;
247
+
248
+ //if is taxonomy term filter return
249
+ if(is_category() || is_tax())
250
+ return;
251
+
252
+ //return if use orderby columns
253
+ if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
254
+ return false;
255
+
256
+ //return if post status filtering
257
+ if (isset($_GET['post_status']))
258
+ return false;
259
+
260
+ //return if post author filtering
261
+ if (isset($_GET['author']))
262
+ return false;
263
+
264
+ //load required dependencies
265
+ wp_enqueue_style('cpt-archive-dd', CPTURL . '/css/cpt-archive-dd.css');
266
+
267
+ wp_enqueue_script('jquery');
268
+ wp_enqueue_script('jquery-ui-sortable');
269
+ wp_register_script('cpto', CPTURL . '/js/cpt.js', array('jquery'));
270
+
271
+ global $userdata;
272
+
273
+ // Localize the script with new data
274
+ $CPTO_variables = array(
275
+ 'archive_sort_nonce' => wp_create_nonce( 'CPTO_archive_sort_nonce_' . $userdata->ID)
276
+ );
277
+ wp_localize_script( 'cpto', 'CPTO', $CPTO_variables );
278
+
279
+ // Enqueued script with localized data.
280
+ wp_enqueue_script( 'cpto' );
281
+
282
+ }
283
+
284
+ function registerFiles()
285
+ {
286
+ if ( $this->current_post_type != null )
287
+ {
288
+ wp_enqueue_script('jQuery');
289
+ wp_enqueue_script('jquery-ui-sortable');
290
+ }
291
+
292
+ wp_register_style('CPTStyleSheets', CPTURL . '/css/cpt.css');
293
+ wp_enqueue_style( 'CPTStyleSheets');
294
+ }
295
+
296
+ function checkPost()
297
+ {
298
+ if ( isset($_GET['page']) && substr($_GET['page'], 0, 17) == 'order-post-types-' )
299
+ {
300
+ $this->current_post_type = get_post_type_object(str_replace( 'order-post-types-', '', $_GET['page'] ));
301
+ if ( $this->current_post_type == null)
302
+ {
303
+ wp_die('Invalid post type');
304
+ }
305
+ }
306
+ }
307
+
308
+
309
+ /**
310
+ * Save the order set through separate interface
311
+ *
312
+ */
313
+ function saveAjaxOrder()
314
+ {
315
+
316
+ set_time_limit(600);
317
+
318
+ global $wpdb;
319
+
320
+ $nonce = $_POST['interface_sort_nonce'];
321
+
322
+ //verify the nonce
323
+ if (! wp_verify_nonce( $nonce, 'interface_sort_nonce') )
324
+ die();
325
+
326
+ parse_str($_POST['order'], $data);
327
+
328
+ if (is_array($data))
329
+ foreach($data as $key => $values )
330
+ {
331
+ if ( $key == 'item' )
332
+ {
333
+ foreach( $values as $position => $id )
334
+ {
335
+
336
+ //sanitize
337
+ $id = (int)$id;
338
+
339
+ $data = array('menu_order' => $position);
340
+ $data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
341
+
342
+ $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
343
+ }
344
+ }
345
+ else
346
+ {
347
+ foreach( $values as $position => $id )
348
+ {
349
+
350
+ //sanitize
351
+ $id = (int)$id;
352
+
353
+ $data = array('menu_order' => $position, 'post_parent' => str_replace('item_', '', $key));
354
+ $data = apply_filters('post-types-order_save-ajax-order', $data, $key, $id);
355
+
356
+ $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+
363
+ /**
364
+ * Save the order set throgh the Archive
365
+ *
366
+ */
367
+ function saveArchiveAjaxOrder()
368
+ {
369
+
370
+ set_time_limit(600);
371
+
372
+ global $wpdb, $userdata;
373
+
374
+ $post_type = filter_var ( $_POST['post_type'], FILTER_SANITIZE_STRING);
375
+ $paged = filter_var ( $_POST['paged'], FILTER_SANITIZE_NUMBER_INT);
376
+ $nonce = $_POST['archive_sort_nonce'];
377
+
378
+ //verify the nonce
379
+ if (! wp_verify_nonce( $nonce, 'CPTO_archive_sort_nonce_' . $userdata->ID ) )
380
+ die();
381
+
382
+ parse_str($_POST['order'], $data);
383
+
384
+ if (!is_array($data) || count($data) < 1)
385
+ die();
386
+
387
+ //retrieve a list of all objects
388
+ $mysql_query = $wpdb->prepare("SELECT ID FROM ". $wpdb->posts ."
389
+ WHERE post_type = %s AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
390
+ ORDER BY menu_order, post_date DESC", $post_type);
391
+ $results = $wpdb->get_results($mysql_query);
392
+
393
+ if (!is_array($results) || count($results) < 1)
394
+ die();
395
+
396
+ //create the list of ID's
397
+ $objects_ids = array();
398
+ foreach($results as $result)
399
+ {
400
+ $objects_ids[] = (int)$result->ID;
401
+ }
402
+
403
+ global $userdata;
404
+ $objects_per_page = get_user_meta($userdata->ID ,'edit_' . $post_type .'_per_page', TRUE);
405
+ if(empty($objects_per_page))
406
+ $objects_per_page = 20;
407
+
408
+ $edit_start_at = $paged * $objects_per_page - $objects_per_page;
409
+ $index = 0;
410
+ for($i = $edit_start_at; $i < ($edit_start_at + $objects_per_page); $i++)
411
+ {
412
+ if(!isset($objects_ids[$i]))
413
+ break;
414
+
415
+ $objects_ids[$i] = (int)$data['post'][$index];
416
+ $index++;
417
+ }
418
+
419
+ //update the menu_order within database
420
+ foreach( $objects_ids as $menu_order => $id )
421
+ {
422
+ $data = array(
423
+ 'menu_order' => $menu_order
424
+ );
425
+ $data = apply_filters('post-types-order_save-ajax-order', $data, $menu_order, $id);
426
+
427
+ $wpdb->update( $wpdb->posts, $data, array('ID' => $id) );
428
+ }
429
+
430
+ }
431
+
432
+
433
+ function addMenu()
434
+ {
435
+ global $userdata;
436
+ //put a menu for all custom_type
437
+ $post_types = get_post_types();
438
+
439
+ $options = $this->functions->get_options();
440
+ //get the required user capability
441
+ $capability = '';
442
+ if(isset($options['capability']) && !empty($options['capability']))
443
+ {
444
+ $capability = $options['capability'];
445
+ }
446
+ else if (is_numeric($options['level']))
447
+ {
448
+ $capability = $this->functions->userdata_get_user_level();
449
+ }
450
+ else
451
+ {
452
+ $capability = 'install_plugins';
453
+ }
454
+
455
+ foreach( $post_types as $post_type_name )
456
+ {
457
+ if ($post_type_name == 'page')
458
+ continue;
459
+
460
+ //ignore bbpress
461
+ if ($post_type_name == 'reply' || $post_type_name == 'topic')
462
+ continue;
463
+
464
+ if(is_post_type_hierarchical($post_type_name))
465
+ continue;
466
+
467
+ $post_type_data = get_post_type_object( $post_type_name );
468
+ if($post_type_data->show_ui === FALSE)
469
+ continue;
470
+
471
+ if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] != 'show')
472
+ continue;
473
+
474
+ if ($post_type_name == 'post')
475
+ add_submenu_page('edit.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
476
+ elseif ($post_type_name == 'attachment')
477
+ add_submenu_page('upload.php', __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
478
+ else
479
+ {
480
+ add_submenu_page('edit.php?post_type='.$post_type_name, __('Re-Order', 'post-types-order'), __('Re-Order', 'post-types-order'), $capability, 'order-post-types-'.$post_type_name, array(&$this, 'SortPage') );
481
+ }
482
+ }
483
+ }
484
+
485
+
486
+ function SortPage()
487
+ {
488
+ ?>
489
+ <div id="cpto" class="wrap">
490
+ <div class="icon32" id="icon-edit"><br></div>
491
+ <h2><?php echo $this->current_post_type->labels->singular_name . ' - '. __('Re-Order', 'post-types-order') ?></h2>
492
+
493
+ <?php $this->functions->cpt_info_box(); ?>
494
+
495
+ <div id="ajax-response"></div>
496
+
497
+ <noscript>
498
+ <div class="error message">
499
+ <p><?php _e('This plugin can\'t work without javascript, because it\'s use drag and drop and AJAX.', 'post-types-order') ?></p>
500
+ </div>
501
+ </noscript>
502
+
503
+ <div id="order-post-type">
504
+ <ul id="sortable">
505
+ <?php $this->listPages('hide_empty=0&title_li=&post_type='.$this->current_post_type->name); ?>
506
+ </ul>
507
+
508
+ <div class="clear"></div>
509
+ </div>
510
+
511
+ <p class="submit">
512
+ <a href="javascript: void(0)" id="save-order" class="button-primary"><?php _e('Update', 'post-types-order' ) ?></a>
513
+ </p>
514
+
515
+ <?php wp_nonce_field( 'interface_sort_nonce', 'interface_sort_nonce' ); ?>
516
+
517
+ <script type="text/javascript">
518
+ jQuery(document).ready(function() {
519
+ jQuery("#sortable").sortable({
520
+ 'tolerance':'intersect',
521
+ 'cursor':'pointer',
522
+ 'items':'li',
523
+ 'placeholder':'placeholder',
524
+ 'nested': 'ul'
525
+ });
526
+
527
+ jQuery("#sortable").disableSelection();
528
+ jQuery("#save-order").bind( "click", function() {
529
+
530
+ jQuery("html, body").animate({ scrollTop: 0 }, "fast");
531
+
532
+ jQuery.post( ajaxurl, { action:'update-custom-type-order', order:jQuery("#sortable").sortable("serialize"), 'interface_sort_nonce' : jQuery('#interface_sort_nonce').val() }, function() {
533
+ jQuery("#ajax-response").html('<div class="message updated fade"><p><?php _e('Items Order Updated', 'post-types-order') ?></p></div>');
534
+ jQuery("#ajax-response div").delay(3000).hide("slow");
535
+ });
536
+ });
537
+ });
538
+ </script>
539
+
540
+ </div>
541
+ <?php
542
+ }
543
+
544
+ function listPages($args = '')
545
+ {
546
+ $defaults = array(
547
+ 'depth' => -1,
548
+ 'date_format' => get_option('date_format'),
549
+ 'child_of' => 0,
550
+ 'sort_column' => 'menu_order',
551
+ 'post_status' => 'any'
552
+ );
553
+
554
+ $r = wp_parse_args( $args, $defaults );
555
+ extract( $r, EXTR_SKIP );
556
+
557
+ $output = '';
558
+
559
+ $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', array()) );
560
+
561
+ // Query pages.
562
+ $r['hierarchical'] = 0;
563
+ $args = array(
564
+ 'sort_column' => 'menu_order',
565
+ 'post_type' => $post_type,
566
+ 'posts_per_page' => -1,
567
+ 'post_status' => 'any',
568
+ 'orderby' => array(
569
+ 'menu_order' => 'ASC',
570
+ 'post_date' => 'DESC'
571
+ )
572
+ );
573
+
574
+ $the_query = new WP_Query($args);
575
+ $pages = $the_query->posts;
576
+
577
+ if ( !empty($pages) )
578
+ {
579
+ $output .= $this->walkTree($pages, $r['depth'], $r);
580
+ }
581
+
582
+ $output = apply_filters('wp_list_pages', $output, $r);
583
+
584
+ echo $output;
585
+ }
586
+
587
+ function walkTree($pages, $depth, $r)
588
+ {
589
+ $walker = new Post_Types_Order_Walker;
590
+
591
+ $args = array($pages, $depth, $r);
592
+ return call_user_func_array(array(&$walker, 'walk'), $args);
593
+ }
594
+ }
595
+
596
+
597
+
598
+
599
  ?>
include/class.functions.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class CptoFunctions
5
+ {
6
+
7
+ /**
8
+ * Return the user level
9
+ *
10
+ * This is deprecated, will be removed in the next versions
11
+ *
12
+ * @param mixed $return_as_numeric
13
+ */
14
+ function userdata_get_user_level($return_as_numeric = FALSE)
15
+ {
16
+ global $userdata;
17
+
18
+ $user_level = '';
19
+ for ($i=10; $i >= 0;$i--)
20
+ {
21
+ if (current_user_can('level_' . $i) === TRUE)
22
+ {
23
+ $user_level = $i;
24
+ if ($return_as_numeric === FALSE)
25
+ $user_level = 'level_'.$i;
26
+ break;
27
+ }
28
+ }
29
+ return ($user_level);
30
+ }
31
+
32
+
33
+ /**
34
+ * Retrieve the plugin options
35
+ *
36
+ */
37
+ function get_options()
38
+ {
39
+ //make sure the vars are set as default
40
+ $options = get_option('cpto_options');
41
+
42
+ $defaults = array (
43
+ 'show_reorder_interfaces' => array(),
44
+ 'autosort' => 1,
45
+ 'adminsort' => 1,
46
+ 'archive_drag_drop' => 1,
47
+ 'capability' => 'install_plugins',
48
+ 'navigation_sort_apply' => 1,
49
+
50
+ );
51
+ $options = wp_parse_args( $options, $defaults );
52
+
53
+ $options = apply_filters('pto/get_options', $options);
54
+
55
+ return $options;
56
+ }
57
+
58
+
59
+ /**
60
+ * General messages box
61
+ *
62
+ */
63
+ function cpt_info_box()
64
+ {
65
+ ?>
66
+ <div id="cpt_info_box">
67
+ <div id="p_right">
68
+
69
+ <div id="p_socialize">
70
+
71
+ <div class="p_s_item s_f">
72
+ <div id="fb-root"></div>
73
+ <script>(function(d, s, id) {
74
+ var js, fjs = d.getElementsByTagName(s)[0];
75
+ if (d.getElementById(id)) return;
76
+ js = d.createElement(s); js.id = id;
77
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
78
+ fjs.parentNode.insertBefore(js, fjs);
79
+ }(document, 'script', 'facebook-jssdk'));</script>
80
+
81
+ <div class="fb-like" data-href="https://www.facebook.com/Nsp-Code-190329887674484/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
82
+
83
+ </div>
84
+
85
+ <div class="p_s_item s_t">
86
+ <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.nsp-code.com" data-text="Define custom order for your post types 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>
87
+ </div>
88
+
89
+ <div class="p_s_item s_gp">
90
+ <!-- Place this tag in your head or just before your close body tag -->
91
+ <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
92
+
93
+ <!-- Place this tag where you want the +1 button to render -->
94
+ <div class="g-plusone" data-size="small" data-annotation="none" data-href="http://nsp-code.com/"></div>
95
+ </div>
96
+
97
+ <div class="clear"></div>
98
+ </div>
99
+
100
+ </div>
101
+
102
+ <p><?php _e('Did you find this plugin useful? Please support our work by purchasing the advanced version or write an article about this plugin in your blog with a link to our site', 'post-types-order') ?> <a href="http://www.nsp-code.com/" target="_blank"><strong>http://www.nsp-code.com/</strong></a>.</p>
103
+ <h4><?php _e('Did you know there is available an Advanced version of this plug-in?', 'post-types-order') ?> <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/"><?php _e('Read more', 'post-types-order') ?></a></h4>
104
+ <p><?php _e('Check our', 'post-types-order') ?> <a target="_blank" href="http://wordpress.org/plugins/taxonomy-terms-order/">Category Order - Taxonomy Terms Order</a> <?php _e('plugin which allow to custom sort categories and custom taxonomies terms', 'post-types-order') ?> </p>
105
+ <p><span style="color:#CC0000" class="dashicons dashicons-megaphone" alt="f488">&nbsp;</span> <?php _e('Check out', 'post-types-order') ?> <a href="https://wordpress.org/plugins/wp-hide-security-enhancer/" target="_blank"><b>WP Hide & Security Enhancer</b></a> <?php _e('the easy way to completely hide your WordPress core files, theme and plugins', 'post-types-order') ?>.</p>
106
+
107
+ <div class="clear"></div>
108
+ </div>
109
+
110
+ <?php
111
+ }
112
+
113
+
114
+
115
+ function cpto_get_previous_post_where($where, $in_same_term, $excluded_terms)
116
+ {
117
+ global $post, $wpdb;
118
+
119
+ if ( empty( $post ) )
120
+ return $where;
121
+
122
+ //?? WordPress does not pass through this varialbe, so we presume it's category..
123
+ $taxonomy = 'category';
124
+ if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
125
+ $taxonomy = $match[1];
126
+
127
+ $_join = '';
128
+ $_where = '';
129
+
130
+ if ( $in_same_term || ! empty( $excluded_terms ) )
131
+ {
132
+ $_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";
133
+ $_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
134
+
135
+ if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
136
+ {
137
+ // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
138
+ if ( false !== strpos( $excluded_terms, ' and ' ) )
139
+ {
140
+ _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
141
+ $excluded_terms = explode( ' and ', $excluded_terms );
142
+ }
143
+ else
144
+ {
145
+ $excluded_terms = explode( ',', $excluded_terms );
146
+ }
147
+
148
+ $excluded_terms = array_map( 'intval', $excluded_terms );
149
+ }
150
+
151
+ if ( $in_same_term )
152
+ {
153
+ $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
154
+
155
+ // Remove any exclusions from the term array to include.
156
+ $term_array = array_diff( $term_array, (array) $excluded_terms );
157
+ $term_array = array_map( 'intval', $term_array );
158
+
159
+ $_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
160
+ }
161
+
162
+ if ( ! empty( $excluded_terms ) ) {
163
+ $_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )';
164
+ }
165
+ }
166
+
167
+ $current_menu_order = $post->menu_order;
168
+
169
+ $query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
170
+ $_join
171
+ WHERE p.post_date < %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where" , $post->post_date, $current_menu_order, $post->post_type);
172
+ $results = $wpdb->get_results($query);
173
+
174
+ if (count($results) > 0)
175
+ {
176
+ $where .= $wpdb->prepare( " AND p.menu_order = %d", $current_menu_order );
177
+ }
178
+ else
179
+ {
180
+ $where = str_replace("p.post_date < '". $post->post_date ."'", "p.menu_order > '$current_menu_order'", $where);
181
+ }
182
+
183
+ return $where;
184
+ }
185
+
186
+ function cpto_get_previous_post_sort($sort)
187
+ {
188
+ global $post, $wpdb;
189
+
190
+ $sort = 'ORDER BY p.menu_order ASC, p.post_date DESC LIMIT 1';
191
+
192
+ return $sort;
193
+ }
194
+
195
+ function cpto_get_next_post_where($where, $in_same_term, $excluded_terms)
196
+ {
197
+ global $post, $wpdb;
198
+
199
+ if ( empty( $post ) )
200
+ return $where;
201
+
202
+ $taxonomy = 'category';
203
+ if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
204
+ $taxonomy = $match[1];
205
+
206
+ $_join = '';
207
+ $_where = '';
208
+
209
+ if ( $in_same_term || ! empty( $excluded_terms ) )
210
+ {
211
+ $_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";
212
+ $_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
213
+
214
+ if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
215
+ {
216
+ // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
217
+ if ( false !== strpos( $excluded_terms, ' and ' ) )
218
+ {
219
+ _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
220
+ $excluded_terms = explode( ' and ', $excluded_terms );
221
+ }
222
+ else
223
+ {
224
+ $excluded_terms = explode( ',', $excluded_terms );
225
+ }
226
+
227
+ $excluded_terms = array_map( 'intval', $excluded_terms );
228
+ }
229
+
230
+ if ( $in_same_term )
231
+ {
232
+ $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
233
+
234
+ // Remove any exclusions from the term array to include.
235
+ $term_array = array_diff( $term_array, (array) $excluded_terms );
236
+ $term_array = array_map( 'intval', $term_array );
237
+
238
+ $_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
239
+ }
240
+
241
+ if ( ! empty( $excluded_terms ) ) {
242
+ $_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )';
243
+ }
244
+ }
245
+
246
+ $current_menu_order = $post->menu_order;
247
+
248
+ //check if there are more posts with lower menu_order
249
+ $query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
250
+ $_join
251
+ WHERE p.post_date > %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where", $post->post_date, $current_menu_order, $post->post_type );
252
+ $results = $wpdb->get_results($query);
253
+
254
+ if (count($results) > 0)
255
+ {
256
+ $where .= $wpdb->prepare(" AND p.menu_order = %d", $current_menu_order );
257
+ }
258
+ else
259
+ {
260
+ $where = str_replace("p.post_date > '". $post->post_date ."'", "p.menu_order < '$current_menu_order'", $where);
261
+ }
262
+
263
+ return $where;
264
+ }
265
+
266
+ function cpto_get_next_post_sort($sort)
267
+ {
268
+ global $post, $wpdb;
269
+
270
+ $sort = 'ORDER BY p.menu_order DESC, p.post_date ASC LIMIT 1';
271
+
272
+ return $sort;
273
+ }
274
+
275
+
276
+
277
+ }
278
+
279
+ ?>
include/class.options.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class CptoOptionsInterface
5
+ {
6
+
7
+ var $CPTO;
8
+
9
+
10
+ function __construct()
11
+ {
12
+
13
+ global $CPTO;
14
+
15
+ $this->CPTO = $CPTO;
16
+
17
+ }
18
+
19
+ function check_options_update()
20
+ {
21
+
22
+ $options = $this->CPTO->functions->get_options();
23
+
24
+ if (isset($_POST['form_submit']) && wp_verify_nonce($_POST['cpto_form_nonce'],'cpto_form_submit'))
25
+ {
26
+
27
+ $options['show_reorder_interfaces'] = (array) $_POST['show_reorder_interfaces'];
28
+ $options['show_reorder_interfaces'] = array_map( 'sanitize_key', $options['show_reorder_interfaces'] );
29
+
30
+ $options['capability'] = sanitize_key($_POST['capability']);
31
+
32
+ $options['autosort'] = isset($_POST['autosort']) ? intval($_POST['autosort']) : '';
33
+ $options['adminsort'] = isset($_POST['adminsort']) ? intval($_POST['adminsort']) : '';
34
+ $options['archive_drag_drop'] = isset($_POST['archive_drag_drop']) ? intval($_POST['archive_drag_drop']) : '';
35
+
36
+ $options['navigation_sort_apply'] = isset($_POST['navigation_sort_apply']) ? intval($_POST['navigation_sort_apply']) : '';
37
+
38
+ echo '<div class="updated fade"><p>' . __('Settings Saved', 'post-types-order') . '</p></div>';
39
+
40
+ update_option('cpto_options', $options);
41
+ update_option('CPT_configured', 'TRUE');
42
+
43
+ }
44
+
45
+ }
46
+
47
+
48
+ function plugin_options_interface()
49
+ {
50
+ $options = $this->CPTO->functions->get_options();
51
+
52
+ ?>
53
+ <div id="cpto" class="wrap">
54
+ <div id="icon-settings" class="icon32"></div>
55
+ <h2><?php _e('General Settings', 'post-types-order') ?></h2>
56
+
57
+ <?php $this->CPTO->functions->cpt_info_box(); ?>
58
+
59
+ <form id="form_data" name="form" method="post">
60
+ <br />
61
+ <h2 class="subtitle"><?php _e('General', 'post-types-order') ?></h2>
62
+ <table class="form-table">
63
+ <tbody>
64
+ <tr valign="top">
65
+ <th scope="row" style="text-align: right;"><label><?php _e('Show / Hide re-order interface', 'post-types-order') ?></label></th>
66
+ <td>
67
+ <?php
68
+
69
+ $post_types = get_post_types();
70
+ foreach( $post_types as $post_type_name )
71
+ {
72
+ //ignore list
73
+ $ignore_post_types = array(
74
+ 'reply',
75
+ 'topic',
76
+ 'report',
77
+ 'status'
78
+ );
79
+
80
+ if(in_array($post_type_name, $ignore_post_types))
81
+ continue;
82
+
83
+ if(is_post_type_hierarchical($post_type_name))
84
+ continue;
85
+
86
+ $post_type_data = get_post_type_object( $post_type_name );
87
+ if($post_type_data->show_ui === FALSE)
88
+ continue;
89
+ ?>
90
+ <p><label>
91
+ <select name="show_reorder_interfaces[<?php echo $post_type_name ?>]">
92
+ <option value="show" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'show') {echo ' selected="selected"';} ?>><?php _e( "Show", 'post-types-order' ) ?></option>
93
+ <option value="hide" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'hide') {echo ' selected="selected"';} ?>><?php _e( "Hide", 'post-types-order' ) ?></option>
94
+ </select> &nbsp;&nbsp;<?php echo $post_type_data->labels->singular_name ?>
95
+ </label><br />&nbsp;</p>
96
+ <?php } ?>
97
+ </td>
98
+ </tr>
99
+ <tr valign="top">
100
+ <th scope="row" style="text-align: right;"><label><?php _e('Minimum Level to use this plugin', 'post-types-order') ?></label></th>
101
+ <td>
102
+ <select id="role" name="capability">
103
+ <option value="read" <?php if (isset($options['capability']) && $options['capability'] == "read") echo 'selected="selected"'?>><?php _e('Subscriber', 'post-types-order') ?></option>
104
+ <option value="edit_posts" <?php if (isset($options['capability']) && $options['capability'] == "edit_posts") echo 'selected="selected"'?>><?php _e('Contributor', 'post-types-order') ?></option>
105
+ <option value="publish_posts" <?php if (isset($options['capability']) && $options['capability'] == "publish_posts") echo 'selected="selected"'?>><?php _e('Author', 'post-types-order') ?></option>
106
+ <option value="publish_pages" <?php if (isset($options['capability']) && $options['capability'] == "publish_pages") echo 'selected="selected"'?>><?php _e('Editor', 'post-types-order') ?></option>
107
+ <option value="switch_themes" <?php if (!isset($options['capability']) || empty($options['capability']) || (isset($options['capability']) && $options['capability'] == "switch_themes")) echo 'selected="selected"'?>><?php _e('Administrator', 'post-types-order') ?></option>
108
+ <?php do_action('pto/admin/plugin_options/capability') ?>
109
+ </select>
110
+ </td>
111
+ </tr>
112
+
113
+ <tr valign="top">
114
+ <th scope="row" style="text-align: right;"><label for="autosort"><?php _e('Auto Sort', 'post-types-order') ?></label></th>
115
+ <td>
116
+ <p><input type="checkbox" <?php checked( '1', $options['autosort'] ); ?> id="autosort" value="1" name="autosort"> <?php _e("If checked, the plug-in automatically update the WordPress queries to use the new order (<b>No code update is necessarily</b>)", 'post-types-order'); ?></p>
117
+ <p class="description"><?php _e("If only certain queries need to use the custom sort, keep this unchecked and include 'orderby' => 'menu_order' into query parameters", 'post-types-order') ?>.
118
+ <br />
119
+ <a href="http://www.nsp-code.com/sample-code-on-how-to-apply-the-sort-for-post-types-order-plugin/" target="_blank"><?php _e('Additional Description and Examples', 'post-types-order') ?></a></p>
120
+
121
+ </td>
122
+ </tr>
123
+
124
+
125
+ <tr valign="top">
126
+ <th scope="row" style="text-align: right;"><label for="adminsort"><?php _e('Admin Sort', 'post-types-order') ?></label></th>
127
+ <td>
128
+ <p>
129
+ <input type="checkbox" <?php checked( '1', $options['adminsort'] ); ?> id="adminsort" value="1" name="adminsort">
130
+ <?php _e("To affect the admin interface, to see the post types per your new sort, this need to be checked", 'post-types-order') ?>.</p>
131
+ </td>
132
+ </tr>
133
+
134
+ <tr valign="top">
135
+ <th scope="row" style="text-align: right;"><label for="archive_drag_drop"><?php _e('Archive Drag&Drop ', 'post-types-order') ?></label></th>
136
+ <td>
137
+ <p>
138
+ <input type="checkbox" <?php checked( '1', $options['archive_drag_drop'] ); ?> id="archive_drag_drop" value="1" name="archive_drag_drop">
139
+ <?php _e("Allow sortable drag & drop functionality within default WordPress post type archive. Admin Sort need to be active.", 'post-types-order') ?>.</p>
140
+ </td>
141
+ </tr>
142
+
143
+ <tr valign="top">
144
+ <th scope="row" style="text-align: right;"><label for="navigation_sort_apply"><?php _e('Next / Previous Apply', 'post-types-order') ?></label></th>
145
+ <td>
146
+ <p>
147
+ <input type="checkbox" <?php checked( '1', $options['navigation_sort_apply'] ); ?> id="navigation_sort_apply" value="1" name="navigation_sort_apply">
148
+ <?php _e("Apply the sort on Next / Previous site-wide navigation.", 'post-types-order') ?> <?php _e('This can also be controlled through', 'post-types-order') ?> <a href="http://www.nsp-code.com/apply-custom-sorting-for-next-previous-site-wide-navigation/" target="_blank"><?php _e('code', 'post-types-order') ?></a></p>
149
+ </td>
150
+ </tr>
151
+
152
+ </tbody>
153
+ </table>
154
+
155
+ <p class="submit">
156
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings', 'post-types-order') ?>">
157
+ </p>
158
+
159
+ <?php wp_nonce_field('cpto_form_submit','cpto_form_nonce'); ?>
160
+ <input type="hidden" name="form_submit" value="true" />
161
+
162
+
163
+ </form>
164
+
165
+ </div>
166
+ <?php
167
+
168
+ }
169
+ }
170
+
171
+ ?>
include/class.walkers.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Post_Types_Order_Walker extends Walker
4
+ {
5
+
6
+ var $db_fields = array (
7
+ 'parent' => 'post_parent',
8
+ 'id' => 'ID'
9
+ );
10
+
11
+
12
+ function start_lvl(&$output, $depth = 0, $args = array())
13
+ {
14
+ $indent = str_repeat("\t", $depth);
15
+ $output .= "\n$indent<ul class='children'>\n";
16
+ }
17
+
18
+
19
+ function end_lvl(&$output, $depth = 0, $args = array())
20
+ {
21
+ $indent = str_repeat("\t", $depth);
22
+ $output .= "$indent</ul>\n";
23
+ }
24
+
25
+
26
+ function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0)
27
+ {
28
+ if ( $depth )
29
+ $indent = str_repeat("\t", $depth);
30
+ else
31
+ $indent = '';
32
+
33
+ extract($args, EXTR_SKIP);
34
+
35
+ $item_details = apply_filters( 'the_title', $page->post_title, $page->ID );
36
+ $item_details = apply_filters('cpto/interface_itme_data', $item_details, $page);
37
+
38
+ $output .= $indent . '<li id="item_'.$page->ID.'"><span>'. $item_details .'</span>';
39
+
40
+
41
+
42
+ }
43
+
44
+
45
+ function end_el(&$output, $page, $depth = 0, $args = array())
46
+ {
47
+ $output .= "</li>\n";
48
+ }
49
+
50
+ }
51
+
52
+
53
+
54
+ ?>
include/functions.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
-
3
-
4
- /**
5
- * Return the user level
6
- *
7
- * This is deprecated, will be removed in the next versions
8
- *
9
- * @param mixed $return_as_numeric
10
- */
11
- function userdata_get_user_level($return_as_numeric = FALSE)
12
- {
13
- global $userdata;
14
-
15
- $user_level = '';
16
- for ($i=10; $i >= 0;$i--)
17
- {
18
- if (current_user_can('level_' . $i) === TRUE)
19
- {
20
- $user_level = $i;
21
- if ($return_as_numeric === FALSE)
22
- $user_level = 'level_'.$i;
23
- break;
24
- }
25
- }
26
- return ($user_level);
27
- }
28
-
29
-
30
- function cpt_get_options()
31
- {
32
- //make sure the vars are set as default
33
- $options = get_option('cpto_options');
34
-
35
- $defaults = array (
36
- 'show_reorder_interfaces' => array(),
37
- 'autosort' => 1,
38
- 'adminsort' => 1,
39
- 'archive_drag_drop' => 1,
40
- 'capability' => 'install_plugins',
41
- 'navigation_sort_apply' => 1,
42
-
43
- );
44
- $options = wp_parse_args( $options, $defaults );
45
-
46
- $options = apply_filters('pto/get_options', $options);
47
-
48
- return $options;
49
- }
50
-
51
- function cpt_info_box()
52
- {
53
- ?>
54
- <div id="cpt_info_box">
55
- <div id="p_right">
56
-
57
- <div id="p_socialize">
58
-
59
- <div class="p_s_item s_f">
60
- <div id="fb-root"></div>
61
- <script>(function(d, s, id) {
62
- var js, fjs = d.getElementsByTagName(s)[0];
63
- if (d.getElementById(id)) return;
64
- js = d.createElement(s); js.id = id;
65
- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
66
- fjs.parentNode.insertBefore(js, fjs);
67
- }(document, 'script', 'facebook-jssdk'));</script>
68
-
69
- <div class="fb-like" data-href="https://www.facebook.com/Nsp-Code-190329887674484/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
70
-
71
- </div>
72
-
73
- <div class="p_s_item s_t">
74
- <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.nsp-code.com" data-text="Define custom order for your post types 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>
75
- </div>
76
-
77
- <div class="p_s_item s_gp">
78
- <!-- Place this tag in your head or just before your close body tag -->
79
- <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
80
-
81
- <!-- Place this tag where you want the +1 button to render -->
82
- <div class="g-plusone" data-size="small" data-annotation="none" data-href="http://nsp-code.com/"></div>
83
- </div>
84
-
85
- <div class="clear"></div>
86
- </div>
87
-
88
- </div>
89
-
90
- <p><?php _e('Did you find this plugin useful? Please support our work by purchasing the advanced version or write an article about this plugin in your blog with a link to our site', 'post-types-order') ?> <a href="http://www.nsp-code.com/" target="_blank"><strong>http://www.nsp-code.com/</strong></a>.</p>
91
- <h4><?php _e('Did you know there is available an Advanced version of this plug-in?', 'post-types-order') ?> <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/"><?php _e('Read more', 'post-types-order') ?></a></h4>
92
- <p><?php _e('Check our', 'post-types-order') ?> <a target="_blank" href="http://wordpress.org/plugins/taxonomy-terms-order/">Category Order - Taxonomy Terms Order</a> <?php _e('plugin which allow to custom sort categories and custom taxonomies terms', 'post-types-order') ?> </p>
93
- <p><span style="color:#CC0000" class="dashicons dashicons-megaphone" alt="f488">&nbsp;</span> <?php _e('Check out', 'post-types-order') ?> <a href="https://wordpress.org/plugins/wp-hide-security-enhancer/" target="_blank"><b>WP Hide & Security Enhancer</b></a> <?php _e('the easy way to completely hide your WordPress core files, theme and plugins', 'post-types-order') ?>.</p>
94
-
95
- <div class="clear"></div>
96
- </div>
97
-
98
- <?php
99
- }
100
-
101
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/options.php DELETED
@@ -1,152 +0,0 @@
1
- <?php
2
-
3
-
4
- function cpt_plugin_options()
5
- {
6
- $options = cpt_get_options();
7
-
8
- if (isset($_POST['form_submit']) && wp_verify_nonce($_POST['cpto_form_nonce'],'cpto_form_submit'))
9
- {
10
-
11
- $options['show_reorder_interfaces'] = (array) $_POST['show_reorder_interfaces'];
12
- $options['show_reorder_interfaces'] = array_map( 'sanitize_key', $options['show_reorder_interfaces'] );
13
-
14
- $options['capability'] = sanitize_key($_POST['capability']);
15
-
16
- $options['autosort'] = isset($_POST['autosort']) ? intval($_POST['autosort']) : '';
17
- $options['adminsort'] = isset($_POST['adminsort']) ? intval($_POST['adminsort']) : '';
18
- $options['archive_drag_drop'] = isset($_POST['archive_drag_drop']) ? intval($_POST['archive_drag_drop']) : '';
19
-
20
- $options['navigation_sort_apply'] = isset($_POST['navigation_sort_apply']) ? intval($_POST['navigation_sort_apply']) : '';
21
-
22
- echo '<div class="updated fade"><p>' . __('Settings Saved', 'post-types-order') . '</p></div>';
23
-
24
- update_option('cpto_options', $options);
25
- update_option('CPT_configured', 'TRUE');
26
-
27
- }
28
-
29
- $queue_data = get_option('ce_queue');
30
-
31
- ?>
32
- <div id="cpto" class="wrap">
33
- <div id="icon-settings" class="icon32"></div>
34
- <h2><?php _e('General Settings', 'post-types-order') ?></h2>
35
-
36
- <?php cpt_info_box(); ?>
37
-
38
- <form id="form_data" name="form" method="post">
39
- <br />
40
- <h2 class="subtitle"><?php _e('General', 'post-types-order') ?></h2>
41
- <table class="form-table">
42
- <tbody>
43
- <tr valign="top">
44
- <th scope="row" style="text-align: right;"><label><?php _e('Show / Hide re-order interface', 'post-types-order') ?></label></th>
45
- <td>
46
- <?php
47
-
48
- $post_types = get_post_types();
49
- foreach( $post_types as $post_type_name )
50
- {
51
- //ignore list
52
- $ignore_post_types = array(
53
- 'reply',
54
- 'topic',
55
- 'report',
56
- 'status'
57
- );
58
-
59
- if(in_array($post_type_name, $ignore_post_types))
60
- continue;
61
-
62
- if(is_post_type_hierarchical($post_type_name))
63
- continue;
64
-
65
- $post_type_data = get_post_type_object( $post_type_name );
66
- if($post_type_data->show_ui === FALSE)
67
- continue;
68
- ?>
69
- <p><label>
70
- <select name="show_reorder_interfaces[<?php echo $post_type_name ?>]">
71
- <option value="show" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'show') {echo ' selected="selected"';} ?>><?php _e( "Show", 'post-types-order' ) ?></option>
72
- <option value="hide" <?php if(isset($options['show_reorder_interfaces'][$post_type_name]) && $options['show_reorder_interfaces'][$post_type_name] == 'hide') {echo ' selected="selected"';} ?>><?php _e( "Hide", 'post-types-order' ) ?></option>
73
- </select> &nbsp;&nbsp;<?php echo $post_type_data->labels->singular_name ?>
74
- </label><br />&nbsp;</p>
75
- <?php } ?>
76
- </td>
77
- </tr>
78
- <tr valign="top">
79
- <th scope="row" style="text-align: right;"><label><?php _e('Minimum Level to use this plugin', 'post-types-order') ?></label></th>
80
- <td>
81
- <select id="role" name="capability">
82
- <option value="read" <?php if (isset($options['capability']) && $options['capability'] == "read") echo 'selected="selected"'?>><?php _e('Subscriber', 'post-types-order') ?></option>
83
- <option value="edit_posts" <?php if (isset($options['capability']) && $options['capability'] == "edit_posts") echo 'selected="selected"'?>><?php _e('Contributor', 'post-types-order') ?></option>
84
- <option value="publish_posts" <?php if (isset($options['capability']) && $options['capability'] == "publish_posts") echo 'selected="selected"'?>><?php _e('Author', 'post-types-order') ?></option>
85
- <option value="publish_pages" <?php if (isset($options['capability']) && $options['capability'] == "publish_pages") echo 'selected="selected"'?>><?php _e('Editor', 'post-types-order') ?></option>
86
- <option value="switch_themes" <?php if (!isset($options['capability']) || empty($options['capability']) || (isset($options['capability']) && $options['capability'] == "switch_themes")) echo 'selected="selected"'?>><?php _e('Administrator', 'post-types-order') ?></option>
87
- <?php do_action('pto/admin/plugin_options/capability') ?>
88
- </select>
89
- </td>
90
- </tr>
91
-
92
- <tr valign="top">
93
- <th scope="row" style="text-align: right;"><label for="autosort"><?php _e('Auto Sort', 'post-types-order') ?></label></th>
94
- <td>
95
- <p><input type="checkbox" <?php checked( '1', $options['autosort'] ); ?> id="autosort" value="1" name="autosort"> <?php _e("If checked, the plug-in automatically update the WordPress queries to use the new order (<b>No code update is necessarily</b>)", 'post-types-order'); ?></p>
96
- <p class="description"><?php _e("If only certain queries need to use the custom sort, keep this unchecked and include 'orderby' => 'menu_order' into query parameters", 'post-types-order') ?>.
97
- <br />
98
- <a href="http://www.nsp-code.com/sample-code-on-how-to-apply-the-sort-for-post-types-order-plugin/" target="_blank"><?php _e('Additional Description and Examples', 'post-types-order') ?></a></p>
99
-
100
- </td>
101
- </tr>
102
-
103
-
104
- <tr valign="top">
105
- <th scope="row" style="text-align: right;"><label for="adminsort"><?php _e('Admin Sort', 'post-types-order') ?></label></th>
106
- <td>
107
- <p>
108
- <input type="checkbox" <?php checked( '1', $options['adminsort'] ); ?> id="adminsort" value="1" name="adminsort">
109
- <?php _e("To affect the admin interface, to see the post types per your new sort, this need to be checked", 'post-types-order') ?>.</p>
110
- </td>
111
- </tr>
112
-
113
- <tr valign="top">
114
- <th scope="row" style="text-align: right;"><label for="archive_drag_drop"><?php _e('Archive Drag&Drop ', 'post-types-order') ?></label></th>
115
- <td>
116
- <p>
117
- <input type="checkbox" <?php checked( '1', $options['archive_drag_drop'] ); ?> id="archive_drag_drop" value="1" name="archive_drag_drop">
118
- <?php _e("Allow sortable drag & drop functionality within default WordPress post type archive. Admin Sort need to be active.", 'post-types-order') ?>.</p>
119
- </td>
120
- </tr>
121
-
122
- <tr valign="top">
123
- <th scope="row" style="text-align: right;"><label for="navigation_sort_apply"><?php _e('Next / Previous Apply', 'post-types-order') ?></label></th>
124
- <td>
125
- <p>
126
- <input type="checkbox" <?php checked( '1', $options['navigation_sort_apply'] ); ?> id="navigation_sort_apply" value="1" name="navigation_sort_apply">
127
- <?php _e("Apply the sort on Next / Previous site-wide navigation.", 'post-types-order') ?> <?php _e('This can also be controlled through', 'post-types-order') ?> <a href="http://www.nsp-code.com/apply-custom-sorting-for-next-previous-site-wide-navigation/" target="_blank"><?php _e('code', 'post-types-order') ?></a></p>
128
- </td>
129
- </tr>
130
-
131
- </tbody>
132
- </table>
133
-
134
- <p class="submit">
135
- <input type="submit" name="Submit" class="button-primary" value="<?php
136
- _e('Save Settings', 'post-types-order') ?>">
137
- </p>
138
-
139
-
140
- <?php wp_nonce_field('cpto_form_submit','cpto_form_nonce'); ?>
141
- <input type="hidden" name="form_submit" value="true" />
142
-
143
-
144
- </form>
145
-
146
- <br />
147
- </div>
148
- <?php
149
-
150
- }
151
-
152
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/walkers.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
-
3
- class Post_Types_Order_Walker extends Walker
4
- {
5
-
6
- var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
7
-
8
-
9
- function start_lvl(&$output, $depth = 0, $args = array()) {
10
- $indent = str_repeat("\t", $depth);
11
- $output .= "\n$indent<ul class='children'>\n";
12
- }
13
-
14
-
15
- function end_lvl(&$output, $depth = 0, $args = array()) {
16
- $indent = str_repeat("\t", $depth);
17
- $output .= "$indent</ul>\n";
18
- }
19
-
20
-
21
- function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0) {
22
- if ( $depth )
23
- $indent = str_repeat("\t", $depth);
24
- else
25
- $indent = '';
26
-
27
- extract($args, EXTR_SKIP);
28
-
29
- $item_details = apply_filters( 'the_title', $page->post_title, $page->ID );
30
- $item_details = apply_filters('cpto/interface_itme_data', $item_details, $page);
31
-
32
- $output .= $indent . '<li id="item_'.$page->ID.'"><span>'. $item_details .'</span>';
33
-
34
-
35
-
36
- }
37
-
38
-
39
- function end_el(&$output, $page, $depth = 0, $args = array()) {
40
- $output .= "</li>\n";
41
- }
42
-
43
- }
44
-
45
-
46
-
47
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/cpt.js CHANGED
@@ -1,53 +1,54 @@
1
-
2
-
3
- var getUrlParameter = function getUrlParameter(sParam) {
4
- var sPageURL = decodeURIComponent(window.location.search.substring(1)),
5
- sURLVariables = sPageURL.split('&'),
6
- sParameterName,
7
- i;
8
-
9
- for (i = 0; i < sURLVariables.length; i++) {
10
- sParameterName = sURLVariables[i].split('=');
11
-
12
- if (sParameterName[0] === sParam) {
13
- return sParameterName[1] === undefined ? true : sParameterName[1];
14
- }
15
- }
16
- };
17
-
18
- jQuery(document).ready(function()
19
- {
20
-
21
- jQuery('table.posts #the-list').sortable({
22
- 'items': 'tr',
23
- 'axis': 'y',
24
- 'update' : function(e, ui) {
25
-
26
- var post_type = jQuery('input[name="post_type"]').val();
27
- var order = jQuery('#the-list').sortable('serialize');
28
-
29
- var paged = getUrlParameter('paged');
30
- if(typeof paged === 'undefined')
31
- paged = 1;
32
-
33
- var queryString = { "action": "update-custom-type-order-archive", "post_type" : post_type, "order" : order ,"paged": paged};
34
- //send the data through ajax
35
- jQuery.ajax({
36
- type: 'POST',
37
- url: ajaxurl,
38
- data: queryString,
39
- cache: false,
40
- dataType: "html",
41
- success: function(data){
42
-
43
- },
44
- error: function(html){
45
-
46
- }
47
- });
48
-
49
- }
50
- });
51
-
52
-
53
- });
 
1
+
2
+
3
+ var getUrlParameter = function getUrlParameter(sParam)
4
+ {
5
+ var sPageURL = decodeURIComponent(window.location.search.substring(1)),
6
+ sURLVariables = sPageURL.split('&'),
7
+ sParameterName,
8
+ i;
9
+
10
+ for (i = 0; i < sURLVariables.length; i++) {
11
+ sParameterName = sURLVariables[i].split('=');
12
+
13
+ if (sParameterName[0] === sParam) {
14
+ return sParameterName[1] === undefined ? true : sParameterName[1];
15
+ }
16
+ }
17
+ };
18
+
19
+ jQuery(document).ready(function()
20
+ {
21
+
22
+ jQuery('table.posts #the-list').sortable({
23
+ 'items': 'tr',
24
+ 'axis': 'y',
25
+ 'update' : function(e, ui) {
26
+
27
+ var post_type = jQuery('input[name="post_type"]').val();
28
+ var order = jQuery('#the-list').sortable('serialize');
29
+
30
+ var paged = getUrlParameter('paged');
31
+ if(typeof paged === 'undefined')
32
+ paged = 1;
33
+
34
+ var queryString = { "action": "update-custom-type-order-archive", "post_type" : post_type, "order" : order ,"paged": paged, "archive_sort_nonce" : CPTO.archive_sort_nonce};
35
+ //send the data through ajax
36
+ jQuery.ajax({
37
+ type: 'POST',
38
+ url: ajaxurl,
39
+ data: queryString,
40
+ cache: false,
41
+ dataType: "html",
42
+ success: function(data){
43
+
44
+ },
45
+ error: function(html){
46
+
47
+ }
48
+ });
49
+
50
+ }
51
+ });
52
+
53
+
54
+ });
post-types-order.php CHANGED
@@ -1,379 +1,79 @@
1
- <?php
2
- /*
3
- Plugin Name: Post Types Order
4
- Plugin URI: http://www.nsp-code.com
5
- Description: Posts Order and Post Types Objects Order using a Drag and Drop Sortable javascript capability
6
- Author: Nsp Code
7
- Author URI: http://www.nsp-code.com
8
- Version: 1.9
9
- Text Domain: post-types-order
10
- Domain Path: /languages/
11
- */
12
-
13
- define('CPTPATH', plugin_dir_path(__FILE__));
14
- define('CPTURL', plugins_url('', __FILE__));
15
-
16
-
17
- register_deactivation_hook(__FILE__, 'CPTO_deactivated');
18
- register_activation_hook(__FILE__, 'CPTO_activated');
19
-
20
- function CPTO_activated()
21
- {
22
- $options = cpt_get_options();
23
-
24
- update_option('cpto_options', $options);
25
- }
26
-
27
- function CPTO_deactivated()
28
- {
29
-
30
- }
31
-
32
- include_once(CPTPATH . '/include/functions.php');
33
- include_once(CPTPATH . '/include/walkers.php');
34
- include_once(CPTPATH . '/include/cpto-class.php');
35
-
36
- add_filter('pre_get_posts', 'CPTO_pre_get_posts');
37
- function CPTO_pre_get_posts($query)
38
- {
39
- //-- lee@cloudswipe.com requirement
40
- global $post;
41
- if(is_object($post) && isset($post->ID) && $post->ID < 1)
42
- { return $query; } // Stop running the function if this is a virtual page
43
- //--
44
-
45
- //no need if it's admin interface
46
- if (is_admin())
47
- return $query;
48
-
49
- //check for ignore_custom_sort
50
- if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
51
- return $query;
52
-
53
- //ignore if "nav_menu_item"
54
- if(isset($query->query_vars) && isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == "nav_menu_item")
55
- return $query;
56
-
57
- $options = cpt_get_options();
58
-
59
- //if auto sort
60
- if ($options['autosort'] == "1")
61
- {
62
- //remove the supresed filters;
63
- if (isset($query->query['suppress_filters']))
64
- $query->query['suppress_filters'] = FALSE;
65
-
66
-
67
- if (isset($query->query_vars['suppress_filters']))
68
- $query->query_vars['suppress_filters'] = FALSE;
69
-
70
- }
71
-
72
- return $query;
73
- }
74
-
75
- add_filter('posts_orderby', 'CPTOrderPosts', 99, 2);
76
- function CPTOrderPosts($orderBy, $query)
77
- {
78
- global $wpdb;
79
-
80
- $options = cpt_get_options();
81
-
82
- //check for ignore_custom_sort
83
- if (isset($query->query_vars['ignore_custom_sort']) && $query->query_vars['ignore_custom_sort'] === TRUE)
84
- return $orderBy;
85
-
86
- //ignore the bbpress
87
- if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("reply", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "reply")))
88
- return $orderBy;
89
- if (isset($query->query_vars['post_type']) && ((is_array($query->query_vars['post_type']) && in_array("topic", $query->query_vars['post_type'])) || ($query->query_vars['post_type'] == "topic")))
90
- return $orderBy;
91
-
92
- //check for orderby GET paramether in which case return default data
93
- if (isset($_GET['orderby']) && $_GET['orderby'] != 'menu_order')
94
- return $orderBy;
95
-
96
- //check to ignore
97
- if(apply_filters('pto/posts_orderby', $orderBy, $query) === FALSE)
98
- return $orderBy;
99
-
100
- if (is_admin())
101
- {
102
-
103
- if ($options['adminsort'] == "1" ||
104
- //ignore when ajax Gallery Edit default functionality
105
- (defined('DOING_AJAX') && isset($_REQUEST['action']) && $_REQUEST['action'] == 'query-attachments')
106
- )
107
- {
108
-
109
- global $post;
110
-
111
- //temporary ignore ACF group and admin ajax calls, should be fixed within ACF plugin sometime later
112
- if (is_object($post) && $post->post_type == "acf-field-group"
113
- || (defined('DOING_AJAX') && isset($_REQUEST['action']) && strpos($_REQUEST['action'], 'acf/') === 0))
114
- return $orderBy;
115
-
116
- if(isset($_POST['query']) && isset($_POST['query']['post__in']) && is_array($_POST['query']['post__in']) && count($_POST['query']['post__in']) > 0)
117
- return $orderBy;
118
-
119
- $orderBy = "{$wpdb->posts}.menu_order, {$wpdb->posts}.post_date DESC";
120
- }
121
- }
122
- else
123
- {
124
- //ignore search
125
- if($query->is_search())
126
- return($orderBy);
127
-
128
- if ($options['autosort'] == "1")
129
- {
130
- if(trim($orderBy) == '')
131
- $orderBy = "{$wpdb->posts}.menu_order ";
132
- else
133
- $orderBy = "{$wpdb->posts}.menu_order, " . $orderBy;
134
- }
135
- }
136
-
137
- return($orderBy);
138
- }
139
-
140
- $is_configured = get_option('CPT_configured');
141
- if ($is_configured == '')
142
- add_action( 'admin_notices', 'CPTO_admin_notices');
143
-
144
- function CPTO_admin_notices()
145
- {
146
- if (isset($_POST['form_submit']))
147
- return;
148
- ?>
149
- <div class="error fade">
150
- <p><strong><?php _e('Post Types Order must be configured. Please go to', 'post-types-order') ?> <a href="<?php echo get_admin_url() ?>options-general.php?page=cpto-options"><?php _e('Settings Page', 'post-types-order') ?></a> <?php _e('make the configuration and save', 'post-types-order') ?></strong></p>
151
- </div>
152
- <?php
153
- }
154
-
155
-
156
- add_action( 'plugins_loaded', 'cpto_load_textdomain');
157
- function cpto_load_textdomain()
158
- {
159
- load_plugin_textdomain('post-types-order', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
160
- }
161
-
162
- add_action('admin_menu', 'cpto_plugin_menu');
163
- function cpto_plugin_menu()
164
- {
165
- include (CPTPATH . '/include/options.php');
166
- add_options_page('Post Types Order', '<img class="menu_pto" src="'. CPTURL .'/images/menu-icon.png" alt="" />Post Types Order', 'manage_options', 'cpto-options', 'cpt_plugin_options');
167
- }
168
-
169
-
170
- add_action('wp_loaded', 'initCPTO' );
171
- function initCPTO()
172
- {
173
- global $custom_post_type_order, $userdata;
174
-
175
- $options = cpt_get_options();
176
-
177
- if (is_admin())
178
- {
179
- if(isset($options['capability']) && !empty($options['capability']))
180
- {
181
- if(current_user_can($options['capability']))
182
- $custom_post_type_order = new CPTO();
183
- }
184
- else if (is_numeric($options['level']))
185
- {
186
- if (userdata_get_user_level(true) >= $options['level'])
187
- $custom_post_type_order = new CPTO();
188
- }
189
- else
190
- {
191
- $custom_post_type_order = new CPTO();
192
- }
193
- }
194
- }
195
-
196
-
197
- add_filter('init', 'cpto_setup_theme');
198
- function cpto_setup_theme()
199
- {
200
- if(is_admin())
201
- return;
202
-
203
- //check the navigation_sort_apply option
204
- $options = cpt_get_options();
205
-
206
- $navigation_sort_apply = ($options['navigation_sort_apply'] == "1") ? TRUE : FALSE;
207
- $navigation_sort_apply = apply_filters('cpto/navigation_sort_apply', $navigation_sort_apply);
208
-
209
- if( ! $navigation_sort_apply)
210
- return;
211
-
212
- add_filter('get_previous_post_where', 'cpto_get_previous_post_where', 99, 3);
213
- add_filter('get_previous_post_sort', 'cpto_get_previous_post_sort');
214
- add_filter('get_next_post_where', 'cpto_get_next_post_where', 99, 3);
215
- add_filter('get_next_post_sort', 'cpto_get_next_post_sort');
216
- }
217
-
218
- function cpto_get_previous_post_where($where, $in_same_term, $excluded_terms)
219
- {
220
- global $post, $wpdb;
221
-
222
- if ( empty( $post ) )
223
- return $where;
224
-
225
- //?? WordPress does not pass through this varialbe, so we presume it's category..
226
- $taxonomy = 'category';
227
- if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
228
- $taxonomy = $match[1];
229
-
230
- $_join = '';
231
- $_where = '';
232
-
233
- if ( $in_same_term || ! empty( $excluded_terms ) )
234
- {
235
- $_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";
236
- $_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
237
-
238
- if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
239
- {
240
- // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
241
- if ( false !== strpos( $excluded_terms, ' and ' ) )
242
- {
243
- _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
244
- $excluded_terms = explode( ' and ', $excluded_terms );
245
- }
246
- else
247
- {
248
- $excluded_terms = explode( ',', $excluded_terms );
249
- }
250
-
251
- $excluded_terms = array_map( 'intval', $excluded_terms );
252
- }
253
-
254
- if ( $in_same_term )
255
- {
256
- $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
257
-
258
- // Remove any exclusions from the term array to include.
259
- $term_array = array_diff( $term_array, (array) $excluded_terms );
260
- $term_array = array_map( 'intval', $term_array );
261
-
262
- $_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
263
- }
264
-
265
- if ( ! empty( $excluded_terms ) ) {
266
- $_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )';
267
- }
268
- }
269
-
270
- $current_menu_order = $post->menu_order;
271
-
272
- $query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
273
- $_join
274
- WHERE p.post_date < %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where" , $post->post_date, $current_menu_order, $post->post_type);
275
- $results = $wpdb->get_results($query);
276
-
277
- if (count($results) > 0)
278
- {
279
- $where .= $wpdb->prepare( " AND p.menu_order = %d", $current_menu_order );
280
- }
281
- else
282
- {
283
- $where = str_replace("p.post_date < '". $post->post_date ."'", "p.menu_order > '$current_menu_order'", $where);
284
- }
285
-
286
- return $where;
287
- }
288
-
289
- function cpto_get_previous_post_sort($sort)
290
- {
291
- global $post, $wpdb;
292
-
293
- $sort = 'ORDER BY p.menu_order ASC, p.post_date DESC LIMIT 1';
294
-
295
- return $sort;
296
- }
297
-
298
- function cpto_get_next_post_where($where, $in_same_term, $excluded_terms)
299
- {
300
- global $post, $wpdb;
301
-
302
- if ( empty( $post ) )
303
- return $where;
304
-
305
- $taxonomy = 'category';
306
- if(preg_match('/ tt.taxonomy = \'([^\']+)\'/i',$where, $match))
307
- $taxonomy = $match[1];
308
-
309
- $_join = '';
310
- $_where = '';
311
-
312
- if ( $in_same_term || ! empty( $excluded_terms ) )
313
- {
314
- $_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";
315
- $_where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );
316
-
317
- if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) )
318
- {
319
- // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
320
- if ( false !== strpos( $excluded_terms, ' and ' ) )
321
- {
322
- _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
323
- $excluded_terms = explode( ' and ', $excluded_terms );
324
- }
325
- else
326
- {
327
- $excluded_terms = explode( ',', $excluded_terms );
328
- }
329
-
330
- $excluded_terms = array_map( 'intval', $excluded_terms );
331
- }
332
-
333
- if ( $in_same_term )
334
- {
335
- $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
336
-
337
- // Remove any exclusions from the term array to include.
338
- $term_array = array_diff( $term_array, (array) $excluded_terms );
339
- $term_array = array_map( 'intval', $term_array );
340
-
341
- $_where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")";
342
- }
343
-
344
- if ( ! empty( $excluded_terms ) ) {
345
- $_where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )';
346
- }
347
- }
348
-
349
- $current_menu_order = $post->menu_order;
350
-
351
- //check if there are more posts with lower menu_order
352
- $query = $wpdb->prepare( "SELECT p.* FROM $wpdb->posts AS p
353
- $_join
354
- WHERE p.post_date > %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where", $post->post_date, $current_menu_order, $post->post_type );
355
- $results = $wpdb->get_results($query);
356
-
357
- if (count($results) > 0)
358
- {
359
- $where .= $wpdb->prepare(" AND p.menu_order = %d", $current_menu_order );
360
- }
361
- else
362
- {
363
- $where = str_replace("p.post_date > '". $post->post_date ."'", "p.menu_order < '$current_menu_order'", $where);
364
- }
365
-
366
- return $where;
367
- }
368
-
369
- function cpto_get_next_post_sort($sort)
370
- {
371
- global $post, $wpdb;
372
-
373
- $sort = 'ORDER BY p.menu_order DESC, p.post_date ASC LIMIT 1';
374
-
375
- return $sort;
376
- }
377
-
378
-
379
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: Post Types Order
4
+ Plugin URI: http://www.nsp-code.com
5
+ Description: Posts Order and Post Types Objects Order using a Drag and Drop Sortable javascript capability
6
+ Author: Nsp Code
7
+ Author URI: http://www.nsp-code.com
8
+ Version: 1.9.3
9
+ Text Domain: post-types-order
10
+ Domain Path: /languages/
11
+ */
12
+
13
+ define('CPTPATH', plugin_dir_path(__FILE__));
14
+ define('CPTURL', plugins_url('', __FILE__));
15
+
16
+
17
+ register_deactivation_hook(__FILE__, 'CPTO_deactivated');
18
+ register_activation_hook(__FILE__, 'CPTO_activated');
19
+
20
+ function CPTO_activated()
21
+ {
22
+
23
+ }
24
+
25
+ function CPTO_deactivated()
26
+ {
27
+
28
+ }
29
+
30
+ include_once(CPTPATH . '/include/class.cpto.php');
31
+ include_once(CPTPATH . '/include/class.functions.php');
32
+
33
+
34
+
35
+ add_action( 'plugins_loaded', 'cpto_class_load');
36
+ function cpto_class_load()
37
+ {
38
+
39
+ global $CPTO;
40
+ $CPTO = new CPTO();
41
+ }
42
+
43
+
44
+ add_action( 'plugins_loaded', 'cpto_load_textdomain');
45
+ function cpto_load_textdomain()
46
+ {
47
+ load_plugin_textdomain('post-types-order', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
48
+ }
49
+
50
+
51
+ add_action('wp_loaded', 'initCPTO' );
52
+ function initCPTO()
53
+ {
54
+ global $CPTO;
55
+
56
+ $options = $CPTO->functions->get_options();
57
+
58
+ if (is_admin())
59
+ {
60
+ if(isset($options['capability']) && !empty($options['capability']))
61
+ {
62
+ if( current_user_can($options['capability']) )
63
+ $CPTO->init();
64
+ }
65
+ else if (is_numeric($options['level']))
66
+ {
67
+ if ( $CPTO->functions->userdata_get_user_level(true) >= $options['level'] )
68
+ $CPTO->init();
69
+ }
70
+ else
71
+ {
72
+ $CPTO->init();
73
+ }
74
+ }
75
+ }
76
+
77
+
78
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  ?>
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 order, posts order, sort, post sort, posts sort, post type order, custom order, admin posts order
5
  Requires at least: 2.8
6
- Tested up to: 4.6.1
7
- Stable tag: 1.9
8
  .
9
  License: GPLv2 or later
10
 
@@ -12,7 +12,7 @@ Post Order and custom Post Type Objects (custom post types) using a Drag and Dro
12
 
13
  == Description ==
14
 
15
- <strong>Over 1.900.000 DOWNLOADS and near PERFECT rating out of 150 REVIEWS</strong>. <br />
16
  A powerful plugin, Order Posts and Post Types Objects using a Drag and Drop Sortable JavaScript capability.
17
 
18
  The order can be customized within **default WordPress post type archive list page** or **a separate Re-Order interface** which display all objects.
@@ -36,7 +36,7 @@ If for some reason the post order does not update on your front side, you either
36
 
37
  <br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.nsp-code.com">Contact</a> and we'll check it out.
38
 
39
- <br />Check out the advanced version of this plugin at <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/">Advanced Post Types Order</a>
40
 
41
  <br />
42
  <br />This plugin is developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
@@ -95,6 +95,12 @@ Consider upgrading to our advanced version of this plugin at a very resonable pr
95
 
96
  == Change Log ==
97
 
 
 
 
 
 
 
98
  = 1.9 =
99
  - Remove translations from the package
100
  - Remove link for donate
1
  === Post Types Order ===
2
+ Contributors: nsp-code, tdgu
3
  Donate link: http://www.nsp-code.com/donate.php
4
  Tags: post order, posts order, sort, post sort, posts sort, post type order, custom order, admin posts order
5
  Requires at least: 2.8
6
+ Tested up to: 4.7.2
7
+ Stable tag: 1.9.3
8
  .
9
  License: GPLv2 or later
10
 
12
 
13
  == Description ==
14
 
15
+ <strong>Over 2 MILLIONS DOWNLOADS and near PERFECT rating out of 150 REVIEWS</strong>. <br />
16
  A powerful plugin, Order Posts and Post Types Objects using a Drag and Drop Sortable JavaScript capability.
17
 
18
  The order can be customized within **default WordPress post type archive list page** or **a separate Re-Order interface** which display all objects.
36
 
37
  <br />Something is wrong with this plugin on your site? Just use the forum or get in touch with us at <a target="_blank" href="http://www.nsp-code.com">Contact</a> and we'll check it out.
38
 
39
+ <br />Need More? Check out the advanced version of this plugin at <a target="_blank" href="http://www.nsp-code.com/premium-plugins/wordpress-plugins/advanced-post-types-order/">Advanced Post Types Order</a> which include Hierarchically post types order, Manual / Automatic Sorting, Individual Categories Order, Conditionals to apply, Paginations for large list, Mobile ready, Enhanced Interface, Plugins compatibility (MultiSite Network Support, WPML, Polylang, WooCommerce, WP E-Commerce, Platform Pro, Genesis etc), font side re-order interface, ... and many more !!
40
 
41
  <br />
42
  <br />This plugin is developed by <a target="_blank" href="http://www.nsp-code.com">Nsp-Code</a>
95
 
96
  == Change Log ==
97
 
98
+ = 1.9.3 =
99
+ - Fix for custom post type objects per page when using default archive interface drag & drop sort
100
+ - Plugin code redo and re-structure
101
+ - Improved compatibility with other plugins
102
+ - Security improvments for AJAX order updates
103
+
104
  = 1.9 =
105
  - Remove translations from the package
106
  - Remove link for donate