Opened 5 years ago
Last modified 3 years ago
#47555 reviewing enhancement
Add per_page filter to nav-menu.php
Reported by: | Martin Snajdr | Owned by: | audrasjb |
---|---|---|---|
Milestone: | Future Release | Priority: | low |
Severity: | normal | Version: | |
Component: | Menus | Keywords: | has-patch needs-dev-note |
Focuses: | Cc: |
Description
Right now there is a hardcoded number of posts / terms (50) displayed per page in wp-admin/includes/nav-menu.php, which might be ok for posts, but it's a nightmare when having a lot of terms (hierarchical). For example in WooCommerce, I have like 200 categories and some of those are having the same name (but different parent). When I go through the list of those categories, it's quite hard to find exactly the one I'm looking for if the parent is on previous page.
Having pagination as default is ok, but there should be a simple filter that will allow plugins / themes to change the per_page variable value (at least in wp_nav_menu_item_taxonomy_meta_box), so you could list more than 50 terms per page.
Attachments (2)
Change History (13)
#2
@
5 years ago
- Focuses administration removed
- Milestone changed from Awaiting Review to 5.3
- Owner set to audrasjb
- Priority changed from normal to low
- Status changed from new to reviewing
- Version 5.2.1 deleted
Hi, thanks for the the ticket and thaks @manishamakhija for the patch. Looks good on my side.
Moving this one for 5.3 consideration.
#3
@
5 years ago
- Keywords needs-refresh added
Hi and thanks for the patch,
There is a coding standard issue in the current patch. Refreshing.
@
5 years ago
Add nav_menu_metabox_per_page_number filter to allow developers to filter $per_page variable
#4
@
5 years ago
- Keywords 2nd-opinion added; needs-refresh removed
In 47555.1.diff
:
- Add inline documentation for
nav_menu_metabox_per_page_number
filter. - Use
absint()
function to ensure to get a proper integer.
Adding 2nd-opinion
keyword to get a second opinion on that.
Adding needs-dev-note
keyword: if this patch is released, the new filter would maybe deserve a dev-note (but not sure if we need it since this is a very small enhancement).
#5
@
5 years ago
Implementation example:
function worg_per_page_number( $per_page ) {
return 10;
}
add_filter( 'nav_menu_metabox_per_page_number', 'worg_per_page_number', 10, 3 );
#7
@
5 years ago
Right now there is a hardcoded number of posts / terms (50) displayed per page in wp-admin/includes/nav-menu.php
FWIW, this value is already filterable via get_terms_args
, see an example in #18282:
https://core.trac.wordpress.org/attachment/ticket/18282/preserve-page-and-taxonomy-hierarchy.php
A dedicated filter might still be helpful though.
Added filter for category list per page in nav menu metabox