Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

hope I've asked this correctly. Bizarre situation. I have some non-breaking spaces in my titles for typography reasons. They are added automatically where required in place of normal spaces by the following function...

// stop brackets in titles appearing on own line
function clean_orphan_titles($content){

$array = array (

   '{ ' => '{ ',

   ' }' => ' }'

);

$content = strtr($content, $array);

return $content;

}

add_filter('the_title', 'clean_orphan_titles');

The problem I have is that one plugin doesn't like this - you can see the result here http://skipology.com/temporary-test-page/ However. If I replace return $content; with return htmlspecialchars($content); the plugin output renders correctly but the rest of my site displays   instead of the space.

Can I either create a conditional situation to include both lines with one just targeted at the output of the plugin (Wordpress Popular Posts) or can I create a near duplicate function somehow triggered by the plugin?

I can't target a specific page because all pages will potentially contain this conflict.

Edit - the conflicting output is from the plugin and shows my post titles as generated by the plugin as 'iPhoneography seascape workflow – {�horizon�}' where the � is the  

Edit2 - That helps. What is the Plugin itself doing to filter the post title?

This is what I can see...

// TITLE

$title = ($this->qTrans) ? qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($p->title) : $p->title;
$title = strip_tags($title);
$title_sub = strip_tags($title);

// truncate title (section on truncating the title here - I don't use)

$title = htmlspecialchars( $title, ENT_QUOTES, $this->charset );
$title_sub = htmlspecialchars( $title_sub, ENT_QUOTES, $this->charset );
$title = apply_filters('the_title', $title, $p->id);
$title_sub = apply_filters('the_title', $title_sub, $p->id);

Specifically re character sets we have:

var $charset = "UTF-8";

and...

// set charset
$this->charset = get_bloginfo('charset');

and the SQL character set seems to be

$sql = "";
$charset_collate = "";

Edit 3 - I've just done another test and if I manually insert   into a title rather than relying on my functions.php code posted above it's rendered perfectly by the plug in. Is there something wrong with the functions.php? My source code shows the correct behaviour as does my site so I'm confused! e.g. this is the title from a post...

<h1><a href="http://skipology.com/iphone-photography-tip-extend-image-canvas-auto-clone/" title="iPhone photography tip {&nbsp;extend canvas and auto clone&nbsp;}">iPhone photography tip {&nbsp;extend canvas and auto clone&nbsp;}</a><i class="icon-file pull-right"></i></h1>

share|improve this question
1  
Please add the conflicting code/output directly to the question. –  Chip Bennett Oct 22 '13 at 12:44
    
Thank you for the guidance Chip - post edited. Hope it is what you need. –  Paul Brown Oct 22 '13 at 12:52
    
That helps. What is the Plugin itself doing to filter the post title? –  Chip Bennett Oct 22 '13 at 12:57
    
Added additional info Chip. Many thanks. –  Paul Brown Oct 22 '13 at 13:22
    
Do you also have QTranslate installed? If so, what happens when you disable it? –  s_ha_dum Oct 22 '13 at 13:33
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.