10up / simple-page-ordering

Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
https://wordpress.org/plugins/simple-page-ordering/
GNU General Public License v2.0
149 stars 23 forks source link

Introduce feature allowing modifying parent/child relationships. #172

Closed peterwilsoncc closed 8 months ago

peterwilsoncc commented 11 months ago

Description of the Change

Adds row actions to move a page up or down the page hierarchy.

The "Move Out from under Parent Page name" action:

The "Move Under Page Name" action

At the moment this always triggers a full page refresh.

Closes #25.

How to test the Change

  1. Generate some pages with wp post generate --post_type=page
    • these pages will not have a menu_order specified
    • the tests below should work as expected without the menu_order
  2. Click the "Move Under Page Name" action of a page
  3. The post should be made a child of the preceding page in the list
  4. Click "Move Under Page Name" of the page following the page you've already edited.
  5. The second page should be made a child of the same parent
  6. Attempt to move the first page in the list in or out (you'll need to get the action to display via the CSS browser tools), ensure nothing happens to the posts parent setting.
  7. Click "Move Under Page Name" of the final child page in your tree
  8. This should be made a child of the page above it, a grandchild of the previous parent
  9. Click "Move Under Page Name" of the first child page
  10. The entire tree should be move in one. The page you clicked should become a top level page

Changelog Entry

Added - Ability to modify the page hierarchy.

Credits

Props @peterwilsoncc.

Checklist:

peterwilsoncc commented 11 months ago

Some shell commands for getting a bunch of posts with the same ID in the title as the post ID.

Warning: it empties the entire post table.

wp site empty
wp post generate --post_type=page
for i in {1..100}; do wp post update $i --post_title="Page $i"; done;

# To set menu order to the ID too
for i in {1..100}; do wp post update $i --post_title="Page $i" --menu_order=$i; done;
shannonmfisher commented 8 months ago

Hello hi!

After some noodling, I think the best option is Nest page and Un-nest page (could be nest/un-nest if the page part make it too long, but I'd leave the page part if possible to be super clear).

Make subpage is another option, but I think it's too complicated because there's no succinct opposite and because nesting it further isn't as intuitive with this command.

Rank page higher/lower could be another option, but I don't think "rank" is intuitive and it's long.

Order or level page up/down are also possibilities, but again, not as intuitive as nest.

Lmk if any of these feel right or if you'd like me to keep thinking on it!

ankitguptaindia commented 8 months ago

Hello @peterwilsoncc, I have just tested this new edition, and it works well for me. I was wondering if we could implement a similar behavior for moving in and out of pages by using drag and drop? similar to how we navigate up and down pages.

I am not familiar with the technical aspects of this change, but I wanted to share the idea and get your feedback.

I noticed a similar flow in menu ordering as well:

Screen recording (1).webm

peterwilsoncc commented 8 months ago

@ankitguptaindia I had an attempt at that but couldn't get it working in an intuitive fashion. As the pages use tables rather than lists, the jQuery UI library only expects items to move up or down, I attempted to fake it but the drop targets' behaviour wasn't great.

jeffpaul commented 8 months ago

@peterwilsoncc besides tweaking the copy, is there anything else needed here before this can move forward towards review/release?

peterwilsoncc commented 8 months ago

@jeffpaul That should do.

I'm worried un nest implies that it moves the page to the top level (ie without a parent) but I can push the change and we can get some real-world feedback and improve if required.

jeffpaul commented 8 months ago

@peterwilsoncc I'm fine with you YOLOing the decision on the copy and we can iterate as needed if there's a consensus in the community for something different

peterwilsoncc commented 8 months ago

@jeffpaul I've just pushed some changes that alter the copy to match that of the native menu pages in WordPress Core.

Screen Shot 2024-01-18 at 11 44 51 am

"Move Under Page Name" sets the page as a child of page name "Move Out from under Parent Page name" sets the page as a child of it's grandparent or top level if no grandparent exists.

I think the copy is clearer than move in/move out and matching existing core text is probably the best thing to do here.

peterwilsoncc commented 8 months ago

@faisal-alvi I've updated the description with the new link text.