Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31374 closed defect (bug) (fixed)

Twenty Fourteen: twentyfourteen_post_thumbnail() should be pluggable

Reported by: wordpressorru's profile WordPressor.ru Owned by: lancewillett's profile lancewillett
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Bundled Theme Keywords: has-patch needs-docs
Focuses: template Cc:

Description

Hi all, this is my first.

In file wp-content/themes/twentyfourteen/inc/template-tags.php, there is missed "if ( ! function_exists(" around function twentyfourteen_post_thumbnail. So I can't redefine this function in my child theme.

I'm using WP 4.1, Twentyfourteen theme 1.3.

See my diff, hope i made it right.

Also, there are same construction missing around function twentyfourteen_categorized_blog in same template-tag.php.

Attachments (2)

template-tags.php.diff (635 bytes) - added by WordPressor.ru 10 years ago.
template-tags.php.2.diff (920 bytes) - added by WordPressor.ru 10 years ago.
both twentyfourteen_post_thumbnail and twentyfourteen_categorized_blog are pluggable

Download all attachments as: .zip

Change History (12)

#1 @philiparthurmoore
10 years ago

[Changing my comment since the original was wrong.]

Hi! Just a note about why twentyfourteen_categorized_blog doesn't have a function_exists around it. If I recall correctly there was discussion about a related issue elsewhere. The reasoning there was that the function is so specific that it doesn't need to be overridden. Reasoning may have changed since then. I'm sure others can provide better context but I wanted to chime in about why that doesn't have a function check around it.

Last edited 10 years ago by philiparthurmoore (previous) (diff)

#2 @SergeyBiryukov
10 years ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 4.2

Good catch, twentyfifteen_post_thumbnail() is pluggable in Twenty Fifteen.

Makes sense for twentyfourteen_post_thumbnail() to be pluggable too.

#3 @SergeyBiryukov
10 years ago

  • Summary changed from Missed "if ( ! function_exists(" around function twentyfourteen_post_thumbnail to Twenty Fourteen: twentyfourteen_post_thumbnail() should be pluggable

#4 @lancewillett
10 years ago

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

In 31481:

Twenty Fourteen: make twentyfourteen_post_thumbnail() pluggable.

Fixes #31374, props wordpressorru.

#5 @DrewAPicture
10 years ago

  • Keywords needs-docs added; commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'd like to have a changelog entry added to the phpDoc for this function mentioning that it was made pluggable in Twenty Fourteen 1.X

@WordPressor.ru
10 years ago

both twentyfourteen_post_thumbnail and twentyfourteen_categorized_blog are pluggable

#6 follow-up: @WordPressor.ru
10 years ago

Thank you all!
What about twentyfourteen_categorized_blog() in the same file?
I fixed them both in combined patch.

#7 in reply to: ↑ 6 @SergeyBiryukov
10 years ago

Replying to WordPressor.ru:

What about twentyfourteen_categorized_blog() in the same file?

As mentioned in comment:1, twentyfourteen_categorized_blog() seems specific and probably doesn't need to be overridden. It's not pluggable in Twenty Fifteen either.

Is there an actual use case for it to be overridden?

#8 @DrewAPicture
10 years ago

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

In 31482:

Add an entry to the changelog for twentyfourteen_post_thumbnail() noting that it was made 'pluggable'.

Fixes #31374.

#9 @WordPressor.ru
10 years ago

In my case, there is no need to display category name in post meta.
twentyfourteen_categorized_blog() in my child theme always returns false.
Perfect solution, for me at least.

#10 @SergeyBiryukov
10 years ago

Let's create a new ticket for twentyfourteen_categorized_blog() then.

A workaround:

function wp31374_override_twentyfourteen_categorized_blog() {
	return 1;
}
add_filter( 'pre_transient_twentyfourteen_category_count', 'wp31374_override_twentyfourteen_categorized_blog' );
Note: See TracTickets for help on using tickets.