Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25796 closed defect (bug) (fixed)

capital_P_dangit : why only 'the_title' === current_filter() ?

Reported by: tivnet's profile tivnet Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.8 Priority: normal
Severity: trivial Version:
Component: Formatting Keywords: has-patch commit
Focuses: Cc:

Description

function capital_P_dangit( $text ) { 
	// Simple replacement for titles
	if ( 'the_title' === current_filter() )
		return str_replace( 'Wordpress', 'WordPress', $text );

Just curious, why not also wp_title ?

Instead of all this, maybe just preg_replace it?

Attachments (1)

25796.diff (597 bytes) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (9)

@nacin
11 years ago

#1 follow-up: @nacin
11 years ago

This function is attached to the_content, the_title, and comment_text. Only the_title could benefit from the simple replacement. The others needed to be more judicious (as the next line of the function says). wp_title was added in 3.7, and yeah, it should have been added to the simple replacement piece. Is that what you're asking? 25796.diff

Regular expressions are significantly slower than string expressions.

#2 @SergeyBiryukov
11 years ago

I wonder if we could add it for term_name as well.

#3 in reply to: ↑ 1 @tivnet
11 years ago

  1. Replying to nacin:

    Regular expressions are significantly slower than string expressions.

What about calling _x() in the middle? Should be slow, too.

  1. 25796.diff is good
  1. Why only those boundary characters are checked: space, funny quotes, and two types of brackets?
  1. The first (simple) replace does not care for boundaries. Should it?
  1. Is completely lowercase 'wordpress' OK?
  1. Yes, I have more important things to do, sorry :-))))

#4 follow-up: @SergeyBiryukov
11 years ago

Related: [15377] (for #13971).

#5 in reply to: ↑ 4 @tivnet
11 years ago

Replying to SergeyBiryukov:

Related: [15377] (for #13971).

Got it, thanks. So, diff --> patch?

#6 @SergeyBiryukov
11 years ago

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

#7 @SergeyBiryukov
11 years ago

  • Keywords commit added

#8 @SergeyBiryukov
11 years ago

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

In 26122:

Use a simple replacement for 'wp_title' filter in capital_P_dangit(), like we do for 'the_title'.

props nacin.
fixes #25796.

Note: See TracTickets for help on using tickets.