capital_P_dangit()WP 3.0.0

Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).

Violating our coding standards for a good function name.

No Hooks.

Return

String. The modified text.

Usage

capital_P_dangit( $text );
$text(string) (required)
The text to be modified.

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.4.3

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
	);
}