Opened 7 years ago

Closed 7 years ago

#2789 closed enhancement (fixed)

wporg-developer theme: pass $post when applying 'get_the_excerpt' filter

Reported by: pbiron's profile pbiron Owned by: ocean90's profile ocean90
Milestone: Priority: normal
Component: Developer Hub Keywords: has-patch


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.

Attachments (1)

2789.patch (1.5 KB) - added by SergeyBiryukov 7 years ago.

Download all attachments as: .zip

Change History (4)

7 years ago

#1 @SergeyBiryukov
7 years ago

  • Keywords has-patch added

#2 @pbiron
7 years ago

thanx for the patch. I was going to mention the call in inc/template-tags.php as well, but thought it was less important...since in that case the post whose excerpt is being filtered is the current post.

#3 @ocean90
7 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 5433: Pass $post argument to the get_the_excerpt filter.

Props pbiron, SergeyBiryukov.
Fixes #2789.

Note: See TracTickets for help on using tickets.