capital_P_dangit() WordPress Function

The capital_P_dangit function is a simple function that forces all of your post titles to have correct capitalization. This is useful for those who often forget to capitalize their titles, or who have a lot of posts with incorrect capitalization.

capital_P_dangit( string $text ) #

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


Description

Violating our coding standards for a good function name.


Top ↑

Parameters

$text

(string)(Required)The text to be modified.


Top ↑

Return

(string) The modified text.


Top ↑

Source

File: wp-includes/formatting.php

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


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More