Formatting: Fix capital_P_dangit() not capital P-ing, dangit.
Unfortunately, in my overzealous desire to fix all the un-capitalised Ps, [42343] capitalled some Ps that intentionally should not be capitals. This commit fixes the incorrectly capitalling of Ps, as well as including unit tests and PHPCS instructions to ensure we never capitulate to capitalisationing them again. Props superdav42. Fixes #43040. Fixes #43041. git-svn-id: https://develop.svn.wordpress.org/trunk@42429 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7f94931449
commit
9cf7385eb3
|
@ -5077,8 +5077,9 @@ function wp_basename( $path, $suffix = '' ) {
|
|||
return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.WP.CapitalPDangit.Misspelled, WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-)
|
||||
/**
|
||||
* Forever eliminate "WordPress" from the planet (or at least the little bit we can influence).
|
||||
* Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
|
||||
*
|
||||
* Violating our coding standards for a good function name.
|
||||
*
|
||||
|
@ -5093,7 +5094,7 @@ 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 );
|
||||
return str_replace( 'Wordpress', 'WordPress', $text );
|
||||
}
|
||||
// Still here? Use the more judicious replacement
|
||||
static $dblq = false;
|
||||
|
@ -5106,6 +5107,7 @@ function capital_P_dangit( $text ) {
|
|||
$text
|
||||
);
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
/**
|
||||
* Sanitize a mime type
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// phpcs:disable WordPress.WP.CapitalPDangit.Misspelled -- 🙃
|
||||
|
||||
/**
|
||||
* @group formatting
|
||||
*/
|
||||
class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase {
|
||||
function test_esc_attr_quotes() {
|
||||
global $wp_current_filter;
|
||||
$this->assertEquals( 'Something about WordPress', capital_P_dangit( 'Something about Wordpress' ) );
|
||||
$this->assertEquals( 'Something about (WordPress', capital_P_dangit( 'Something about (Wordpress' ) );
|
||||
$this->assertEquals( 'Something about ‘WordPress', capital_P_dangit( 'Something about ‘Wordpress' ) );
|
||||
$this->assertEquals( 'Something about “WordPress', capital_P_dangit( 'Something about “Wordpress' ) );
|
||||
$this->assertEquals( 'Something about >WordPress', capital_P_dangit( 'Something about >Wordpress' ) );
|
||||
$this->assertEquals( 'Wordpress', capital_P_dangit( 'Wordpress' ) );
|
||||
|
||||
$wp_current_filter = array( 'the_title' );
|
||||
$this->assertEquals( 'WordPress', capital_P_dangit( 'Wordpress' ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue