<?php
function change_quotation_marks() {
// Content
add_filter( 'the_content' , 'alternative_quotes', 12 );
add_filter( 'the_excerpt', 'alternative_quotes', 12 );
add_filter( 'comment_text', 'alternative_quotes', 12 );
add_filter( 'widget_text', 'alternative_quotes', 12 );
function alternative_quotes( $text ) {
$use_str_replace = false;
if ( strpos( get_locale(), 'de_' ) === 0 ) {
$text = wptexturize( $text );
}
else {
return $text;
}
if (
( strpos( $text, '„' ) !== false && strpos( $text, '«' ) === false ) ||
( strpos( $text, '“' ) !== false && strpos( $text, '»' ) === false )
) {
$use_str_replace = true;
}
// Replace English curly quotes
if ( $use_str_replace ) {
$text = str_replace( '„' , '«' , $text ); // replace english curly double open
$text = str_replace( '“' , '»' , $text ); // replace english curly double close
}
return $text;
}
}
add_action( 'wp', 'change_quotation_marks' );
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