Simple Page Ordering - Version 2.2.3

Version Description

  • Fixed ordering in WordPress 4.0 following core changes to ORDER BY in WP_Query
Download this release

Release Info

Developer jakemgold
Plugin Icon 128x128 Simple Page Ordering
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

Files changed (2) hide show
  1. readme.txt +6 -3
  2. simple-page-ordering.php +18 -8
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jakemgold, 10up, thinkoomph
3
Donate link: http://10up.com/plugins/simple-page-ordering-wordpress/
4
Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin
5
Requires at least: 3.8
6
- Tested up to: 3.9.2
7
- Stable tag: 2.2.2
8
9
Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
10
@@ -75,7 +75,10 @@ This feature is already built into WordPress natively, but a bit tucked away. If
75
1. Processing indicator
76
77
78
- == Changelog ==
79
80
= 2.2.2 =
81
* Column widths no longer change when dragging a row (partial props griffinjt)
3
Donate link: http://10up.com/plugins/simple-page-ordering-wordpress/
4
Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin
5
Requires at least: 3.8
6
+ Tested up to: 4.0
7
+ Stable tag: 2.2.3
8
9
Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
10
75
1. Processing indicator
76
77
78
+ == Changelog ==
79
+
80
+ = 2.2.3 =
81
+ * Fixed ordering in WordPress 4.0 following core changes to ORDER BY in WP_Query
82
83
= 2.2.2 =
84
* Column widths no longer change when dragging a row (partial props griffinjt)
simple-page-ordering.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Simple Page Ordering
4
Plugin URI: http://10up.com/plugins/simple-page-ordering-wordpress/
5
Description: Order your pages and hierarchical post types using drag and drop on the built in page list. For further instructions, open the "Help" tab on the Pages screen.
6
- Version: 2.2.2
7
Author: Jake Goldman, 10up
8
Author URI: http://10up.com
9
License: GPLv2 or later
@@ -80,7 +80,8 @@ class Simple_Page_Ordering {
80
* when we load up our posts query, if we're actually sorting by menu order, initialize sorting scripts
81
*/
82
public static function wp() {
83
- if ( 0 === strpos( get_query_var('orderby'), 'menu_order' ) ) {
84
$script_name = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'simple-page-ordering.dev.js' : 'simple-page-ordering.js';
85
wp_enqueue_script( 'simple-page-ordering', plugins_url( $script_name, __FILE__ ), array('jquery-ui-sortable'), '2.1', true );
86
wp_enqueue_style( 'simple-page-ordering', plugins_url( 'simple-page-ordering.css', __FILE__ ) );
@@ -120,6 +121,8 @@ class Simple_Page_Ordering {
120
error_reporting( 0 );
121
}
122
123
$previd = empty( $_POST['previd'] ) ? false : (int) $_POST['previd'];
124
$nextid = empty( $_POST['nextid'] ) ? false : (int) $_POST['nextid'];
125
$start = empty( $_POST['start'] ) ? 1 : (int) $_POST['start'];
@@ -156,20 +159,24 @@ class Simple_Page_Ordering {
156
'show_in_admin_all_list' => true,
157
));
158
159
- $siblings = new WP_Query(array(
160
'depth' => 1,
161
'posts_per_page' => $max_sortable_posts,
162
'post_type' => $post->post_type,
163
'post_status' => $post_stati,
164
'post_parent' => $parent_id,
165
- 'orderby' => 'menu_order title',
166
- 'order' => 'ASC',
167
'post__not_in' => $excluded,
168
'update_post_term_cache' => false,
169
'update_post_meta_cache' => false,
170
'suppress_filters' => true,
171
'ignore_sticky_posts' => true,
172
- )); // fetch all the siblings (relative ordering)
173
174
// don't waste overhead of revisions on a menu order change (especially since they can't *all* be rolled back at once)
175
remove_action( 'pre_post_update', 'wp_save_post_revision' );
@@ -274,8 +281,11 @@ class Simple_Page_Ordering {
274
*/
275
public static function sort_by_order_link( $views ) {
276
$class = ( get_query_var('orderby') == 'menu_order title' ) ? 'current' : '';
277
- $query_string = esc_url( remove_query_arg(array( 'orderby', 'order' )) );
278
- $query_string = add_query_arg( 'orderby', urlencode('menu_order title'), $query_string );
279
$views['byorder'] = sprintf('<a href="%s" class="%s">%s</a>', $query_string, $class, __("Sort by Order", 'simple-page-ordering'));
280
281
return $views;
3
Plugin Name: Simple Page Ordering
4
Plugin URI: http://10up.com/plugins/simple-page-ordering-wordpress/
5
Description: Order your pages and hierarchical post types using drag and drop on the built in page list. For further instructions, open the "Help" tab on the Pages screen.
6
+ Version: 2.2.3
7
Author: Jake Goldman, 10up
8
Author URI: http://10up.com
9
License: GPLv2 or later
80
* when we load up our posts query, if we're actually sorting by menu order, initialize sorting scripts
81
*/
82
public static function wp() {
83
+ $orderby = get_query_var('orderby');
84
+ if ( ( is_string( $orderby ) && 0 === strpos( $orderby, 'menu_order' ) ) || ( isset( $orderby['menu_order'] ) && $orderby['menu_order'] == 'ASC' ) ) {
85
$script_name = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'simple-page-ordering.dev.js' : 'simple-page-ordering.js';
86
wp_enqueue_script( 'simple-page-ordering', plugins_url( $script_name, __FILE__ ), array('jquery-ui-sortable'), '2.1', true );
87
wp_enqueue_style( 'simple-page-ordering', plugins_url( 'simple-page-ordering.css', __FILE__ ) );
121
error_reporting( 0 );
122
}
123
124
+ global $wp_version;
125
+
126
$previd = empty( $_POST['previd'] ) ? false : (int) $_POST['previd'];
127
$nextid = empty( $_POST['nextid'] ) ? false : (int) $_POST['nextid'];
128
$start = empty( $_POST['start'] ) ? 1 : (int) $_POST['start'];
159
'show_in_admin_all_list' => true,
160
));
161
162
+ $siblings_query = array(
163
'depth' => 1,
164
'posts_per_page' => $max_sortable_posts,
165
'post_type' => $post->post_type,
166
'post_status' => $post_stati,
167
'post_parent' => $parent_id,
168
+ 'orderby' => array( 'menu_order' => 'ASC', 'title' => 'ASC' ),
169
'post__not_in' => $excluded,
170
'update_post_term_cache' => false,
171
'update_post_meta_cache' => false,
172
'suppress_filters' => true,
173
'ignore_sticky_posts' => true,
174
+ );
175
+ if ( version_compare( $wp_version, '4.0', '<' ) ) {
176
+ $siblings_query['orderby'] = 'menu_order title';
177
+ $siblings_query['order'] = 'ASC';
178
+ }
179
+ $siblings = new WP_Query( $siblings_query ); // fetch all the siblings (relative ordering)
180
181
// don't waste overhead of revisions on a menu order change (especially since they can't *all* be rolled back at once)
182
remove_action( 'pre_post_update', 'wp_save_post_revision' );
281
*/
282
public static function sort_by_order_link( $views ) {
283
$class = ( get_query_var('orderby') == 'menu_order title' ) ? 'current' : '';
284
+ $query_string = esc_url( remove_query_arg( array( 'orderby', 'order' ) ) );
285
+ if ( ! is_post_type_hierarchical( get_post_type() ) ) {
286
+ $query_string = add_query_arg( 'orderby', urlencode( 'menu_order title' ), $query_string );
287
+ $query_string = add_query_arg( 'order', 'asc', $query_string );
288
+ }
289
$views['byorder'] = sprintf('<a href="%s" class="%s">%s</a>', $query_string, $class, __("Sort by Order", 'simple-page-ordering'));
290
291
return $views;