Nested Pages - Version 3.2.1

Version Description

  • Reverts previous wp_update_post change to prevent server errors on large sites. Replaces with optional "nestedpages_use_update_post" filter to enable hook when needed.
Download this release

Release Info

Developer kylephillips
Plugin Icon 128x128 Nested Pages
Version 3.2.1
Comparing to
See all releases

Code changes from version 3.2.0 to 3.2.1

app/Entities/Post/PostUpdateRepository.php CHANGED
@@ -56,6 +56,7 @@ class PostUpdateRepository
56
  {
57
  $this->validation->validatePostIDs($posts);
58
  $post_type = get_post_type($posts[0]['id']);
 
59
  if ( !$this->user_repo->canSortPosts($post_type) ) return;
60
  global $wpdb;
61
  foreach( $posts as $key => $post )
@@ -63,26 +64,37 @@ class PostUpdateRepository
63
  $post_id = sanitize_text_field($post['id']);
64
  $original_modifed_date = get_post_modified_time('Y-m-d H:i:s', false, $post_id);
65
  $original_modifed_date_gmt = get_post_modified_time('Y-m-d H:i:s', true, $post_id);
66
- $args = [
67
- 'ID' => $post_id,
68
- 'menu_order' => intval($key),
69
- 'post_modified' => $original_modifed_date,
70
- 'post_modified_gmt' => $original_modifed_date_gmt
71
- ];
72
  if ( !$filtered ) $args['post_parent'] = intval($parent);
73
- wp_update_post($args);
74
-
75
- // Reset the modified date to the last modified date
76
- // We can't use the above update_post, because wp_insert_post defaults to the current time
77
- $query = $wpdb->prepare(
78
- "UPDATE $wpdb->posts
79
- SET post_modified = '%s', post_modified_gmt = '%s'
80
- WHERE ID = '%d'",
81
- $original_modifed_date,
82
- $original_modifed_date_gmt,
83
- intval($post_id)
84
- );
85
- $wpdb->query($query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  do_action('nestedpages_post_order_updated', $post_id, $parent, $key, $filtered);
88
  if ( isset($post['children']) ) $this->updateOrder($post['children'], $post_id);
56
  {
57
  $this->validation->validatePostIDs($posts);
58
  $post_type = get_post_type($posts[0]['id']);
59
+ $update_post_hook = apply_filters('nestedpages_use_update_post', false);
60
  if ( !$this->user_repo->canSortPosts($post_type) ) return;
61
  global $wpdb;
62
  foreach( $posts as $key => $post )
64
  $post_id = sanitize_text_field($post['id']);
65
  $original_modifed_date = get_post_modified_time('Y-m-d H:i:s', false, $post_id);
66
  $original_modifed_date_gmt = get_post_modified_time('Y-m-d H:i:s', true, $post_id);
67
+
 
 
 
 
 
68
  if ( !$filtered ) $args['post_parent'] = intval($parent);
69
+
70
+ // Update post hook causes server timeout on large sites, but may be required by some users
71
+ if ( $update_post_hook ) wp_update_post(['ID' => $post_id]);
72
+
73
+ if ( !$filtered ) :
74
+ $query = $wpdb->prepare(
75
+ "UPDATE $wpdb->posts
76
+ SET menu_order = '%d', post_parent = '%d', post_modified = '%s', post_modified_gmt = '%s'
77
+ WHERE ID = '%d'",
78
+ intval($key),
79
+ intval($parent),
80
+ $original_modifed_date,
81
+ $original_modifed_date_gmt,
82
+ intval($post_id)
83
+ );
84
+ else : // The posts are filtered, don't update the parent
85
+ $query = $wpdb->prepare(
86
+ "UPDATE $wpdb->posts
87
+ SET menu_order = '%d', post_modified = '%s', post_modified_gmt = '%s'
88
+ WHERE ID = '%d'",
89
+ intval($key),
90
+ $original_modifed_date,
91
+ $original_modifed_date_gmt,
92
+ intval($post_id)
93
+ );
94
+ endif;
95
+
96
+ $wpdb->query( $query );
97
+ do_action('nestedpages_post_order_updated', $post_id, $parent, $key, $filtered);
98
 
99
  do_action('nestedpages_post_order_updated', $post_id, $parent, $key, $filtered);
100
  if ( isset($post['children']) ) $this->updateOrder($post['children'], $post_id);
app/NestedPages.php CHANGED
@@ -12,7 +12,7 @@ class NestedPages
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
- $np_version = '3.2.0';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
18
  if ( !is_admin() ) $app = new NestedPages\FrontEndBootstrap;
12
  $np_env = 'live';
13
 
14
  global $np_version;
15
+ $np_version = '3.2.1';
16
 
17
  if ( is_admin() ) $app = new NestedPages\Bootstrap;
18
  if ( !is_admin() ) $app = new NestedPages\FrontEndBootstrap;
nestedpages.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while enhancing quick edit. Includes an auto-generated menu to match the nested interface, support for all post types and more.
6
- Version: 3.2.0
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: wp-nested-pages
3
  Plugin Name: Nested Pages
4
  Plugin URI: http://nestedpages.com
5
  Description: Provides an intuitive drag and drop interface for managing pages in the Wordpress admin, while enhancing quick edit. Includes an auto-generated menu to match the nested interface, support for all post types and more.
6
+ Version: 3.2.1
7
  Author: Kyle Phillips
8
  Author URI: https://github.com/kylephillips
9
  Text Domain: wp-nested-pages
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: kylephillips
3
  Donate link: https://github.com/sponsors/kylephillips/
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
- Tested up to: 6.0
7
  Requires PHP: 5.4
8
- Stable tag: 3.1.22
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -105,6 +105,9 @@ No. The menu synchronization currently only works within the pages post type.
105
 
106
  == Changelog ==
107
 
 
 
 
108
  = 3.2.0 =
109
  * Resolves issue where post_updated action was not firing after reordering of nested view.
110
  * Adds ability to save a custom URL for pages in the nav menu (Example: outputting an anchor link rather than the page's link). To add a custom link, select quick edit, followed by the "Menu Options" tab. There is a new "Custom URL" input.
3
  Donate link: https://github.com/sponsors/kylephillips/
4
  Tags: pages, admin, nested, tree view, page tree, sort, quick edit, structure
5
  Requires at least: 3.8
6
+ Tested up to: 6.1
7
  Requires PHP: 5.4
8
+ Stable tag: 3.2.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
105
 
106
  == Changelog ==
107
 
108
+ = 3.2.1 =
109
+ * Reverts previous wp_update_post change to prevent server errors on large sites. Replaces with optional "nestedpages_use_update_post" filter to enable hook when needed.
110
+
111
  = 3.2.0 =
112
  * Resolves issue where post_updated action was not firing after reordering of nested view.
113
  * Adds ability to save a custom URL for pages in the nav menu (Example: outputting an anchor link rather than the page's link). To add a custom link, select quick edit, followed by the "Menu Options" tab. There is a new "Custom URL" input.