Opened 9 years ago
Closed 9 years ago
#2789 closed enhancement (fixed)
wporg-developer theme: pass $post when applying 'get_the_excerpt' filter
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Component: | Developer Hub | Keywords: | has-patch |
| Cc: |
Description
In the current version of the wporg-developer theme (I just checked out the trunk today, as described in Devhub: Install the theme), reference/template-methods.php contains the following:
<?php if ( $excerpt = apply_filters( 'get_the_excerpt', $child->post_excerpt ) ) {
and I think it would be best to change that to:
<?php if ( $excerpt = apply_filters( 'get_the_excerpt', $child->post_excerpt, $child ) ) {
now that get_the_excerpt allows passing the post as the 2nd param.
I'm currently developing a documentation system for the plugins/themes I write (using WP-Parser and a child of wporg-developer, leveraging my user's familiarity with DevHub). Another plugin that is active as part of that documentation system also hooks into get_the_excerpt and the hooked function relies on the $post param (defaulting to the current post).
In the context in which wporg-developer applies get_the_excerpt in reference/template-methods.php, the current post is the post for the class whose method is being output. As a result, the "Methods" section of for a class in my documentation system contains the "summary" for the class as the "summary" for each method of that class.
This change is probably not strictly necessary for the use of wporg-developer on the DevHub itself. However, given that wporg-developer appears to be written to encourage folks like me to create child themes based on it (given all the uses of if (!function_exists()) in inc/template-tags.php) I think the suggested change is warranted and it would greatly easy the creation of this child theme.
thanx for the patch. I was going to mention the call in
inc/template-tags.phpas well, but thought it was less important...since in that case the post whose excerpt is being filtered is the current post.