0

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>

11
  • 1
    Please add the conflicting code/output directly to the question. Commented Oct 22, 2013 at 12:44
  • Thank you for the guidance Chip - post edited. Hope it is what you need.
    – Paul Brown
    Commented Oct 22, 2013 at 12:52
  • That helps. What is the Plugin itself doing to filter the post title? Commented Oct 22, 2013 at 12:57
  • Do you also have QTranslate installed? If so, what happens when you disable it?
    – s_ha_dum
    Commented Oct 22, 2013 at 13:33
  • No I've never installed QTranslate and I can't see it came as part of my theme.
    – Paul Brown
    Commented Oct 22, 2013 at 13:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.