Simple Page Ordering - Version 0.9

Version Description

  • Fix page count display always showing "0" on non-hierarchical post types (Showing 1-X of X)
  • Fix hidden menu order not updating after sort (causing Quick Edit to reset order when used right after sorting)
  • "Move" cursor only set if JavaScript enabled
  • Added further directions in the plug-in description (some users were confused about how to use it)
  • Basic compatibility with 3.1 RC (prevent clashes with post list sorting)
Download this release

Release Info

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

Code changes from version 0.8.4 to 0.9

Files changed (3) hide show
  1. readme.txt +11 -4
  2. simple-page-ordering.php +23 -18
  3. spo-ordering.js +14 -3
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Simple Page Ordering ===
2
- Contributors: Jacob M Goldman (C. Murray Consulting)
3
- Donate link: http://www.cmurrayconsulting.com/software/wordpress-page-order-plugin/
4
  Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin
5
  Requires at least: 3.0.1
6
- Tested up to: 3.0.1
7
- Stable tag: 0.8.4
8
 
9
  Order your pages and other hierarchical post types with simple drag and drop. Also adds a drop down to change items per page.
10
 
@@ -48,6 +48,13 @@ folder to the `/wp-content/plugins/` directory
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
 
 
51
  = 0.8.4 =
52
  * Loosened constraints on drag and drop to ease dropping into top and bottom position
53
  * Fixed row background staying "white" after dropping into a new position
1
  === Simple Page Ordering ===
2
+ Contributors: Jake Goldman (C. Murray Consulting)
3
+ Donate link: http://www.thinkoomph.com/plugins-modules/wordpress-page-order-plugin/
4
  Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin
5
  Requires at least: 3.0.1
6
+ Tested up to: 3.1
7
+ Stable tag: 0.9
8
 
9
  Order your pages and other hierarchical post types with simple drag and drop. Also adds a drop down to change items per page.
10
 
48
 
49
  == Changelog ==
50
 
51
+ = 0.9 =
52
+ * Fix page count display always showing "0" on non-hierarchical post types (Showing 1-X of X)
53
+ * Fix hidden menu order not updating after sort (causing Quick Edit to reset order when used right after sorting)
54
+ * "Move" cursor only set if JavaScript enabled
55
+ * Added further directions in the plug-in description (some users were confused about how to use it)
56
+ * Basic compatibility with 3.1 RC (prevent clashes with post list sorting)
57
+
58
  = 0.8.4 =
59
  * Loosened constraints on drag and drop to ease dropping into top and bottom position
60
  * Fixed row background staying "white" after dropping into a new position
simple-page-ordering.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  Plugin Name: Simple Page Ordering
4
- Plugin URI: http://www.cmurrayconsulting.com/software/wordpress-page-order-plugin/
5
- Description: Order your pages and other hierarchical post types with drag and drop. Also adds a filter for items to show per page.
6
- Version: 0.8.4
7
- Author: Jacob M Goldman (C. Murray Consulting)
8
- Author URI: http://www.cmurrayconsulting.com
9
 
10
  Plugin: Copyright 2009 C. Murray Consulting (email : jake@cmurrayconsulting.com)
11
 
@@ -33,15 +33,15 @@ add_filter( 'edit_posts_per_page', 'spo_edit_posts_per_page', 10, 2 );
33
  function spo_edit_posts_per_page( $per_page, $post_type )
