Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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