From 57deb5ec03b1bc3515b40b09a9de8d217a20f76d Mon Sep 17 00:00:00 2001 From: markjaquith Date: Thu, 8 Jul 2010 19:35:29 +0000 Subject: [PATCH] More judicious Wordpress-to-WordPress correction, to avoid bungling reasonable URLs. fixes #13971 git-svn-id: http://svn.automattic.com/wordpress/trunk@15377 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 2 +- wp-includes/formatting.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index d3f5fc0c2e..c2b5216bbf 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -88,7 +88,7 @@ foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', // Format WordPress foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $filter ) - add_filter( $filter, 'capital_P_dangit' ); + add_filter( $filter, 'capital_P_dangit', 11 ); // Format titles foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index b20fb6c077..58c826f903 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -2825,8 +2825,20 @@ function sanitize_text_field($str) { * * @since 3.0.0 */ + function capital_P_dangit( $text ) { - return str_replace( 'Wordpress', 'WordPress', $text ); + // Simple replacement for titles + if ( 'the_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 quote'); + return str_replace( + array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), + array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), + $text ); + } ?>