Simple Page Ordering - Version 2.4.2

Version Description

  • 2022-09-28 =
  • Changed: Replaced our Grunt build process with 10up-toolkit (props @cadic, @peterwilsoncc, @dinhtungdu via #97.
  • Fixed: Disable reordering for CPTs that don't support page-attributes (props @dhanendran, @dinhtungdu, @peterwilsoncc via #103.
Download this release

Release Info

Developer 10up
Plugin Icon 128x128 Simple Page Ordering
Version 2.4.2
Comparing to
See all releases

Code changes from version 2.4.1 to 2.4.2

assets/css/scss/simple-page-ordering.scss DELETED
@@ -1,40 +0,0 @@
1
- .wp-list-table {
2
- .ui-sortable {
3
- tr {
4
- cursor: move;
5
- &.inline-editor {
6
- cursor: default;
7
- }
8
- }
9
- }
10
-
11
- .spo-updating {
12
- tr {
13
- cursor: default;
14
- }
15
- }
16
-
17
- .ui-sortable-placeholder {
18
- outline: 1px dashed #bbb;
19
- background: #F1F1F1;
20
- visibility: visible !important;
21
- }
22
-
23
- .ui-sortable-helper {
24
- background-color: #fff;
25
- outline: 1px solid #e1e1e1;
26
- }
27
- }
28
-
29
- .spo-updating-row {
30
- .check-column {
31
- display: table-cell; // reset from core .spinner
32
- float: none; // reset from core .spinner
33
- margin: 0; // reset from core .spinner
34
- background-position: 9px 9px;
35
-
36
- input {
37
- visibility: hidden;
38
- }
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/simple-page-ordering.css DELETED
@@ -1,26 +0,0 @@
1
- .wp-list-table .ui-sortable tr {
2
- cursor: move; }
3
- .wp-list-table .ui-sortable tr.inline-editor {
4
- cursor: default; }
5
-
6
- .wp-list-table .spo-updating tr {
7
- cursor: default; }
8
-
9
- .wp-list-table .ui-sortable-placeholder {
10
- outline: 1px dashed #bbb;
11
- background: #F1F1F1;
12
- visibility: visible !important; }
13
-
14
- .wp-list-table .ui-sortable-helper {
15
- background-color: #fff;
16
- outline: 1px solid #e1e1e1; }
17
-
18
- .spo-updating-row .check-column {
19
- display: table-cell;
20
- float: none;
21
- margin: 0;
22
- background-position: 9px 9px; }
23
- .spo-updating-row .check-column input {
24
- visibility: hidden; }
25
-
26
- /*# sourceMappingURL=simple-page-ordering.css.map */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/simple-page-ordering.css.map DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "file": "simple-page-ordering.css",
4
- "sources": [
5
- "scss/simple-page-ordering.scss"
6
- ],
7
- "names": [],
8
- "mappings": "AAAA,AAEE,cAFY,CACb,YAAY,CACX,EAAE,CAAC;EACF,MAAM,EAAE,IAAI,GAIZ;EAPH,AAEE,cAFY,CACb,YAAY,CACX,EAAE,AAED,cAAe,CAAC;IACf,MAAM,EAAE,OAAO,GACf;;AANJ,AAWE,cAXY,CAUb,aAAa,CACZ,EAAE,CAAC;EACF,MAAM,EAAE,OAAO,GACf;;AAbH,AAgBC,cAhBa,CAgBb,wBAAwB,CAAC;EACxB,OAAO,EAAE,eAAe;EACxB,UAAU,EAAE,OAAO;EACnB,UAAU,EAAE,kBAAkB,GAC9B;;AApBF,AAsBC,cAtBa,CAsBb,mBAAmB,CAAC;EACnB,gBAAgB,EAAE,IAAI;EACtB,OAAO,EAAE,iBAAiB,GAC1B;;AAGF,AACC,iBADgB,CAChB,aAAa,CAAC;EACb,OAAO,EAAE,UAAU;EACnB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,CAAC;EACT,mBAAmB,EAAE,OAAO,GAK5B;EAVF,AAOE,iBAPe,CAChB,aAAa,CAMZ,KAAK,CAAC;IACL,UAAU,EAAE,MAAM,GAClB"
9
- }
 
 
 
 
 
 
 
 
 
assets/js/simple-page-ordering.min.js DELETED
@@ -1 +0,0 @@
1
- function update_simple_ordering_callback(e){if("children"!==e){var t=jQuery.parseJSON(e),r=t.new_pos;for(var a in r)if("next"!==a){var n=document.getElementById("inline_"+a);if(null!==n&&r.hasOwnProperty(a)){var o=n.querySelector(".menu_order");if(void 0!==r[a].menu_order){null!==o&&(o.textContent=r[a].menu_order);var l=n.querySelector(".post_parent");null!==l&&(l.textContent=r[a].post_parent);var i=null,s=n.querySelector(".post_title");null!==s&&(i=s.innerHTML);for(var d=0;d<r[a].depth;)i="&mdash; "+i,d++;var p=n.parentNode.querySelector(".row-title");if(null!==p&&null!==i){var c=document.createElement("textarea");c.innerHTML=i,p.textContent=c.value}}else null!==o&&(o.textContent=r[a])}}t.next?jQuery.post(ajaxurl,{action:"simple_page_ordering",id:t.next.id,previd:t.next.previd,nextid:t.next.nextid,start:t.next.start,_wpnonce:simple_page_ordering_localized_data._wpnonce,screen_id:simple_page_ordering_localized_data.screen_id,excluded:JSON.stringify(t.next.excluded)},update_simple_ordering_callback):(jQuery(".spo-updating-row").removeClass("spo-updating-row").find(".check-column").removeClass("spinner is-active"),sortable_post_table.removeClass("spo-updating").sortable("enable"))}else window.location.reload()}var sortable_post_table=jQuery(".wp-list-table tbody");sortable_post_table.sortable({items:"> tr",cursor:"move",axis:"y",containment:"table.widefat",cancel:"input, textarea, button, select, option, .inline-edit-row",distance:2,opacity:.8,tolerance:"pointer",create:function(){jQuery(document).keydown(function(e){var t=e.key||e.keyCode;"Escape"!==t&&"Esc"!==t&&27!==t||(sortable_post_table.sortable("option","preventUpdate",!0),sortable_post_table.sortable("cancel"))})},start:function(e,t){"undefined"!=typeof inlineEditPost&&inlineEditPost.revert(),t.placeholder.height(t.item.height()),t.placeholder.empty()},helper:function(e,t){for(var r=t.children(),a=0;a<r.length;a++){var n=jQuery(r[a]);n.width(n.width())}return t},stop:function(e,t){sortable_post_table.sortable("option","preventUpdate")&&sortable_post_table.sortable("option","preventUpdate",!1),t.item.children().css("width","")},update:function(e,t){if(sortable_post_table.sortable("option","preventUpdate"))sortable_post_table.sortable("option","preventUpdate",!1);else{sortable_post_table.sortable("disable").addClass("spo-updating"),t.item.addClass("spo-updating-row"),t.item.find(".check-column").addClass("spinner is-active");var r=t.item[0].id.substr(5),a=!1,n=t.item.prev();0<n.length&&(a=n.attr("id").substr(5));var o=!1,l=t.item.next();0<l.length&&(o=l.attr("id").substr(5)),jQuery.post(ajaxurl,{action:"simple_page_ordering",id:r,previd:a,nextid:o,_wpnonce:simple_page_ordering_localized_data._wpnonce,screen_id:simple_page_ordering_localized_data.screen_id},update_simple_ordering_callback);for(var i=document.querySelectorAll("tr.iedit"),s=i.length;s--;)0==s%2?jQuery(i[s]).addClass("alternate"):jQuery(i[s]).removeClass("alternate")}}});
 
assets/js/src/simple-page-ordering.js DELETED
@@ -1,150 +0,0 @@
1
- function update_simple_ordering_callback(response) {
2
- if ( 'children' === response ) {
3
- window.location.reload();
4
- return;
5
- }
6
-
7
- var changes = jQuery.parseJSON( response );
8
-
9
- var new_pos = changes.new_pos;
10
- for ( var key in new_pos ) {
11
- if ( 'next' === key ) {
12
- continue;
13
- }
14
-
15
- var inline_key = document.getElementById('inline_' + key);
16
- if ( null !== inline_key && new_pos.hasOwnProperty(key) ) {
17
- var dom_menu_order = inline_key.querySelector('.menu_order');
18
-
19
- if ( undefined !== new_pos[key]['menu_order'] ) {
20
- if ( null !== dom_menu_order ) {
21
- dom_menu_order.textContent = new_pos[key]['menu_order'];
22
- }
23
-
24
- var dom_post_parent = inline_key.querySelector('.post_parent');
25
- if ( null !== dom_post_parent ) {
26
- dom_post_parent.textContent = new_pos[key]['post_parent'];
27
- }
28
-
29
- var post_title = null;
30
- var dom_post_title = inline_key.querySelector('.post_title');
31
- if ( null !== dom_post_title ) {
32
- post_title = dom_post_title.innerHTML;
33
- }
34
-
35
- var dashes = 0;
36
- while ( dashes < new_pos[key]['depth'] ) {
37
- post_title = '&mdash; ' + post_title;
38
- dashes++;
39
- }
40
- var dom_row_title = inline_key.parentNode.querySelector('.row-title');
41
- if ( null !== dom_row_title && null !== post_title ) {
42
- // Decode mdash character before rendering the title.
43
- var textArea = document.createElement('textarea');
44
- textArea.innerHTML = post_title;
45
- dom_row_title.textContent = textArea.value;
46
- }
47
- } else if ( null !== dom_menu_order ) {
48
- dom_menu_order.textContent = new_pos[key];
49
- }
50
- }
51
- }
52
-
53
- if ( changes.next ) {
54
- jQuery.post( ajaxurl, {
55
- action: 'simple_page_ordering',
56
- id: changes.next['id'],
57
- previd: changes.next['previd'],
58
- nextid: changes.next['nextid'],
59
- start: changes.next['start'],
60
- _wpnonce: simple_page_ordering_localized_data._wpnonce,
61
- screen_id: simple_page_ordering_localized_data.screen_id,
62
- excluded: JSON.stringify( changes.next['excluded'] )
63
- }, update_simple_ordering_callback );
64
- } else {
65
- jQuery('.spo-updating-row').removeClass('spo-updating-row').find('.check-column').removeClass('spinner is-active');
66
- sortable_post_table.removeClass('spo-updating').sortable('enable');
67
- }
68
- }
69
-
70
- var sortable_post_table = jQuery(".wp-list-table tbody");
71
- sortable_post_table.sortable({
72
- items: '> tr',
73
- cursor: 'move',
74
- axis: 'y',
75
- containment: 'table.widefat',
76
- cancel: 'input, textarea, button, select, option, .inline-edit-row',
77
- distance: 2,
78
- opacity: .8,
79
- tolerance: 'pointer',
80
- create: function() {
81
- jQuery( document ).keydown(function(e) {
82
- var key = e.key || e.keyCode;
83
- if ( 'Escape' === key || 'Esc' === key || 27 === key ) {
84
- sortable_post_table.sortable( 'option', 'preventUpdate', true );
85
- sortable_post_table.sortable( 'cancel' );
86
- }
87
- });
88
- },
89
- start: function(e, ui){
90
- if ( typeof(inlineEditPost) !== 'undefined' ) {
91
- inlineEditPost.revert();
92
- }
93
- ui.placeholder.height(ui.item.height());
94
- ui.placeholder.empty();
95
- },
96
- helper: function(e, ui) {
97
- var children = ui.children();
98
- for ( var i=0; i<children.length; i++ ) {
99
- var selector = jQuery(children[i]);
100
- selector.width( selector.width() );
101
- };
102
- return ui;
103
- },
104
- stop: function(e, ui) {
105
- if ( sortable_post_table.sortable( 'option', 'preventUpdate') ) {
106
- sortable_post_table.sortable( 'option', 'preventUpdate', false );
107
- }
108
-
109
- // remove fixed widths
110
- ui.item.children().css('width','');
111
- },
112
- update: function(e, ui) {
113
- if ( sortable_post_table.sortable( 'option', 'preventUpdate') ) {
114
- sortable_post_table.sortable( 'option', 'preventUpdate', false );
115
- return;
116
- }
117
-
118
- sortable_post_table.sortable('disable').addClass('spo-updating');
119
- ui.item.addClass('spo-updating-row');
120
- ui.item.find('.check-column').addClass('spinner is-active');
121
-
122
- var postid = ui.item[0].id.substr(5); // post id
123
-
124
- var prevpostid = false;
125
- var prevpost = ui.item.prev();
126
- if ( prevpost.length > 0 ) {
127
- prevpostid = prevpost.attr('id').substr(5);
128
- }
129
-
130
- var nextpostid = false;
131
- var nextpost = ui.item.next();
132
- if ( nextpost.length > 0 ) {
133
- nextpostid = nextpost.attr('id').substr(5);
134
- }
135
-
136
- // go do the sorting stuff via ajax
137
- jQuery.post( ajaxurl, { action: 'simple_page_ordering', id: postid, previd: prevpostid, nextid: nextpostid, _wpnonce: simple_page_ordering_localized_data._wpnonce, screen_id: simple_page_ordering_localized_data.screen_id, }, update_simple_ordering_callback );
138
-
139
- // fix cell colors
140
- var table_rows = document.querySelectorAll('tr.iedit'),
141
- table_row_count = table_rows.length;
142
- while( table_row_count-- ) {
143
- if ( 0 === table_row_count%2 ) {
144
- jQuery(table_rows[table_row_count]).addClass('alternate');
145
- } else {
146
- jQuery(table_rows[table_row_count]).removeClass('alternate');
147
- }
148
- }
149
- }
150
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dist/css/simple-page-ordering.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-list-table .ui-sortable tr{cursor:move}.wp-list-table .ui-sortable tr.inline-editor{cursor:default}.wp-list-table .spo-updating tr{cursor:default}.wp-list-table .ui-sortable-placeholder{outline:1px dashed #bbb;background:#f1f1f1;visibility:visible !important}.wp-list-table .ui-sortable-helper{background-color:#fff;outline:1px solid #e1e1e1}.spo-updating-row .check-column{display:table-cell;float:none;margin:0;background-position:9px 9px}.spo-updating-row .check-column input{visibility:hidden}
dist/js/simple-page-ordering.asset.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php return array('dependencies' => array('jquery', 'jquery-ui-sortable'), 'version' => 'abf1d95e6c2b031b104a');
dist/js/simple-page-ordering.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(){"use strict";window["jquery-ui-sortable"],window.jQuery;function e(n){if("children"!==n){var r=jQuery.parseJSON(n),i=r.new_pos;for(var a in i)if("next"!==a){var o=document.getElementById("inline_"+a);if(null!==o&&i.hasOwnProperty(a)){var l=o.querySelector(".menu_order");if(void 0!==i[a].menu_order){null!==l&&(l.textContent=i[a].menu_order);var d=o.querySelector(".post_parent");null!==d&&(d.textContent=i[a].post_parent);var s=null,p=o.querySelector(".post_title");null!==p&&(s=p.innerHTML);for(var c=0;c<i[a].depth;)s="&mdash; "+s,c++;var u=o.parentNode.querySelector(".row-title");if(null!==u&&null!==s){var _=document.createElement("textarea");_.innerHTML=s,u.textContent=_.value}}else null!==l&&(l.textContent=i[a])}}r.next?jQuery.post(ajaxurl,{action:"simple_page_ordering",id:r.next.id,previd:r.next.previd,nextid:r.next.nextid,start:r.next.start,_wpnonce:simple_page_ordering_localized_data._wpnonce,screen_id:simple_page_ordering_localized_data.screen_id,excluded:JSON.stringify(r.next.excluded)},e):(jQuery(".spo-updating-row").removeClass("spo-updating-row").find(".check-column").removeClass("spinner is-active"),t.removeClass("spo-updating").sortable("enable"))}else window.location.reload()}var t=jQuery(".wp-list-table tbody");t.sortable({items:"> tr",cursor:"move",axis:"y",containment:"table.widefat",cancel:"input, textarea, button, select, option, .inline-edit-row",distance:2,opacity:.8,tolerance:"pointer",create:function(){jQuery(document).keydown((function(e){var n=e.key||e.keyCode;"Escape"!==n&&"Esc"!==n&&27!==n||(t.sortable("option","preventUpdate",!0),t.sortable("cancel"))}))},start:function(e,t){"undefined"!==typeof inlineEditPost&&inlineEditPost.revert(),t.placeholder.height(t.item.height()),t.placeholder.empty()},helper:function(e,t){for(var n=t.children(),r=0;r<n.length;r++){var i=jQuery(n[r]);i.width(i.width())}return t},stop:function(e,n){t.sortable("option","preventUpdate")&&t.sortable("option","preventUpdate",!1),n.item.children().css("width","")},update:function(n,r){if(t.sortable("option","preventUpdate"))t.sortable("option","preventUpdate",!1);else{t.sortable("disable").addClass("spo-updating"),r.item.addClass("spo-updating-row"),r.item.find(".check-column").addClass("spinner is-active");var i=r.item[0].id.substr(5),a=!1,o=r.item.prev();o.length>0&&(a=o.attr("id").substr(5));var l=!1,d=r.item.next();d.length>0&&(l=d.attr("id").substr(5)),jQuery.post(ajaxurl,{action:"simple_page_ordering",id:i,previd:a,nextid:l,_wpnonce:simple_page_ordering_localized_data._wpnonce,screen_id:simple_page_ordering_localized_data.screen_id},e);for(var s=document.querySelectorAll("tr.iedit"),p=s.length;p--;)0===p%2?jQuery(s[p]).addClass("alternate"):jQuery(s[p]).removeClass("alternate")}}})}();
localization/simple-page-ordering.pot ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2022 Jake Goldman, 10up
2
+ # This file is distributed under the GPLv2 or later.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Simple Page Ordering 2.4.2\n"
6
+ "Report-Msgid-Bugs-To: "
7
+ "https://wordpress.org/support/plugin/simple-page-ordering\n"
8
+ "POT-Creation-Date: 2022-09-28 16:13:24+00:00\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=utf-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "X-Generator: node-wp-i18n 1.2.6\n"
16
+
17
+ #: simple-page-ordering.php:143
18
+ msgid ""
19
+ "It looks like you are using a development copy of <strong>Simple Page "
20
+ "Ordering</strong>. Please run <code>npm i; npm run build</code> to create "
21
+ "assets."
22
+ msgstr ""
23
+
24
+ #: simple-page-ordering.php:161
25
+ msgid ""
26
+ "To reposition an item, simply drag and drop the row by \"clicking and "
27
+ "holding\" it anywhere (outside of the links and form controls) and moving "
28
+ "it to its new position."
29
+ msgstr ""
30
+
31
+ #: simple-page-ordering.php:226 simple-page-ordering.php:501
32
+ msgid "Missing mandatory parameters."
33
+ msgstr ""
34
+
35
+ #: simple-page-ordering.php:424
36
+ msgid "Sort by Order"
37
+ msgstr ""
38
+
39
+ #: simple-page-ordering.php:456
40
+ msgid "Post ID."
41
+ msgstr ""
42
+
43
+ #: simple-page-ordering.php:461
44
+ msgid "Previous post ID"
45
+ msgstr ""
46
+
47
+ #: simple-page-ordering.php:466
48
+ msgid "Next post ID"
49
+ msgstr ""
50
+
51
+ #: simple-page-ordering.php:472
52
+ msgid "Start index"
53
+ msgstr ""
54
+
55
+ #: simple-page-ordering.php:478
56
+ msgid "Array of excluded post IDs"
57
+ msgstr ""
58
+
59
+ #. Plugin Name of the plugin/theme
60
+ msgid "Simple Page Ordering"
61
+ msgstr ""
62
+
63
+ #. Plugin URI of the plugin/theme
64
+ msgid "http://10up.com/plugins/simple-page-ordering-wordpress/"
65
+ msgstr ""
66
+
67
+ #. Description of the plugin/theme
68
+ msgid ""
69
+ "Order your pages and hierarchical post types using drag and drop on the "
70
+ "built in page list. For further instructions, open the \"Help\" tab on the "
71
+ "Pages screen."
72
+ msgstr ""
73
+
74
+ #. Author of the plugin/theme
75
+ msgid "Jake Goldman, 10up"
76
+ msgstr ""
77
+
78
+ #. Author URI of the plugin/theme
79
+ msgid "https://10up.com"
80
+ msgstr ""
readme.txt CHANGED
@@ -4,11 +4,11 @@ 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: 6.0
7
- Stable tag: 2.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
12
 
13
  == Description ==
14
 
@@ -42,13 +42,11 @@ Generic posts are not displayed by menu order - they're displayed by chronology.
42
 
43
  = Can I make my custom post type take advantage of this plug-in? =
44
 
45
- Yep. There are two ways to turn on support for Simple Page Ordering.
46
 
47
- Ideally, when you register the post type, set `hierarchical` to `true` - hierarchical post types natively order by menu order.
48
 
49
- 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.
50
-
51
- 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.
52
 
53
  = I want my non-hierarchical post type to be sortable. Help! =
54
 
@@ -87,6 +85,10 @@ add_filter( 'simple_page_ordering_is_sortable', function( $sortable, $post_type
87
  }, 10, 2 );
88
  `
89
 
 
 
 
 
90
  == Screenshots ==
91
 
92
  1. Dragging the page to its new position
@@ -94,6 +96,10 @@ add_filter( 'simple_page_ordering_is_sortable', function( $sortable, $post_type
94
 
95
  == Changelog ==
96
 
 
 
 
 
97
  = 2.4.1 - 2022-06-21 =
98
  * **Added:** Missing text domain to strings (props [@kebbet](https://github.com/kebbet), [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul) via [#92](https://github.com/10up/simple-page-ordering/pull/92).
99
  * **Fixed:** Condition in REST page sorting logic in `rest_page_ordering` method (props [@szepeviktor](https://github.com/szepeviktor), [@iamdharmesh](https://github.com/iamdharmesh) via [#94](https://github.com/10up/simple-page-ordering/pull/94).
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: 6.0
7
+ Stable tag: 2.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Order your pages and other custom post types that support "page-attributes" with simple drag and drop right from the standard page list.
12
 
13
  == Description ==
14
 
42
 
43
  = Can I make my custom post type take advantage of this plug-in? =
44
 
45
+ Yep. When you register the post type, include the `page-attributes` feature in the support list. 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
+ `'supports' => array( 'title', 'editor', 'page-attributes' ),`
48
 
49
+ You can also 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.
 
 
50
 
51
  = I want my non-hierarchical post type to be sortable. Help! =
52
 
85
  }, 10, 2 );
86
  `
87
 
88
+ = Can I use REST to order posts? =
89
+
90
+ Yes. The plugin registers the REST endpoint `simple-page-ordering/v1/page_ordering`.
91
+
92
  == Screenshots ==
93
 
94
  1. Dragging the page to its new position
96
 
97
  == Changelog ==
98
 
99
+ = 2.4.2 - 2022-09-28 =
100
+ * **Changed:** Replaced our Grunt build process with `10up-toolkit` (props [@cadic](https://github.com/cadic), [@peterwilsoncc](https://github.com/peterwilsoncc), [@dinhtungdu](https://github.com/dinhtungdu) via [#97](https://github.com/10up/simple-page-ordering/pull/97).
101
+ * **Fixed:** Disable reordering for CPTs that don't support `page-attributes` (props [@dhanendran](https://github.com/dhanendran), [@dinhtungdu](https://github.com/dinhtungdu), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#103](https://github.com/10up/simple-page-ordering/pull/103).
102
+
103
  = 2.4.1 - 2022-06-21 =
104
  * **Added:** Missing text domain to strings (props [@kebbet](https://github.com/kebbet), [@dkotter](https://github.com/dkotter), [@jeffpaul](https://github.com/jeffpaul) via [#92](https://github.com/10up/simple-page-ordering/pull/92).
105
  * **Fixed:** Condition in REST page sorting logic in `rest_page_ordering` method (props [@szepeviktor](https://github.com/szepeviktor), [@iamdharmesh](https://github.com/iamdharmesh) via [#94](https://github.com/10up/simple-page-ordering/pull/94).
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.4.1
7
  * Requires at least: 3.8
8
  * Author: Jake Goldman, 10up
9
  * Author URI: https://10up.com
@@ -15,7 +15,7 @@
15
  */
16
 
17
  // Useful global constants.
18
- define( 'SIMPLE_PAGE_ORDERING_VERSION', '2.4.0' );
19
 
20
  if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
21
 
@@ -65,6 +65,17 @@ if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
65
  load_plugin_textdomain( 'simple-page-ordering', false, dirname( plugin_basename( __FILE__ ) ) . '/localization/' );
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Load up page ordering scripts for the edit screen
70
  */
@@ -73,8 +84,7 @@ if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
73
  $post_type = $screen->post_type;
74
 
75
  // is post type sortable?
76
- $sortable = ( post_type_supports( $post_type, 'page-attributes' ) || is_post_type_hierarchical( $post_type ) ); // check permission
77
- $sortable = apply_filters( 'simple_page_ordering_is_sortable', $sortable, $post_type );
78
  if ( ! $sortable ) {
79
  return;
80
  }
@@ -103,18 +113,39 @@ if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
103
  $orderby = get_query_var( 'orderby' );
104
  $screen = get_current_screen();
105
  if ( ( is_string( $orderby ) && 0 === strpos( $orderby, 'menu_order' ) ) || ( isset( $orderby['menu_order'] ) && 'ASC' === $orderby['menu_order'] ) ) {
106
- $script_name = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '/assets/js/src/simple-page-ordering.js' : '/assets/js/simple-page-ordering.min.js';
107
- wp_enqueue_script( 'simple-page-ordering', plugins_url( $script_name, __FILE__ ), array( 'jquery-ui-sortable' ), '2.1', true );
108
- wp_localize_script(
109
- 'simple-page-ordering',
110
- 'simple_page_ordering_localized_data',
111
- array(
112
- '_wpnonce' => wp_create_nonce( 'simple-page-ordering_' . $screen->id ),
113
- 'screen_id' => (string) $screen->id,
114
- )
115
- );
116
 
117
- wp_enqueue_style( 'simple-page-ordering', plugins_url( '/assets/css/simple-page-ordering.css', __FILE__ ), [], SIMPLE_PAGE_ORDERING_VERSION );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
  }
120
 
@@ -385,7 +416,8 @@ if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
385
  public static function sort_by_order_link( $views ) {
386
  $class = ( get_query_var( 'orderby' ) === 'menu_order title' ) ? 'current' : '';
387
  $query_string = remove_query_arg( array( 'orderby', 'order' ) );
388
- if ( ! is_post_type_hierarchical( get_post_type() ) ) {
 
389
  $query_string = add_query_arg( 'orderby', 'menu_order title', $query_string );
390
  $query_string = add_query_arg( 'order', 'asc', $query_string );
391
  }
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.4.2
7
  * Requires at least: 3.8
8
  * Author: Jake Goldman, 10up
9
  * Author URI: https://10up.com
15
  */
16
 
17
  // Useful global constants.
18
+ define( 'SIMPLE_PAGE_ORDERING_VERSION', '2.4.2' );
19
 
20
  if ( ! class_exists( 'Simple_Page_Ordering' ) ) :
21
 
65
  load_plugin_textdomain( 'simple-page-ordering', false, dirname( plugin_basename( __FILE__ ) ) . '/localization/' );
66
  }
67
 
68
+ /**
69
+ * Determine whether given post type is sortable or not.
70
+ *
71
+ * @param string $post_type Post type to check.
72
+ *
73
+ * @return boolean
74
+ */
75
+ private static function is_post_type_sortable( $post_type = 'post' ) {
76
+ return apply_filters( 'simple_page_ordering_is_sortable', post_type_supports( $post_type, 'page-attributes' ), $post_type );
77
+ }
78
+
79
  /**
80
  * Load up page ordering scripts for the edit screen
81
  */
84
  $post_type = $screen->post_type;
85
 
86
  // is post type sortable?
87
+ $sortable = self::is_post_type_sortable( $post_type );
 
88
  if ( ! $sortable ) {
89
  return;
90
  }
113
  $orderby = get_query_var( 'orderby' );
114
  $screen = get_current_screen();
115
  if ( ( is_string( $orderby ) && 0 === strpos( $orderby, 'menu_order' ) ) || ( isset( $orderby['menu_order'] ) && 'ASC' === $orderby['menu_order'] ) ) {
 
 
 
 
 
 
 
 
 
 
116
 
117
+ $script_name = 'dist/js/simple-page-ordering.js';
118
+ $script_asset_path = plugin_dir_path( __FILE__ ) . 'dist/js/simple-page-ordering.asset.php';
119
+ $script_asset = file_exists( $script_asset_path )
120
+ ? require $script_asset_path
121
+ : false;
122
+
123
+ if ( false !== $script_asset ) {
124
+ $script_url = plugins_url( $script_name, __FILE__ );
125
+ wp_enqueue_script( 'simple-page-ordering', $script_url, $script_asset['dependencies'], $script_asset['version'], true );
126
+
127
+ wp_localize_script(
128
+ 'simple-page-ordering',
129
+ 'simple_page_ordering_localized_data',
130
+ array(
131
+ '_wpnonce' => wp_create_nonce( 'simple-page-ordering_' . $screen->id ),
132
+ 'screen_id' => (string) $screen->id,
133
+ )
134
+ );
135
+
136
+ wp_enqueue_style( 'simple-page-ordering', plugins_url( '/dist/css/simple-page-ordering.css', __FILE__ ), [], $script_asset['version'] );
137
+ } else {
138
+ add_action(
139
+ 'admin_notices',
140
+ function () {
141
+ ?>
142
+ <div class="notice notice-warning is-dismissible">
143
+ <p><?php echo wp_kses_post( __( 'It looks like you are using a development copy of <strong>Simple Page Ordering</strong>. Please run <code>npm i; npm run build</code> to create assets.', 'simple-page-ordering' ) ); ?></p>
144
+ </div>
145
+ <?php
146
+ }
147
+ );
148
+ }
149
  }
150
  }
151
 
416
  public static function sort_by_order_link( $views ) {
417
  $class = ( get_query_var( 'orderby' ) === 'menu_order title' ) ? 'current' : '';
418
  $query_string = remove_query_arg( array( 'orderby', 'order' ) );
419
+ $sortable = self::is_post_type_sortable( get_post_type() );
420
+ if ( $sortable ) {
421
  $query_string = add_query_arg( 'orderby', 'menu_order title', $query_string );
422
  $query_string = add_query_arg( 'order', 'asc', $query_string );
423
  }