Make WordPress Core

Opened 21 months ago

Last modified 13 months ago

#55978 new enhancement

Adding optional post parameter to get_the_modified_author function

Reported by: samirmalpande's profile samirmalpande Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8
Component: Posts, Post Types Keywords: has-patch dev-feedback changes-requested
Focuses: Cc:

Description

With the current implementation of the get_the_modified_author() it is not possible to use this function with the custom WP_Query loop. It takes the post ID using the get_post() which returns the global post id and there is no way to pass the ID from the custom query.

We want to add the optional post parameter in get_the_modified_author function so that we can use this function in custom loops as well.

By doing this change we also make this function follow the same standard as other "get_the_" functions like get_the_title, get_the_content, get_the_terms etc.

Attachments (1)

55978.diff (859 bytes) - added by samirmalpande 21 months ago.
Patch file

Download all attachments as: .zip

Change History (14)

@samirmalpande
21 months ago

Patch file

#1 @samirmalpande
21 months ago

  • Keywords has-patch added

#2 @johnbillion
21 months ago

  • Keywords changes-requested removed
  • Milestone changed from Awaiting Review to 6.1
  • Version changed from trunk to 2.8

Thanks for the ticket and the patch @samirmalpande 👍

#3 @SergeyBiryukov
21 months ago

Should get_the_author() get the same parameter for consistency?

It used to have an $idmode parameter, which was deprecated in [4146] / #2386. Since it only accepted a string, I think we should be able to un-deprecate and use it if an integer post ID or a WP_Post object is passed. There is a precedent for something like this, see [47366] / #48772.

#4 @samirmalpande
21 months ago

Ideally get_the_author() should also have same parameter. Since we have a precedent to un-deprecate the parameter, we should pass the $post parameter to get_the_author().

Should we create a new ticket for this or include it in the same patch?

#5 @desrosj
18 months ago

  • Keywords needs-refresh changes-requested added
  • Milestone changed from 6.1 to 6.2

@samirmalpande Could you refresh the current patch?

@SergeyBiryukov what do you think about protecting against edge cases by throwing a __doing_it_wrong() notice if the value is not an integer post ID or WP_Post object?

Since 6.1 beta 1 is due out in less than 12 hours (the cut off for enhancement and feature request tickets), I'm going to punt this one. But if a refreshed patch is added in time and a committer has bandwidth to review, it can be moved back.

This ticket was mentioned in Slack in #core by costdev. View the logs.


13 months ago

#7 @costdev
13 months ago

  • Keywords dev-feedback added; needs-refresh removed

This ticket was reviewed in the bug scrub. As the patch still applies cleanly against trunk, I'm removing the needs-refresh keyword. The changes-requested keyword is accurate. Also adding dev-feedback to draw attention to Jonathan's comment above.

#9 @audrasjb
13 months ago

  • Keywords changes-requested removed

#10 @audrasjb
13 months ago

  • Keywords changes-requested added

I added a refreshed PR but I'm re-adding the changes-requested workflow keyword since I forgot to cover other functions like get_the_author()/the_author().

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


13 months ago

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


13 months ago

#13 @mukesh27
13 months ago

  • Milestone changed from 6.2 to Future Release

Thanks @samirmalpande for the ticket.

This ticket was discussed during the bug scrub. as this ticket still needs more functions covered. 6.2 Beta 1 is being released today, I'll move this to Future Release.

Additional props: @costdev

Note: See TracTickets for help on using tickets.