34
  {
35
  if ( !current_user_can('edit_others_pages') ) // check permission
36
- return;
37
 
38
  $post_type_object = get_post_type_object( $post_type );
39
  if ( !$post_type_object->hierarchical ) // only hierarchical post types apply
40
- return;
41
 
42
  add_action( 'restrict_manage_posts', 'spo_posts_per_page_filter' ); // posts per page drop down UI
43
- add_action( 'admin_print_styles', 'spo_admin_styles' ); // special styles (move cursor), spinner positioning
44
- wp_enqueue_script( 'spo-ordering', plugin_dir_url( __FILE__ ) . '/spo-ordering.js', array('jquery-ui-sortable'), '0.8.4', true );
45
  add_filter( 'contextual_help', 'spo_contextual_help' );
46
 
47
  if ( isset( $_GET['spo'] ) && is_numeric( $_GET['spo'] ) && ( $_GET['spo'] == -1 || ($_GET['spo']%10) == 0 ) ) :
@@ -66,10 +66,10 @@ function spo_posts_per_page_filter()
66
 
67
  $spo = isset($_GET['spo']) ? (int)$_GET['spo'] : $per_page;
68
  ?>
69
- <select name="spo" style="width: 100px;">
70
  <option<?php selected( $spo, -1 ); ?> value="-1"><?php _e('Show all'); ?></option>
71
  <?php for( $i=10;$i<=100;$i+=10 ) : ?>
72
- <option<?php selected( $spo, $i ); ?> value="<?php echo $i ?>"><?php echo $i; ?> <?php _e('per page'); ?></option>
73
  <?php endfor; ?>
74
  </select>
75
  <?php
@@ -78,17 +78,17 @@ function spo_posts_per_page_filter()
78
  /**
79
  * styling and help
80
  */
81
-
82
  function spo_admin_styles() {
83
- echo '<style type="text/css">table.widefat tbody th, table.widefat tbody td { cursor: move; }</style>';
84
  }
85
 
86
  function spo_contextual_help( $help )
87
  {
88
  return $help . '
89
- <p><strong>Simple Page Ordering</strong></p>
90
 
91
- <p><a href="http://www.cmurrayconsulting.com/software/wordpress-page-order-plugin/" target="_blank">Simple Page Ordering</a> is a plug-in by <a href="http://www.jakegoldman.net" target="_blank">Jake Goldman</a> (<a href="http://www.cmurrayconsulting.com/software/wordpress-page-order-plugin/" target="_blank">C. Murray Consulting</a>) that allows you to order pages and other hierarchical post types with drag and drop.</p>
92
 
93
  <p>To reposition an item, simply drag and drop the row by "clicking and holding" it anywhere (outside of the links and form controls) and moving it to its new position.</p>
94
 
@@ -116,6 +116,7 @@ function spo_do_page_ordering()
116
 
117
  $previd = isset($_POST['previd']) ? $_POST['previd'] : false;
118
  $nextid = isset($_POST['nextid']) ? $_POST['nextid'] : false;
 
119
 
120
  if ( $previd ) {
121
 
@@ -127,6 +128,7 @@ function spo_do_page_ordering()
127
  if ( $sibling->ID == $previd ) {
128
  $menu_order = $sibling->menu_order + 1;
129
  wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
 
130
  continue;
131
  }
132
 
@@ -138,10 +140,11 @@ function spo_do_page_ordering()
138
  if ( isset($menu_order) ) {
139
  $menu_order++;
140
  wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
141
- }
 
142
 
143
  endforeach;
144
-
145
  }
146
 
147
  if ( !isset($menu_order) && $nextid ) {
@@ -154,6 +157,7 @@ function spo_do_page_ordering()
154
  if ( $sibling->ID == $nextid ) {
155
  $menu_order = $sibling->menu_order - 1;
156
  wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
 
157
  continue;
158
  }
159
 
@@ -165,6 +169,7 @@ function spo_do_page_ordering()
165
  if ( isset($menu_order) ) {
166
  $menu_order--;
167
  wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
 
168
  }
169
 
170
  endforeach;
@@ -176,5 +181,5 @@ function spo_do_page_ordering()
176
  if ( !empty($children) )
177
  die('children');
178
 
179
- die();
180
  }
1
  <?php
2
  /**
3
  Plugin Name: Simple Page Ordering
4
+ Plugin URI: http://www.thinkoomph.com/plugins-modules/wordpress-page-order-plugin/
5
+ Description: Order your pages and hierarchical post types using drag and drop on the built in page list. Also adds a filter for items to show per page. For further instructions, open the "Help" tab on the Pages screen.
6
+ Version: 0.9
7
+ Author: Jake Goldman (Oomph, Inc)
8
+ Author URI: http://www.thinkoomph.com
9
 
10
  Plugin: Copyright 2009 C. Murray Consulting (email : jake@cmurrayconsulting.com)
11
 
33
  function spo_edit_posts_per_page( $per_page, $post_type )
34
  {
35
  if ( !current_user_can('edit_others_pages') ) // check permission
36
+ return $per_page;
37
 
38
  $post_type_object = get_post_type_object( $post_type );
39
  if ( !$post_type_object->hierarchical ) // only hierarchical post types apply
40
+ return $per_page;
41
 
42
  add_action( 'restrict_manage_posts', 'spo_posts_per_page_filter' ); // posts per page drop down UI
43
+ add_action( 'admin_print_styles', 'spo_admin_styles' ); // special styles (move cursor)
44
+ wp_enqueue_script( 'spo-ordering', plugin_dir_url( __FILE__ ) . '/spo-ordering.js', array('jquery-ui-sortable'), '0.9', true );
45
  add_filter( 'contextual_help', 'spo_contextual_help' );
46
 
47
  if ( isset( $_GET['spo'] ) && is_numeric( $_GET['spo'] ) && ( $_GET['spo'] == -1 || ($_GET['spo']%10) == 0 ) ) :
66
 
67
  $spo = isset($_GET['spo']) ? (int)$_GET['spo'] : $per_page;
68
  ?>
69
+ <select name="spo" style="width: 110px;">
70
  <option<?php selected( $spo, -1 ); ?> value="-1"><?php _e('Show all'); ?></option>
71
  <?php for( $i=10;$i<=100;$i+=10 ) : ?>
72
+ <option<?php selected( $spo, $i ); ?> value="<?php echo $i; ?>"><?php echo $i; ?> <?php _e('per page'); ?></option>
73
  <?php endfor; ?>
74
  </select>
75
  <?php
78
  /**
79
  * styling and help
80
  */
81
+
82
  function spo_admin_styles() {
83
+ echo '<style type="text/css">.js table.widefat tbody th, .js table.widefat tbody td { cursor: move; }</style>';
84
  }
85
 
86
  function spo_contextual_help( $help )
87
  {
88
  return $help . '
89
+ <p><strong>'. __( 'Simple Page Ordering' ) . '</strong></p>
90
 
91
+ <p><a href="http://www.thinkoomph.com/plugins-modules/wordpress-page-order-plugin/" target="_blank">Simple Page Ordering</a> is a plug-in by <a href="http://www.jakegoldman.net" target="_blank">Jake Goldman</a> (<a href="http://www.thinkoomph.com" target="_blank">Oomph, Inc</a>) that allows you to order pages and other hierarchical post types with drag and drop.</p>
92
 
93
  <p>To reposition an item, simply drag and drop the row by "clicking and holding" it anywhere (outside of the links and form controls) and moving it to its new position.</p>
94
 
116
 
117
  $previd = isset($_POST['previd']) ? $_POST['previd'] : false;
118
  $nextid = isset($_POST['nextid']) ? $_POST['nextid'] : false;
119
+ $new_pos = array(); // store new positions for ajax
120
 
121
  if ( $previd ) {
122
 
128
  if ( $sibling->ID == $previd ) {
129
  $menu_order = $sibling->menu_order + 1;
130
  wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
131
+ $new_pos[$post->ID] = $menu_order;
132
  continue;
133
  }
134
 
140
  if ( isset($menu_order) ) {
141
  $menu_order++;
142
  wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
143
+ $new_pos[$sibling->ID] = $menu_order;
144
+ }
145
 
146
  endforeach;
147
+
148
  }
149
 
150
  if ( !isset($menu_order) && $nextid ) {
157
  if ( $sibling->ID == $nextid ) {
158
  $menu_order = $sibling->menu_order - 1;
159
  wp_update_post(array( 'ID' => $post->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
160
+ $new_pos[$post->ID] = $menu_order;
161
  continue;
162
  }
163
 
169
  if ( isset($menu_order) ) {
170
  $menu_order--;
171
  wp_update_post(array( 'ID' => $sibling->ID, 'menu_order' => $menu_order )); // update the actual moved post to 1 after prev
172
+ $new_pos[$sibling->ID] = $menu_order;
173
  }
174
 
175
  endforeach;
181
  if ( !empty($children) )
182
  die('children');
183
 
184
+ die( json_encode($new_pos) );
185
  }
spo-ordering.js CHANGED
@@ -1,3 +1,5 @@
 
 
1
  jQuery("table.widefat tbody").sortable({
2
  cursor: 'move',
3
  axis: 'y',
@@ -9,12 +11,12 @@ jQuery("table.widefat tbody").sortable({
9
  },
10
  start: function(event, ui) {
11
  if ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );
12
- ui.item.children('td, th').css('border','none');
13
  ui.item.css( 'outline', '1px solid #dfdfdf' );
14
  },
15
  stop: function(event, ui) {
16
  ui.item.removeAttr('style');
17
- ui.item.children('td, th').removeAttr('style');
18
  },
19
  update: function(event, ui) {
20
  if ( ui.item.hasClass('inline-editor') ) {
@@ -22,6 +24,11 @@ jQuery("table.widefat tbody").sortable({
22
  alert( 'Please close the quick editor before reordering this item.' );
23
  return;
24
  }
 
 
 
 
 
25
 
26
  var postid = ui.item.find('.check-column input').val(); // this post id
27
  var postparent = ui.item.find('.post_parent').html(); // post parent
@@ -56,7 +63,11 @@ jQuery("table.widefat tbody").sortable({
56
  // go do the sorting stuff via ajax
57
  jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){
58
  if ( response == 'children' ) window.location.reload();
59
- else ui.item.find('.check-column input').show().siblings('img').remove();
 
 
 
 
60
  });
61
 
62
  // fix cell colors
1
+ jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','move');
2
+
3
  jQuery("table.widefat tbody").sortable({
4
  cursor: 'move',
5
  axis: 'y',
11
  },
12
  start: function(event, ui) {
13
  if ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );
14
+ ui.item.children('td,th').css('border','none');
15
  ui.item.css( 'outline', '1px solid #dfdfdf' );
16
  },
17
  stop: function(event, ui) {
18
  ui.item.removeAttr('style');
19
+ ui.item.children('td,th').removeAttr('style');
20
  },
21
  update: function(event, ui) {
22
  if ( ui.item.hasClass('inline-editor') ) {
24
  alert( 'Please close the quick editor before reordering this item.' );
25
  return;
26
  }
27
+ if ( jQuery('table.widefat th.sorted').length > 0 ) {
28
+ jQuery("table.widefat tbody").sortable('cancel');
29
+ alert( 'Please return the list to the default, menu order sorting before ordering items.' );
30
+ return;
31
+ }
32
 
33
  var postid = ui.item.find('.check-column input').val(); // this post id
34
  var postparent = ui.item.find('.post_parent').html(); // post parent
63
  // go do the sorting stuff via ajax
64
  jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){
65
  if ( response == 'children' ) window.location.reload();
66
+ else {
67
+ var changes = jQuery.parseJSON(response);
68
+ jQuery.each(changes, function(key,value) { jQuery('#inline_'+key+' .menu_order').html(value); });
69
+ ui.item.find('.check-column input').show().siblings('img').remove();
70
+ }
71
  });
72
 
73
  // fix cell colors