Skip to content

Instantly share code, notes, and snippets.

@lukecav
Last active November 8, 2016 22:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/73df75b6a3c10e5a4549c757b02f2046 to your computer and use it in GitHub Desktop.
Save lukecav/73df75b6a3c10e5a4549c757b02f2046 to your computer and use it in GitHub Desktop.
capital_C_dangit - Forever eliminate "Woocommerce" from the planet (or at least the little bit we can influence)
/**
* Forever eliminate "Woocommerce" from the planet (or at least the little bit we can influence).
*
* Violating our coding standards for a good function name.
*
* @since 2.7.0
*
* @staticvar string|false $dblq
*
* @param string $text The text to be modified.
* @return string The modified text.
*/
function capital_C_dangit( $text ) {
// Simple replacement for titles
$current_filter = current_filter();
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter )
return str_replace( 'Woocommerce', 'WooCommerce', $text );
// Still here? Use the more judicious replacement
static $dblq = false;
if ( false === $dblq ) {
$dblq = _x( '“', 'opening curly double quote' );
}
return str_replace(
array( ' Woocommerce', '‘Woocommerce', $dblq . 'Woocommerce', '>Woocommerce', '(Woocommerce' ),
array( ' WooCommerce', '‘WooCommerce', $dblq . 'WooCommerce', '>WooCommerce', '(WooCommerce' ),
$text );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment