WordPress.org

Make WordPress Core

Ticket #43040: 43040.diff

File 43040.diff, 2.1 KB (added by superdav42, 4 years ago)

Patch with fix and unit tests

  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index ce2c851bc5..9df4e9b7a8 100644
    a b function wp_basename( $path, $suffix = '' ) { 
    50785078}
    50795079
    50805080/**
    5081  * Forever eliminate "WordPress" from the planet (or at least the little bit we can influence).
     5081 * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
    50825082 *
    50835083 * Violating our coding standards for a good function name.
    50845084 *
    function capital_P_dangit( $text ) { 
    50935093        // Simple replacement for titles
    50945094        $current_filter = current_filter();
    50955095        if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
    5096                 return str_replace( 'WordPress', 'WordPress', $text );
     5096                return str_replace( 'Wordpress', 'WordPress', $text );
    50975097        }
    50985098        // Still here? Use the more judicious replacement
    50995099        static $dblq = false;
  • new file tests/phpunit/tests/formatting/CapitalPDangit.php

    diff --git a/tests/phpunit/tests/formatting/CapitalPDangit.php b/tests/phpunit/tests/formatting/CapitalPDangit.php
    new file mode 100644
    index 0000000000..27411c4cf8
    - +  
     1<?php
     2
     3/**
     4 * @group formatting
     5 */
     6class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase {
     7        function test_esc_attr_quotes() {
     8        global $wp_current_filter;
     9        $this->assertEquals('Something about WordPress', capital_P_dangit('Something about Wordpress'));
     10        $this->assertEquals('Something about (WordPress', capital_P_dangit('Something about (Wordpress'));
     11        $this->assertEquals('Something about &#8216;WordPress', capital_P_dangit('Something about &#8216;Wordpress'));
     12        $this->assertEquals('Something about &#8220;WordPress', capital_P_dangit('Something about &#8220;Wordpress'));
     13        $this->assertEquals('Something about >WordPress', capital_P_dangit('Something about >Wordpress'));
     14        $this->assertEquals('Wordpress', capital_P_dangit('Wordpress'));
     15
     16        $wp_current_filter = array('the_title');
     17        $this->assertEquals('WordPress', capital_P_dangit('Wordpress'));
     18    }
     19}