capital_P_dangit()WP 3.0.0

Replaces the incorrectly written letter "p" in the middle of the word WordPress (it should be written with a capital P in the middle).

The function is used in filters: the_content, the_title, comment_text, wp_title:

// from the file /wp-includes/default-filters.php
foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter )
	add_filter( $filter, 'capital_P_dangit', 11 );
add_filter( 'comment_text', 'capital_P_dangit', 31 );

No Hooks.

Returns

String. Filtered text.

Usage

capital_P_dangit( $text );
$text(string) (required)
Text in which all words WordPress need to be corrected.

Examples

0

#1 Auto-correct wordpress in text

$text = 'I do not know how to spell Wordpress';
echo capital_P_dangit( $text );

// Returns: I do not know how to spell WordPress
0

#2 Removing standard filters

If you don't want wordpress words to be automatically corrected in your texts, then disable the filters this way:

remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'wp_title', 'capital_P_dangit', 11 );
remove_filter( 'comment_text', 'capital_P_dangit', 31 );

Changelog

Since 3.0.0 Introduced.

capital_P_dangit() code WP 6.9

function capital_P_dangit( $text ) {
	// Simple replacement for titles.
	$current_filter = current_filter();
	if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
		return str_replace( 'Wordpress', 'WordPress', $text );
	}
	// Still here? Use the more judicious replacement.
	static $dblq = false;
	if ( false === $dblq ) {
		$dblq = _x( '“', 'opening curly double quote' );
	}
	return str_replace(
		array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
		array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
		$text
	);
}