Skip to content

Instantly share code, notes, and snippets.

@2ndkauboy
Last active November 15, 2016 15:49
Show Gist options
  • Save 2ndkauboy/ef5c62174871a03b3787f3936662fe53 to your computer and use it in GitHub Desktop.
Save 2ndkauboy/ef5c62174871a03b3787f3936662fe53 to your computer and use it in GitHub Desktop.
<?php
/**
* Capitalize ẞ Dangit
*
* @package CapitalizeẞDangit
* @author Bernhard Kau
* @license GPLv3
*
* @wordpress-plugin
* Plugin Name: Capitalize ẞ Dangit
* Plugin URI: https://kau-boys.com
* Description: Introduces a helper function you can use to capitalize the letter ß when surrounded by capital letters
* Version: 1.0.0
* Author: Bernhard Kau
* Author URI: https://kau-boys.com
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0
*/
/**
* Capitalizes the letter ß when surrounded by capital letters
*
* @param string $text The text to be modified.
*
* @return string The modified text.
*/
function capital_ß_dangit( $text ) {
return preg_replace( '/(\p{Lu})ß(\p{Lu})?/', '$1ẞ$2', $text );
}
add_filter( 'the_content', 'capital_ß_dangit', 11 );
add_filter( 'the_title', 'capital_ß_dangit', 11 );
add_filter( 'wp_title', 'capital_ß_dangit', 11 );
add_filter( 'comment_text', 'capital_ß_dangit', 31 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment