Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 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 9 years ago.
template-tags.php.2.diff (920 bytes) - added by WordPressor.ru 9 years ago.
both twentyfourteen_post_thumbnail and twentyfourteen_categorized_blog are pluggable

Download all attachments as: .zip

Change History (12)

#1 @philiparthurmoore
9 years ago

Hi! Just a note about why twentyfourteen_categorized_blog doesn't have a function_exists around it. You will see below that the code that uses this function is as follows:

/**
 * Flush out the transients used in twentyfourteen_categorized_blog.
 *
 * @since Twenty Fourteen 1.0
 */
function twentyfourteen_category_transient_flusher() {
	// Like, beat it. Dig?
	delete_transient( 'twentyfourteen_category_count' );
}
add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' );
add_action( 'save_post',     'twentyfourteen_category_transient_flusher' );

Making that function pluggable is somewhat redundant. If someone doesn't want to use it then he can remove the action from save_post and edit_category, thus there's no need for the function check.

Version 0, edited 9 years ago by philiparthurmoore (next)

#2 @SergeyBiryukov
9 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
9 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
9 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
9 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
9 years ago

both twentyfourteen_post_thumbnail and twentyfourteen_categorized_blog are pluggable

#6 follow-up: @WordPressor.ru
9 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
9 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
9 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
9 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
9 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.