Reorder Posts - Version 2.1.1

Version Description

  • Released 2015-01-21
  • Fixed pagination issue
  • Improved Reorder save query performance significantly
Download this release

Release Info

Developer ronalfy
Plugin Icon 128x128 Reorder Posts
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0 to 2.1.1

Files changed (3) hide show
  1. class-reorder.php +14 -4
  2. index.php +1 -1
  3. readme.txt +9 -1
class-reorder.php CHANGED
@@ -200,7 +200,7 @@ final class MN_Reorder {
200
  public function adjust_offset_pagination( $found_posts, $query ) {
201
  //This sometimes will have a bug of showing an extra page, but it doesn't break anything, so leaving it for now.
202
  if( $found_posts > $this->posts_per_page ) {
203
- $num_pages = round($found_posts / $this->offset);
204
  $found_posts = (string)round( $num_pages * $this->posts_per_page );
205
  }
206
  return $found_posts;
@@ -246,7 +246,10 @@ final class MN_Reorder {
246
 
247
  //Update post if passed - Should run only on beginning of first iteration
248
  if( $post_id > 0 && !isset( $_POST[ 'more_posts' ] ) ) {
249
- wp_update_post( array( 'ID' => $post_id, 'post_parent' => $post_parent, 'menu_order' => $post_menu_order ) );
 
 
 
250
  $posts_to_exclude[] = $post_id;
251
  }
252
 
@@ -260,9 +263,12 @@ final class MN_Reorder {
260
  'ignore_sticky_posts' => true,
261
  'post_status' => $this->post_status,
262
  'post_parent' => $post_parent,
263
- 'post__not_in' => $posts_to_exclude
 
 
264
  );
265
  $posts = new WP_Query( $query_args );
 
266
  $start = $menu_order_start;
267
  if ( $posts->have_posts() ) {
268
  foreach( $posts->posts as $post ) {
@@ -273,7 +279,11 @@ final class MN_Reorder {
273
 
274
  if ( $post_id != $post->ID ) {
275
  //Update post and counts
276
- wp_update_post( array( 'ID' => $post->ID, 'menu_order' => $start, 'post_parent' => $post_parent ) );
 
 
 
 
277
  }
278
  $posts_to_exclude[] = $post->ID;
279
  $start++;
200
  public function adjust_offset_pagination( $found_posts, $query ) {
201
  //This sometimes will have a bug of showing an extra page, but it doesn't break anything, so leaving it for now.
202
  if( $found_posts > $this->posts_per_page ) {
203
+ $num_pages = $found_posts / $this->offset;
204
  $found_posts = (string)round( $num_pages * $this->posts_per_page );
205
  }
206
  return $found_posts;
246
 
247
  //Update post if passed - Should run only on beginning of first iteration
248
  if( $post_id > 0 && !isset( $_POST[ 'more_posts' ] ) ) {
249
+ $wpdb->update(
250
+ $wpdb->posts,
251
+ array( 'menu_order' => $post_menu_order, 'post_parent' => $post_parent ), array( 'ID' => $post_id )
252
+ );
253
  $posts_to_exclude[] = $post_id;
254
  }
255
 
263
  'ignore_sticky_posts' => true,
264
  'post_status' => $this->post_status,
265
  'post_parent' => $post_parent,
266
+ 'post__not_in' => $posts_to_exclude,
267
+ 'update_post_term_cache' => false,
268
+ 'update_post_meta_cache' => false
269
  );
270
  $posts = new WP_Query( $query_args );
271
+
272
  $start = $menu_order_start;
273
  if ( $posts->have_posts() ) {
274
  foreach( $posts->posts as $post ) {
279
 
280
  if ( $post_id != $post->ID ) {
281
  //Update post and counts
282
+ $wpdb->update(
283
+ $wpdb->posts,
284
+ array( 'menu_order' => $start, 'post_parent' => $post_parent ),
285
+ array( 'ID' => $post->ID )
286
+ );
287
  }
288
  $posts_to_exclude[] = $post->ID;
289
  $start++;
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Metronet Reorder Posts
4
  Plugin URI: https://wordpress.org/plugins/metronet-reorder-posts/
5
  Description: Easily reorder posts and pages in WordPress
6
- Version: 2.1.0
7
  Author: Ryan Hellyer, Ronald Huereca, Scott Basgaard
8
  Author URI: https://github.com/ronalfy/reorder-posts
9
  Text Domain: metronet-reorder-posts
3
  Plugin Name: Metronet Reorder Posts
4
  Plugin URI: https://wordpress.org/plugins/metronet-reorder-posts/
5
  Description: Easily reorder posts and pages in WordPress
6
+ Version: 2.1.1
7
  Author: Ryan Hellyer, Ronald Huereca, Scott Basgaard
8
  Author URI: https://github.com/ronalfy/reorder-posts
9
  Text Domain: metronet-reorder-posts
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URL: https://wordpress.org/plugins/metronet-reorder-posts/
5
  Requires at Least: 3.7
6
  Tested up to: 4.1
7
  Tags: reorder, re-order, posts, wordpress, post-type, ajax, admin, hierarchical, menu_order, ordering
8
- Stable tag: 2.1.0
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -116,6 +116,11 @@ This plugin requires WordPress 3.7 or above. We urge you, however, to always us
116
 
117
  == Changelog ==
118
 
 
 
 
 
 
119
  = 2.1.0 =
120
  * Released 2015-01-19
121
  * Added add-on support
@@ -179,6 +184,9 @@ This plugin requires WordPress 3.7 or above. We urge you, however, to always us
179
 
180
  == Upgrade Notice ==
181
 
 
 
 
182
  = 2.1.0 =
183
  Some capability fixes, pagination for post types with a lot of posts, improved query performance, and add-on capability.
184
 
5
  Requires at Least: 3.7
6
  Tested up to: 4.1
7
  Tags: reorder, re-order, posts, wordpress, post-type, ajax, admin, hierarchical, menu_order, ordering
8
+ Stable tag: 2.1.1
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
116
 
117
  == Changelog ==
118
 
119
+ = 2.1.1 =
120
+ * Released 2015-01-21
121
+ * Fixed pagination issue
122
+ * Improved Reorder save query performance significantly
123
+
124
  = 2.1.0 =
125
  * Released 2015-01-19
126
  * Added add-on support
184
 
185
  == Upgrade Notice ==
186
 
187
+ = 2.1.1 =
188
+ Fixed pagination issue. Improved Reorder save query performance significantly
189
+
190
  = 2.1.0 =
191
  Some capability fixes, pagination for post types with a lot of posts, improved query performance, and add-on capability.
192