WordPress.org

Making WordPress.org

Opened 9 months ago

Closed 9 months ago

#2789 closed enhancement (fixed)

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

Reported by: pbiron Owned by: ocean90
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.

Attachments (1)

2789.patch (1.5 KB) - added by SergeyBiryukov 9 months ago.

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
9 months ago

  • Keywords has-patch added

#2 @pbiron
9 months 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
9 months ago

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

In 5433:

developer.wordpress.org: Pass $post argument to the get_the_excerpt filter.

Props pbiron, SergeyBiryukov.
Fixes #2789.

Note: See TracTickets for help on using tickets.