Version Description
- Drag pages into any part of the page hierarchy! No longer limited to same branch of tree!
- Big performance improvements under the hood: leaner queries, batched requests, less processing
- Scales much more reliably in situations with very high page counts due to batching of requests
- Order of the first page is now set to "1" instead of "0", so pages added after ordering are added at the top (instead of second)
- Removed "number of pages" drop down, which is repetitive of a field accessible under Screen Options
- New filters and hooks to extend / override default functionality
- Improved compatibility with newer versions of WordPress
Download this release
Release Info
Developer | jakemgold |
Plugin | Simple Page Ordering |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 2.0
- localization/simple-page-ordering-es_ES.mo +0 -0
- localization/simple-page-ordering-es_ES.po +32 -40
- localization/simple-page-ordering-nl_NL.mo +0 -0
- localization/simple-page-ordering-nl_NL.po +57 -0
- readme.txt +63 -23
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- simple-page-ordering.dev.js +96 -0
- simple-page-ordering.js +1 -77
- simple-page-ordering.php +227 -168
localization/simple-page-ordering-es_ES.mo
CHANGED
Binary file
|
localization/simple-page-ordering-es_ES.po
CHANGED
@@ -5,53 +5,45 @@ msgstr ""
|
|
5 |
"Project-Id-Version: Simple Page Ordering 1.0\n"
|
6 |
"Report-Msgid-Bugs-To: \n"
|
7 |
"POT-Creation-Date: 2011-07-03 23:41-0500\n"
|
8 |
-
"PO-Revision-Date:
|
9 |
-
"Last-Translator:
|
10 |
"Language-Team: 10up <jake@get10up.com>\n"
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
"Content-Transfer-Encoding: 8bit\n"
|
14 |
-
"
|
15 |
|
16 |
-
#: simple-page-ordering.php:
|
17 |
-
|
18 |
-
"Items can only be repositioned within their current branch in the page tree / hierarchy (next to pages with the same parent).\n"
|
19 |
-
"\n"
|
20 |
-
"If you want to move this item into a different part of the page tree, use the Quick Edit feature to change the parent before continuing."
|
21 |
-
msgstr ""
|
22 |
-
"Los productos que sólo se puede colocar dentro de su rama actual del árbol de páginas / jerarquía (al lado de las páginas con el mismo padre).\n"
|
23 |
-
"\n"
|
24 |
-
"Si desea mover este tema en una parte diferente del árbol de páginas, utilice la función de edición rápida para cambiar la matriz antes de continuar."
|
25 |
-
|
26 |
-
#: simple-page-ordering.php:71
|
27 |
-
msgid "Show all"
|
28 |
-
msgstr "Mostrar todo"
|
29 |
-
|
30 |
-
#: simple-page-ordering.php:76
|
31 |
-
msgid "per page"
|
32 |
-
msgstr "por página"
|
33 |
-
|
34 |
-
#: simple-page-ordering.php:86
|
35 |
-
msgid "Simple Page Ordering"
|
36 |
-
msgstr "Simple Page Ordering"
|
37 |
-
|
38 |
-
#: simple-page-ordering.php:86
|
39 |
msgid "is a plug-in by"
|
40 |
msgstr "es un plug-in por"
|
41 |
|
42 |
-
#: simple-page-ordering.php:
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
#: simple-page-ordering.php:88
|
51 |
-
msgid "If you have a large number of pages, it may be helpful to adjust the new \"items per page\" filter located above the table and before the filter button."
|
52 |
-
msgstr "Si usted tiene un gran número de páginas, puede ser útil para ajustar el nuevo \"artículos por página\" filtro situado por encima de la tabla y antes de que el botón Filtro."
|
53 |
|
54 |
-
#: simple-page-ordering.php:
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
"Project-Id-Version: Simple Page Ordering 1.0\n"
|
6 |
"Report-Msgid-Bugs-To: \n"
|
7 |
"POT-Creation-Date: 2011-07-03 23:41-0500\n"
|
8 |
+
"PO-Revision-Date: 2012-09-15 16:33-0800\n"
|
9 |
+
"Last-Translator: Jacob Goldman <jake@10up.com>\n"
|
10 |
"Language-Team: 10up <jake@get10up.com>\n"
|
11 |
"MIME-Version: 1.0\n"
|
12 |
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
"Content-Transfer-Encoding: 8bit\n"
|
14 |
+
"Language: es\n"
|
15 |
|
16 |
+
#: simple-page-ordering.php:63
|
17 |
+
#, fuzzy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
msgid "is a plug-in by"
|
19 |
msgstr "es un plug-in por"
|
20 |
|
21 |
+
#: simple-page-ordering.php:63
|
22 |
+
#, fuzzy
|
23 |
+
msgid ""
|
24 |
+
"that allows you to order pages and other hierarchical post types with drag "
|
25 |
+
"and drop."
|
26 |
+
msgstr ""
|
27 |
+
"que le permite ordenar las páginas y otros tipos de mensaje jerárquica con "
|
28 |
+
"arrastrar y soltar."
|
|
|
|
|
|
|
29 |
|
30 |
+
#: simple-page-ordering.php:64
|
31 |
+
#, fuzzy
|
32 |
+
msgid ""
|
33 |
+
"To reposition an item, simply drag and drop the row by \"clicking and holding"
|
34 |
+
"\" it anywhere (outside of the links and form controls) and moving it to its "
|
35 |
+
"new position."
|
36 |
+
msgstr ""
|
37 |
+
"Para cambiar la posición de un elemento, basta con arrastrar y soltar en la "
|
38 |
+
"fila de \"clic y manteniendo\" en cualquier lugar (fuera de los vínculos y "
|
39 |
+
"formar controles) y moverla a su nueva posición."
|
40 |
|
41 |
+
#: simple-page-ordering.php:64
|
42 |
+
#, fuzzy
|
43 |
+
msgid ""
|
44 |
+
"If you have a large number of pages, it may be helpful to adjust the items "
|
45 |
+
"shown per page by opening the Screen Options tab."
|
46 |
+
msgstr ""
|
47 |
+
"Si usted tiene un gran número de páginas, puede ser útil para ajustar los "
|
48 |
+
"elementos que se muestran por página, abra la pestaña Opciones de la "
|
49 |
+
"pantalla."
|
localization/simple-page-ordering-nl_NL.mo
ADDED
Binary file
|
localization/simple-page-ordering-nl_NL.po
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2011 Simple Page Ordering
|
2 |
+
# This file is distributed under the same license as the Simple Page Ordering package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Simple Page Ordering 1.0\n"
|
6 |
+
"Report-Msgid-Bugs-To: \n"
|
7 |
+
"POT-Creation-Date: 2011-07-03 23:41-0500\n"
|
8 |
+
"PO-Revision-Date: 2011-12-14 11:38+0100\n"
|
9 |
+
"Last-Translator: Moriz <info@moriz.nl>\n"
|
10 |
+
"Language-Team: 10up <jake@get10up.com>\n"
|
11 |
+
"MIME-Version: 1.0\n"
|
12 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
+
"Content-Transfer-Encoding: 8bit\n"
|
14 |
+
"X-Poedit-Language: Spanish\n"
|
15 |
+
|
16 |
+
#: simple-page-ordering.php:57
|
17 |
+
msgid ""
|
18 |
+
"Items can only be repositioned within their current branch in the page tree / hierarchy (next to pages with the same parent).\n"
|
19 |
+
"\n"
|
20 |
+
"If you want to move this item into a different part of the page tree, use the Quick Edit feature to change the parent before continuing."
|
21 |
+
msgstr ""
|
22 |
+
"Items kunnen alleen verplaatst worden binnen hun huidige niveau (boven of onder pagina's met dezelfde hoofdpagina).\n"
|
23 |
+
"\n"
|
24 |
+
"Als u een pagina onder een andere hoofdpagina wilt plaatsen, kies dan eerst de functie Snel bewerken om een andere hoofdpagina te kiezen."
|
25 |
+
|
26 |
+
#: simple-page-ordering.php:71
|
27 |
+
msgid "Show all"
|
28 |
+
msgstr "Toon alles"
|
29 |
+
|
30 |
+
#: simple-page-ordering.php:76
|
31 |
+
msgid "per page"
|
32 |
+
msgstr "per pagina"
|
33 |
+
|
34 |
+
#: simple-page-ordering.php:86
|
35 |
+
msgid "Simple Page Ordering"
|
36 |
+
msgstr "Simple Page Ordering"
|
37 |
+
|
38 |
+
#: simple-page-ordering.php:86
|
39 |
+
msgid "is a plug-in by"
|
40 |
+
msgstr "is een plug-in door"
|
41 |
+
|
42 |
+
#: simple-page-ordering.php:86
|
43 |
+
msgid "that allows you to order pages and other hierarchical post types with drag and drop."
|
44 |
+
msgstr "welke het mogelijk maakt om pagina's en andere posttypes door drag and drop te verplaatsen."
|
45 |
+
|
46 |
+
#: simple-page-ordering.php:87
|
47 |
+
msgid "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."
|
48 |
+
msgstr "Om een item te verplaatsen, gebruik eenvoudigweg drag en drop (slepen en loslaten) door klikken en vasthouden (buiten de links en knoppen) en het te verplaatsen naar de nieuwe positie."
|
49 |
+
|
50 |
+
#: simple-page-ordering.php:88
|
51 |
+
msgid "If you have a large number of pages, it may be helpful to adjust the new \"items per page\" filter located above the table and before the filter button."
|
52 |
+
msgstr "Als er een groot aantal pagina's zijn, dan kan het handig zijn om het nieuwe Items per pagina filter bovenin de tabel en voor de filter knop aan te passen."
|
53 |
+
|
54 |
+
#: simple-page-ordering.php:89
|
55 |
+
msgid "To keep things relatively simple, the current version only allows you to reposition items within their current tree / hierarchy (next to pages with the same parent). If you want to move an item into or out of a different part of the page tree, use the \"quick edit\" feature to change the parent."
|
56 |
+
msgstr "Om alles relatief eenvoudig te houden staat de huidige versie alleen toe om items binnen hun eigen niveau te verplaatsen. Als een item naar een andere hoofdpagina verplaatst moet worden, gebruik dan eerst de Snel bewerken functie om een andere hoofdpagina te kiezen."
|
57 |
+
|
readme.txt
CHANGED
@@ -1,50 +1,90 @@
|
|
1 |
=== Simple Page Ordering ===
|
2 |
Contributors: jakemgold, 10up, thinkoomph
|
3 |
-
Donate link: http://
|
4 |
Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin
|
5 |
-
Requires at least: 3.
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag:
|
8 |
|
9 |
-
Order your pages and other hierarchical post types with simple drag and drop
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Order your pages, hierarchical custom post types, or custom post types with "page-attributes" with simple drag and drop
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
The plug-in is "capabilities smart" - only users with the ability to edit others' pages (i.e. editors and administrators) will be able to reorder pages.
|
24 |
-
|
25 |
-
Integrated help is included! Just click the "help" tab toward the top right of the screen; the help is below the standard help for the screen.
|
26 |
-
|
27 |
-
Note that this plug-in only allows drag and drop resort within the same "branch" in the page tree / hierarchy. You can still instantly change the hierarchy by using the Quick Edit feature built into WordPress and changing the "Parent". The intention is to avoid confusion about "where" the user is trying to put the page. For example, when moving a page after another page's last child, are you trying to make it a child of the other page, or position it after the other page? Ideas are welcome.
|
28 |
-
|
29 |
-
You must have JavaScript enabled for this plug-in to work. Please note that the plug-in is currently only minimally compatible with Internet Explorer 7 and earlier, due to limitations within those browsers.
|
30 |
|
31 |
|
32 |
== Installation ==
|
33 |
|
34 |
-
1. Install
|
35 |
-
|
36 |
-
1.
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
== Screenshots ==
|
41 |
|
42 |
-
1. Changing the paging (items per page)
|
43 |
1. Dragging the page to its new position
|
44 |
1. Processing indicator
|
45 |
|
46 |
|
47 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
= 1.0 =
|
50 |
* Fix unexpected page ordering results when pages have not been explictly ordered yet (sorts by menu_order, then title, not just menu_order)
|
1 |
=== Simple Page Ordering ===
|
2 |
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.2
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 2.0
|
8 |
|
9 |
+
Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Order your pages, hierarchical custom post types, or custom post types with "page-attributes" with simple drag and drop right from the built in page list.
|
14 |
|
15 |
+
Simply drag and drop the page into the desired position. It's that simple. No new admin menus pages, no clunky, bolted on user interfaces. Just drag and drop on the page or post-type screen.
|
16 |
|
17 |
+
The plug-in is "capabilities aware" - only users with the ability to edit others' pages (editors and administrators) will be able to reorder content.
|
18 |
|
19 |
+
Integrated help is included: just click the "help" tab at the top right of the screen.
|
20 |
|
21 |
+
Please note that the plug-in is currently only minimally compatible with Internet Explorer 7 and earlier, due to limitations within those browsers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
|
24 |
== Installation ==
|
25 |
|
26 |
+
1. Install either via the WordPress.org plugin directory, or by uploading the files to your server.
|
27 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
28 |
+
1. Get to work reordering your content!
|
29 |
+
|
30 |
+
|
31 |
+
== Frequently Asked Questions ==
|
32 |
+
|
33 |
+
= Why can't I reorder my posts? =
|
34 |
+
|
35 |
+
Generic posts are not displayed by menu order - they're displayed by chronology. You can theoretically add menu ordering to posts in your code (theme functions.php, plug-in) by using:
|
36 |
+
|
37 |
+
`add_post_type_support( 'post', 'page-attributes' );`
|
38 |
+
|
39 |
+
= Can I make my custom post type take advantage of this plug-in? =
|
40 |
+
|
41 |
+
Yep. There are two ways to turn on support for Simple Page Ordering.
|
42 |
+
|
43 |
+
Ideally, when you register the post type, set `hierarchical` to `true` - hierarchical post types natively order by menu order.
|
44 |
+
|
45 |
+
Alternatively, when you define the features the post type supports, include `page-attributes`. This will add a `Sort by Order` option to the filter links above the drop downs. Once you sort by order, you can drag and drop the content.
|
46 |
+
|
47 |
+
Finally, you can take advantage of the `simple_page_ordering_is_sortable` filter, which passes the result of the default check and the post type name, to override default behavior.
|
48 |
+
|
49 |
+
= I want my non-hierarchical post type to be sortable. Help! =
|
50 |
+
|
51 |
+
See the previous two answers - just add `page-attributes` to the list of supported post type features.
|
52 |
+
|
53 |
+
= I reordered my posts, but the order didn't change on the front end of my site! =
|
54 |
+
|
55 |
+
This plug-in doesn't change any *behavior* on the front end, it simply changes the menu order stored in WordPress.
|
56 |
+
|
57 |
+
If you want a list of pages or custom post types to display in that defined order, you must change the post query's `orderby` parameter to `menu_order` (if it's not already).
|
58 |
+
|
59 |
+
= I reordered my content, it seemed to work, but when I refreshed, it went back to the old order! =
|
60 |
+
|
61 |
+
This most likely means the AJAX request - the server side code - failed after you dropped the content into the new position. Some shared hosts aggressively time out and limit AJAX requests. Version 2.0 batches these requests so you can try reducing the number of items it updates on each request using a filter in your theme's functions.php or a custom plug-in:
|
62 |
+
|
63 |
+
`add_filter( 'simple_page_ordering_limit', function($number) { return 5; } );`
|
64 |
+
|
65 |
+
Where 5 is the number of items to batch on each request (the default is 50). Note that this example uses PHP 5.3+ callback functions, so if you're still on PHP 5.2, you'll need to add a traditional callback.
|
66 |
+
|
67 |
+
= What happened to the drop down box that let me change the number of items on each page in the admin?? =
|
68 |
+
|
69 |
+
This feature is already built into WordPress natively, but a bit tucked away. If you pull down the "Screen Options" tab up top (on the list of post objects) there's a field where you can specify the number of items to show per page. I decided it was not a very good practice to duplicate this.
|
70 |
|
71 |
|
72 |
== Screenshots ==
|
73 |
|
|
|
74 |
1. Dragging the page to its new position
|
75 |
1. Processing indicator
|
76 |
|
77 |
|
78 |
== Changelog ==
|
79 |
+
|
80 |
+
= 2.0 =
|
81 |
+
* Drag pages into any part of the page hierarchy! No longer limited to same branch of tree!
|
82 |
+
* Big performance improvements under the hood: leaner queries, batched requests, less processing
|
83 |
+
* Scales much more reliably in situations with very high page counts due to batching of requests
|
84 |
+
* Order of the first page is now set to "1" instead of "0", so pages added after ordering are added at the top (instead of second)
|
85 |
+
* Removed "number of pages" drop down, which is repetitive of a field accessible under Screen Options
|
86 |
+
* New filters and hooks to extend / override default functionality
|
87 |
+
* Improved compatibility with newer versions of WordPress
|
88 |
|
89 |
= 1.0 =
|
90 |
* Fix unexpected page ordering results when pages have not been explictly ordered yet (sorts by menu_order, then title, not just menu_order)
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
DELETED
Binary file
|
simple-page-ordering.dev.js
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function update_simple_ordering_callback(response) {
|
2 |
+
if ( response == 'children' ) {
|
3 |
+
window.location.reload();
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
var changes = jQuery.parseJSON( response );
|
8 |
+
|
9 |
+
var new_pos = changes.new_pos;
|
10 |
+
for ( key in new_pos ) {
|
11 |
+
if ( key == 'next' )
|
12 |
+
continue;
|
13 |
+
|
14 |
+
if ( jQuery('#inline_'+key).length > 0 ) {
|
15 |
+
if ( new_pos[key]['menu_order'] != null ) {
|
16 |
+
jQuery('#inline_'+key+' .menu_order').html( new_pos[key]['menu_order'] );
|
17 |
+
jQuery('#inline_'+key+' .post_parent').html( new_pos[key]['post_parent'] );
|
18 |
+
var post_title = jQuery('#inline_'+key+' .post_title').html();
|
19 |
+
var dashes = 0;
|
20 |
+
while ( dashes < new_pos[key]['depth'] ) {
|
21 |
+
post_title = '— ' + post_title;
|
22 |
+
dashes++;
|
23 |
+
}
|
24 |
+
jQuery('tr#post-'+key+' a.row-title').html( post_title );
|
25 |
+
} else {
|
26 |
+
jQuery('#inline_'+key+' .menu_order').html(new_pos[key]);
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( changes.next ) {
|
32 |
+
jQuery.post( ajaxurl, {
|
33 |
+
action: 'simple_page_ordering',
|
34 |
+
id: changes.next['id'],
|
35 |
+
previd: changes.next['previd'],
|
36 |
+
nextid: changes.next['nextid'],
|
37 |
+
start: changes.next['start'],
|
38 |
+
excluded: changes.next['excluded']
|
39 |
+
}, update_simple_ordering_callback );
|
40 |
+
} else {
|
41 |
+
jQuery('.check-column .waiting').siblings('input').show().siblings('img').remove();
|
42 |
+
jQuery('tr.iedit').css('cursor','move');
|
43 |
+
jQuery(".wp-list-table tbody").sortable('enable');
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
jQuery('tr.iedit').css('cursor','move');
|
48 |
+
|
49 |
+
jQuery(".wp-list-table tbody").sortable({
|
50 |
+
items: 'tr:not(.inline-edit-row)',
|
51 |
+
cursor: 'move',
|
52 |
+
axis: 'y',
|
53 |
+
containment: 'table.widefat',
|
54 |
+
scrollSensitivity: 40,
|
55 |
+
helper: function(e, ui) {
|
56 |
+
ui.children().each(function() { jQuery(this).width(jQuery(this).width()); });
|
57 |
+
return ui;
|
58 |
+
},
|
59 |
+
start: function(event, ui) {
|
60 |
+
if ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );
|
61 |
+
ui.item.children('td,th').css('border-bottom-width','0');
|
62 |
+
ui.item.css( 'outline', '1px solid #dfdfdf' );
|
63 |
+
},
|
64 |
+
stop: function(event, ui) {
|
65 |
+
ui.item.removeAttr('style');
|
66 |
+
ui.item.children('td,th').css('border-bottom-width','1px');
|
67 |
+
},
|
68 |
+
update: function(event, ui) {
|
69 |
+
jQuery('tr.iedit').css('cursor','default');
|
70 |
+
jQuery(".wp-list-table tbody").sortable('disable');
|
71 |
+
|
72 |
+
var postid = ui.item.attr('id').substr(5); // post id
|
73 |
+
|
74 |
+
var prevpostid = false;
|
75 |
+
var prevpost = ui.item.prev();
|
76 |
+
if ( prevpost.length > 0 )
|
77 |
+
prevpostid = prevpost.attr('id').substr(5);
|
78 |
+
|
79 |
+
var nextpostid = false;
|
80 |
+
var nextpost = ui.item.next();
|
81 |
+
if ( nextpost.length > 0 )
|
82 |
+
nextpostid = nextpost.attr('id').substr(5);
|
83 |
+
|
84 |
+
// show spinner
|
85 |
+
ui.item.find('.check-column input').hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');
|
86 |
+
|
87 |
+
// go do the sorting stuff via ajax
|
88 |
+
jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, update_simple_ordering_callback );
|
89 |
+
|
90 |
+
// fix cell colors
|
91 |
+
jQuery( 'tr.iedit' ).each(function(i){
|
92 |
+
if ( i%2 == 0 ) jQuery(this).addClass('alternate');
|
93 |
+
else jQuery(this).removeClass('alternate');
|
94 |
+
});
|
95 |
+
}
|
96 |
+
});
|
simple-page-ordering.js
CHANGED
@@ -1,77 +1 @@
|
|
1 |
-
jQuery('
|
2 |
-
|
3 |
-
jQuery("table.widefat tbody").sortable({
|
4 |
-
items: 'tr:not(.inline-edit-row)',
|
5 |
-
cursor: 'move',
|
6 |
-
axis: 'y',
|
7 |
-
containment: 'table.widefat',
|
8 |
-
scrollSensitivity: 40,
|
9 |
-
helper: function(e, ui) {
|
10 |
-
ui.children().each(function() { jQuery(this).width(jQuery(this).width()); });
|
11 |
-
return ui;
|
12 |
-
},
|
13 |
-
start: function(event, ui) {
|
14 |
-
if ( ! ui.item.hasClass('alternate') ) ui.item.css( 'background-color', '#ffffff' );
|
15 |
-
ui.item.children('td,th').css('border-bottom-width','0');
|
16 |
-
ui.item.css( 'outline', '1px solid #dfdfdf' );
|
17 |
-
},
|
18 |
-
stop: function(event, ui) {
|
19 |
-
ui.item.removeAttr('style');
|
20 |
-
ui.item.children('td,th').css('border-bottom-width','1px');
|
21 |
-
},
|
22 |
-
update: function(event, ui) {
|
23 |
-
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','default');
|
24 |
-
jQuery("table.widefat tbody").sortable('disable');
|
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
|
28 |
-
|
29 |
-
var prevpostid = ui.item.prev().find('.check-column input').val();
|
30 |
-
var nextpostid = ui.item.next().find('.check-column input').val();
|
31 |
-
|
32 |
-
// can only sort in same tree
|
33 |
-
|
34 |
-
var prevpostparent = undefined;
|
35 |
-
if ( prevpostid != undefined ) {
|
36 |
-
var prevpostparent = ui.item.prev().find('.post_parent').html()
|
37 |
-
if ( prevpostparent != postparent) prevpostid = undefined;
|
38 |
-
}
|
39 |
-
|
40 |
-
var nextpostparent = undefined;
|
41 |
-
if ( nextpostid != undefined ) {
|
42 |
-
nextpostparent = ui.item.next().find('.post_parent').html();
|
43 |
-
if ( nextpostparent != postparent) nextpostid = undefined;
|
44 |
-
}
|
45 |
-
|
46 |
-
// if previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children
|
47 |
-
if ( ( prevpostid == undefined && nextpostid == undefined ) || ( nextpostid == undefined && nextpostparent == prevpostid ) || ( nextpostid != undefined && prevpostparent == postid ) ) {
|
48 |
-
jQuery("table.widefat tbody").sortable('cancel');
|
49 |
-
alert( simple_page_ordering_l10n.RepositionTree );
|
50 |
-
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','move');
|
51 |
-
jQuery("table.widefat tbody").sortable('enable');
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
// show spinner
|
56 |
-
ui.item.find('.check-column input').hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');
|
57 |
-
|
58 |
-
// go do the sorting stuff via ajax
|
59 |
-
jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function(response){
|
60 |
-
if ( response == 'children' ) window.location.reload();
|
61 |
-
else {
|
62 |
-
var changes = jQuery.parseJSON(response);
|
63 |
-
jQuery.each(changes, function(key,value) { jQuery('#inline_'+key+' .menu_order').html(value); });
|
64 |
-
ui.item.find('.check-column input').show().siblings('img').remove();
|
65 |
-
jQuery('table.widefat tbody th, table.widefat tbody td').css('cursor','move');
|
66 |
-
jQuery("table.widefat tbody").sortable('enable');
|
67 |
-
}
|
68 |
-
});
|
69 |
-
|
70 |
-
// fix cell colors
|
71 |
-
jQuery( 'table.widefat tbody tr' ).each(function(){
|
72 |
-
var i = jQuery('table.widefat tbody tr').index(this);
|
73 |
-
if ( i%2 == 0 ) jQuery(this).addClass('alternate');
|
74 |
-
else jQuery(this).removeClass('alternate');
|
75 |
-
});
|
76 |
-
}
|
77 |
-
});
|
1 |
+
function update_simple_ordering_callback(response){if(response=='children'){window.location.reload();return}var changes=jQuery.parseJSON(response);var new_pos=changes.new_pos;for(key in new_pos){if(key=='next')continue;if(jQuery('#inline_'+key).length>0){if(new_pos[key]['menu_order']!=null){jQuery('#inline_'+key+' .menu_order').html(new_pos[key]['menu_order']);jQuery('#inline_'+key+' .post_parent').html(new_pos[key]['post_parent']);var post_title=jQuery('#inline_'+key+' .post_title').html();var dashes=0;while(dashes<new_pos[key]['depth']){post_title='— '+post_title;dashes++}jQuery('tr#post-'+key+' a.row-title').html(post_title)}else{jQuery('#inline_'+key+' .menu_order').html(new_pos[key])}}}if(changes.next){jQuery.post(ajaxurl,{action:'simple_page_ordering',id:changes.next['id'],previd:changes.next['previd'],nextid:changes.next['nextid'],start:changes.next['start'],excluded:changes.next['excluded']},update_simple_ordering_callback)}else{jQuery('.check-column .waiting').siblings('input').show().siblings('img').remove();jQuery('tr.iedit').css('cursor','move');jQuery(".wp-list-table tbody").sortable('enable')}}jQuery('tr.iedit').css('cursor','move');jQuery(".wp-list-table tbody").sortable({items:'tr:not(.inline-edit-row)',cursor:'move',axis:'y',containment:'table.widefat',scrollSensitivity:40,helper:function(e,ui){ui.children().each(function(){jQuery(this).width(jQuery(this).width())});return ui},start:function(event,ui){if(!ui.item.hasClass('alternate'))ui.item.css('background-color','#ffffff');ui.item.children('td,th').css('border-bottom-width','0');ui.item.css('outline','1px solid #dfdfdf')},stop:function(event,ui){ui.item.removeAttr('style');ui.item.children('td,th').css('border-bottom-width','1px')},update:function(event,ui){jQuery('tr.iedit').css('cursor','default');jQuery(".wp-list-table tbody").sortable('disable');var postid=ui.item.attr('id').substr(5);var prevpostid=false;var prevpost=ui.item.prev();if(prevpost.length>0)prevpostid=prevpost.attr('id').substr(5);var nextpostid=false;var nextpost=ui.item.next();if(nextpost.length>0)nextpostid=nextpost.attr('id').substr(5);ui.item.find('.check-column input').hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />');jQuery.post(ajaxurl,{action:'simple_page_ordering',id:postid,previd:prevpostid,nextid:nextpostid},update_simple_ordering_callback);jQuery('tr.iedit').each(function(i){if(i%2==0)jQuery(this).addClass('alternate');else jQuery(this).removeClass('alternate')})}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
simple-page-ordering.php
CHANGED
@@ -1,168 +1,227 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
function load_edit_screen() {
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
if ( !
|
47 |
-
return;
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
//
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
if
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
'
|
113 |
-
'
|
114 |
-
'
|
115 |
-
'
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
$
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$new_pos[$post->ID] =
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
if (
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
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.0
|
7 |
+
Author: Jake Goldman, 10up, Oomph
|
8 |
+
Author URI: http://10up.com
|
9 |
+
License: GPLv2 or later
|
10 |
+
|
11 |
+
This plug-in is was created by Jake Goldman with original copyright
|
12 |
+
attributions for purposes of GPL enforcement assigned to Oomph Inc
|
13 |
+
(pre-1.0). All modifications, updates, and support since February 2011
|
14 |
+
have been provided by 10up LLC and Jake Goldman from that date forward,
|
15 |
+
including the near rewrite, version 2.0.
|
16 |
+
|
17 |
+
This program is free software; you can redistribute it and/or modify
|
18 |
+
it under the terms of the GNU General Public License as published by
|
19 |
+
the Free Software Foundation; either version 2 of the License, or
|
20 |
+
(at your option) any later version.
|
21 |
+
|
22 |
+
This program is distributed in the hope that it will be useful,
|
23 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
+
GNU General Public License for more details.
|
26 |
+
|
27 |
+
You should have received a copy of the GNU General Public License
|
28 |
+
along with this program; if not, write to the Free Software
|
29 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30 |
+
*/
|
31 |
+
|
32 |
+
class Simple_Page_Ordering {
|
33 |
+
|
34 |
+
public function __construct() {
|
35 |
+
add_action( 'load-edit.php', array( $this, 'load_edit_screen' ) );
|
36 |
+
add_action( 'wp_ajax_simple_page_ordering', array( $this, 'ajax_simple_page_ordering' ) );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function load_edit_screen() {
|
40 |
+
if ( ! current_user_can('edit_others_pages') )
|
41 |
+
return;
|
42 |
+
|
43 |
+
$screen = get_current_screen();
|
44 |
+
$sortable = ( post_type_supports( $screen->post_type, 'page-attributes' ) || is_post_type_hierarchical( $screen->post_type ) ); // check permission
|
45 |
+
$sortable = apply_filters( 'simple_page_ordering_is_sortable', $sortable, $screen->post_type );
|
46 |
+
if ( ! $sortable )
|
47 |
+
return;
|
48 |
+
|
49 |
+
add_filter( 'views_' . $screen->id, array( $this, 'sort_by_order_link' ) ); // add view by menu order to views
|
50 |
+
add_action( 'wp', array( $this, 'wp' ) );
|
51 |
+
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
public function wp() {
|
55 |
+
if ( strpos( get_query_var('orderby'), 'menu_order' ) === 0 ) { // we can only sort if we're organized by menu order
|
56 |
+
$script_name = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'simple-page-ordering.dev.js' : 'simple-page-ordering.js';
|
57 |
+
wp_enqueue_script( 'simple-page-ordering', plugins_url( $script_name, __FILE__ ), array('jquery-ui-sortable'), '2.0', true );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
public function admin_head() {
|
62 |
+
$screen = get_current_screen();
|
63 |
+
$screen->add_help_tab(array(
|
64 |
+
'id' => 'simple_page_ordering_help_tab',
|
65 |
+
'title' => 'Simple Page Ordering',
|
66 |
+
'content' => '<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.', 'simple-page-ordering' ) . '</p>',
|
67 |
+
));
|
68 |
+
}
|
69 |
+
|
70 |
+
public function ajax_simple_page_ordering() {
|
71 |
+
// check permissions again and make sure we have what we need
|
72 |
+
if ( !current_user_can( 'edit_others_pages' ) || empty( $_POST['id'] ) || ( !isset( $_POST['previd'] ) && !isset( $_POST['nextid'] ) ) )
|
73 |
+
die(-1);
|
74 |
+
|
75 |
+
// real post?
|
76 |
+
if ( ! $post = get_post( $_POST['id'] ) )
|
77 |
+
die(-1);
|
78 |
+
|
79 |
+
// badly written plug-in hooks for save post can break things
|
80 |
+
error_reporting( 0 );
|
81 |
+
|
82 |
+
$previd = empty( $_POST['previd'] ) ? false : (int) $_POST['previd'];
|
83 |
+
$nextid = empty( $_POST['nextid'] ) ? false : (int) $_POST['nextid'];
|
84 |
+
$start = empty( $_POST['start'] ) ? 1 : (int) $_POST['start'];
|
85 |
+
$excluded = empty( $_POST['excluded'] ) ? array( $post->ID ) : array_filter( (array) $_POST['excluded'], 'intval' );
|
86 |
+
|
87 |
+
$new_pos = array(); // store new positions for ajax
|
88 |
+
$return_data = new stdClass;
|
89 |
+
|
90 |
+
do_action( 'simple_page_ordering_pre_order_posts', $post, $start );
|
91 |
+
|
92 |
+
// attempt to get the intended parent... if either sibling has a matching parent ID, use that
|
93 |
+
$parent_id = $post->post_parent;
|
94 |
+
//$prev_post_parent = $previd ? wp_get_post_parent_id( $previd ) : false;
|
95 |
+
$next_post_parent = $nextid ? wp_get_post_parent_id( $nextid ) : false;
|
96 |
+
if ( $previd == $next_post_parent ) { // if the preceding post is the parent of the next most, move it inside
|
97 |
+
$parent_id = $next_post_parent;
|
98 |
+
} elseif ( $next_post_parent !== $parent_id ) { // otherwise, if the next post's parent isn't the same as our parent, we need to study
|
99 |
+
$prev_post_parent = $previd ? wp_get_post_parent_id( $previd ) : false;
|
100 |
+
if ( $prev_post_parent !== $parent_id ) // if the previous post is not our parent now, make it so!
|
101 |
+
$parent_id = ( $prev_post_parent !== false ) ? $prev_post_parent : $next_post_parent;
|
102 |
+
}
|
103 |
+
// if the next post's parent isn't our parent, it might as well be false (irrelevant to our query)
|
104 |
+
if ( $next_post_parent !== $parent_id )
|
105 |
+
$nextid = false;
|
106 |
+
|
107 |
+
$max_sortable_posts = (int) apply_filters( 'simple_page_ordering_limit', 50 ); // should reliably be able to do about 50 at a time
|
108 |
+
if ( $max_sortable_posts < 5 )
|
109 |
+
$max_sortable_posts = 50;
|
110 |
+
|
111 |
+
$siblings = new WP_Query(array(
|
112 |
+
'depth' => 1,
|
113 |
+
'posts_per_page' => $max_sortable_posts,
|
114 |
+
'post_type' => $post->post_type,
|
115 |
+
'post_status' => array( 'publish' , 'pending', 'draft', 'future', 'private' ),
|
116 |
+
'post_parent' => $parent_id,
|
117 |
+
'orderby' => 'menu_order title',
|
118 |
+
'order' => 'ASC',
|
119 |
+
'post__not_in' => array_merge( $excluded ),
|
120 |
+
'update_post_term_cache' => false,
|
121 |
+
'update_post_meta_cache' => false,
|
122 |
+
'suppress_filters' => true,
|
123 |
+
'ignore_sticky_posts' => true,
|
124 |
+
)); // fetch all the siblings (relative ordering)
|
125 |
+
|
126 |
+
// don't waste overhead of revisions on a menu order change (especially since they can't *all* be rolled back at once)
|
127 |
+
remove_action( 'pre_post_update', 'wp_save_post_revision' );
|
128 |
+
|
129 |
+
foreach( $siblings->posts as $sibling ) :
|
130 |
+
|
131 |
+
// don't handle the actual post
|
132 |
+
if ( $sibling->ID == $post->ID )
|
133 |
+
continue;
|
134 |
+
|
135 |
+
// if this is the post that comes after our repositioned post, set our repositioned post position and increment menu order
|
136 |
+
if ( $nextid == $sibling->ID ) {
|
137 |
+
wp_update_post(array(
|
138 |
+
'ID' => $post->ID,
|
139 |
+
'menu_order' => $start,
|
140 |
+
'post_parent' => $parent_id,
|
141 |
+
));
|
142 |
+
$ancestors = get_post_ancestors( $post->ID );
|
143 |
+
$new_pos[$post->ID] = array(
|
144 |
+
'menu_order' => $start,
|
145 |
+
'post_parent' => $parent_id,
|
146 |
+
'depth' => count( $ancestors ),
|
147 |
+
);
|
148 |
+
$start++;
|
149 |
+
}
|
150 |
+
|
151 |
+
// if repositioned post has been set, and new items are already in the right order, we can stop
|
152 |
+
if ( isset( $new_pos[$post->ID] ) && $sibling->menu_order >= $start ) {
|
153 |
+
$return_data->next = false;
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
|
157 |
+
// set the menu order of the current sibling and increment the menu order
|
158 |
+
if ( $sibling->menu_order != $start ) {
|
159 |
+
wp_update_post(array(
|
160 |
+
'ID' => $sibling->ID,
|
161 |
+
'menu_order' => $start,
|
162 |
+
));
|
163 |
+
}
|
164 |
+
$new_pos[$sibling->ID] = $start;
|
165 |
+
$start++;
|
166 |
+
|
167 |
+
if ( !$nextid && $previd == $sibling->ID ) {
|
168 |
+
wp_update_post(array(
|
169 |
+
'ID' => $post->ID,
|
170 |
+
'menu_order' => $start,
|
171 |
+
'post_parent' => $parent_id
|
172 |
+
));
|
173 |
+
$ancestors = get_post_ancestors( $post->ID );
|
174 |
+
$new_pos[$post->ID] = array(
|
175 |
+
'menu_order' => $start,
|
176 |
+
'post_parent' => $parent_id,
|
177 |
+
'depth' => count($ancestors) );
|
178 |
+
$start++;
|
179 |
+
}
|
180 |
+
|
181 |
+
endforeach;
|
182 |
+
|
183 |
+
// max per request
|
184 |
+
if ( !isset( $return_data->next ) && $siblings->max_num_pages > 1 ) {
|
185 |
+
$return_data->next = array(
|
186 |
+
'id' => $post->ID,
|
187 |
+
'previd' => $previd,
|
188 |
+
'nextid' => $nextid,
|
189 |
+
'start' => $start,
|
190 |
+
'excluded' => array_merge( array_keys( $new_pos ), $excluded ),
|
191 |
+
);
|
192 |
+
} else {
|
193 |
+
$return_data->next = false;
|
194 |
+
}
|
195 |
+
|
196 |
+
do_action( 'simple_page_ordering_ordered_posts', $post, $new_pos );
|
197 |
+
|
198 |
+
if ( ! $return_data->next ) {
|
199 |
+
// if the moved post has children, we need to refresh the page (unless we're continuing)
|
200 |
+
$children = get_posts(array(
|
201 |
+
'numberposts' => 1,
|
202 |
+
'post_type' => $post->post_type,
|
203 |
+
'post_status' => array('publish','pending','draft','future','private'),
|
204 |
+
'post_parent' => $post->ID,
|
205 |
+
'update_post_term_cache' => false,
|
206 |
+
'update_post_meta_cache' => false,
|
207 |
+
));
|
208 |
+
|
209 |
+
if ( ! empty( $children ) )
|
210 |
+
die( 'children' );
|
211 |
+
}
|
212 |
+
|
213 |
+
$return_data->new_pos = $new_pos;
|
214 |
+
|
215 |
+
die( json_encode( $return_data ) );
|
216 |
+
}
|
217 |
+
|
218 |
+
public function sort_by_order_link( $views ) {
|
219 |
+
$class = ( get_query_var('orderby') == 'menu_order title' ) ? 'current' : '';
|
220 |
+
$query_string = remove_query_arg(array( 'orderby', 'order' ));
|
221 |
+
$query_string = add_query_arg( 'orderby', urlencode('menu_order title'), $query_string );
|
222 |
+
$views['byorder'] = '<a href="'. $query_string . '" class="' . $class . '">Sort by Order</a>';
|
223 |
+
return $views;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
$simple_page_ordering = new Simple_Page_Ordering;
|