Opened 8 years ago
Last modified 7 years ago
#39862 reopened enhancement
Track the number of children for a walker element scope
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7.2 |
Component: | Menus | Keywords: | has-patch |
Focuses: | Cc: |
Description
Unless this had been deliberately omitted for performance reasons?
A minor change to the Walker
class would provide the total number of children $this->total_children
for the current element scope from within the display_element()
function.
Currently a custom walker must be used and include an extension of display_element() for each X_Walker
class where this information is needed.
Patch attached.
This change; for example could provide information to display the number of replies to a comment in an extended template of Comment_Walker::comment()
Attachments (5)
Change History (15)
#2
@
8 years ago
@AlexGW thanks for creating this ticket and welcome to core!
I was not able to apply the patch and it seems to be formatted strangely. I have taken the liberty of creating the patch again. Can you please review to be sure it's correct?
What is your process for creating the patch?
If you're using SVN you can refer to the codex for details on creating a patch file here https://codex.wordpress.org/Using_Subversion#Saving_patch.2Fdiff_files
#4
@
8 years ago
@welcher Thanks for spotting that, the patch was created when I wasn't too familiar with creating patches. I can confirm the second patch is correct, the third is missing the initial declaration for
$this->total_children = 0
#5
@
8 years ago
- Keywords reporter-feedback removed
- Resolution set to invalid
- Status changed from new to closed
#7
@
8 years ago
- Keywords needs-refresh added; has-patch removed
@AlexGW can you regenerate the patch to add that back in?
#9
@
7 years ago
@AlexGW thanks for generating that. Just a couple of formatting things for future patches.
Please try and generate the patch the root of the repository. That way if there are any unit tests added they are in the same patch. Also, usually we keep the filenames the same for the patches so that when uploaded, the patch files are names PATH.1, .2 .3 etc. It's easier to see what the latest patch is.
I've uploaded a revised patch.
patch for class-wp-walker.php