Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#33723 closed enhancement (fixed)

Allow WP_Post on thumbnail functions

Reported by: rahe's profile Rahe Owned by: swissspidy's profile swissspidy
Milestone: 4.4 Priority: normal
Severity: normal Version: 2.9
Component: Post Thumbnails Keywords: has-patch needs-refresh
Focuses: docs Cc:

Description

Since we can put WP_Post object as argument for get_the_title() or get_permalink() it can be nice to have theses on the thumbnail functions.

Here's my patch containing the changes for handling this kind of improvements and coding standards applyed.

Attachments (6)

33723.patch (4.9 KB) - added by Rahe 10 years ago.
33723.diff (3.8 KB) - added by swissspidy 10 years ago.
33723.2.diff (2.5 KB) - added by swissspidy 10 years ago.
Adds unit tests
33723.3.diff (6.0 KB) - added by swissspidy 10 years ago.
Unit tests, now for real
33723.4.diff (7.5 KB) - added by swissspidy 10 years ago.
33723.5.diff (7.6 KB) - added by swissspidy 10 years ago.

Download all attachments as: .zip

Change History (17)

@Rahe
10 years ago

@swissspidy
10 years ago

#1 follow-up: @swissspidy
10 years ago

  • Focuses docs added
  • Keywords has-patch dev-feedback added
  • Milestone changed from Awaiting Review to 4.4

Thanks for your patch! I think this enhancements makes sense as it is more convenient for developers.

Unfortunately I wasn't able to easily apply it because of the base directory. As a tip for next time, please make sure you patch from the /src directory, so it looks like src/wp-includes/post-thumbnail-template.php in your patch.

I created 33723.diff now that does the following:

Unfortunately these functions have no unit tests. We really should add some, but maybe in a separate ticket.

#2 in reply to: ↑ 1 @DrewAPicture
10 years ago

  • Keywords needs-unit-tests added

Replying to swissspidy:

Unfortunately these functions have no unit tests. We really should add some, but maybe in a separate ticket.

Unit tests should ship with the changes here in the same ticket.

#3 @swissspidy
10 years ago

  • Owner set to swissspidy
  • Status changed from new to assigned

@swissspidy
10 years ago

Adds unit tests

#4 @swissspidy
10 years ago

  • Keywords needs-unit-tests removed

#5 @swissspidy
10 years ago

  • Keywords needs-unit-tests added

Oh noes, looks like I attached the same again by mistake.

@swissspidy
10 years ago

Unit tests, now for real

#6 @swissspidy
10 years ago

  • Keywords needs-unit-tests removed

@swissspidy
10 years ago

#7 @swissspidy
10 years ago

  • Version changed from 4.3 to 2.9

33723.4.diff improves the inline docs even more.

I'd say this could safely make it into core now, but of course a second pair of eyes would be great.

#8 @DrewAPicture
10 years ago

@swissspidy: The docs look pretty good. The only thing missing is that all of the functions that accept $post = null default to the global $post, therefore the parameter should be documented as optional, and mention that it defaults to the global $post.

@swissspidy
10 years ago

#9 @swissspidy
10 years ago

  • Keywords dev-feedback removed

All good things go by six. The new patch mentions that the global $post is the default.

#10 @wonderboymusic
10 years ago

  • Keywords needs-refresh added

I'm gonna look at this

#11 @wonderboymusic
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34167:

Update post thumbnail functions to allow a WP_Post to be passed.

Adds unit tests.

Props swissspidy, Rahe.
Fixes #33723.

Note: See TracTickets for help on using tickets.