• I use wp-Typography on my site and it makes a mess of CMS Tree Page View titles. The typography plugin inserts all sorts of spans into text with filters. Unfortunately, since CMS Tree Page View uses get_the_title() to grab the page titles, I end up with nearly illegible titles. I’m not sure why you think it is important that the titles be processed since you later do an esc_html() to make sure the results of that processing are not used. I would recommend just replacing the get_the_title with a grab of the post_title unprocessed. Here’s how I fixed it for my use:

    $title = $onePage->post_title;

    …instead of…

    $title = get_the_title($onePage->ID); // so hooks and stuff will do their work

    I hope this can make it into an update some day!

    http://wordpress.org/extend/plugins/cms-tree-page-view/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Eric

    (@eceleste)

    This is a very simple problem to fix, but a few revisions have now come and gone without any action. Is there a reason this will NOT be done? I note that other parts of the WordPress dashboard which display these titles do not use get_the_title and so do not suffer from this problem (see the regular title list, for example).

    Why must CMS Tree Page View be different?

    It would be a big help if this could be fixed in the actual plugin so that I didn’t have to patch my copy after each upgrade. Thanks!

    Plugin Author eskapism

    (@eskapism)

    Thanks for reminding me about this.

    I want to keep using get_the_title() because other plugins depend on it (for example some translation plugins do output html comments otherwise).

    I have however made another fix to overcome this in CMS Tree Page View. Please try version 1.2.9 and let me know if it works better!

    Thread Starter Eric

    (@eceleste)

    Nope, 1.2.9 does not fix the problem with wp-Typography.

    Here’s what it looks like with get_the_title() http://imgur.com/Cr2B85o

    And here it is in the regular page list http://imgur.com/pGz8dnR

    The point is that the HTML output is not being properly rendered anyway, so get_the_title() is not helping other plugins anyway. If it were being rendered as HTML that would be fine, but it is being output as text.

    It is better to ignore the HTML than to output it as text, and it is more consistent with the rest of the WordPress dashboard, which does the same thing.

    Thread Starter Eric

    (@eceleste)

    Just took a moment for a deeper look.

    It appears that the problem really is a few lines further along: $title = esc_html($title);

    If you compare this with the _draft_or_post_title() function in /wp-admin/includes/template.php (which is called to fill in regular title lists) you see the difference is that you escape HTML and WP does not.

    However, if I try to comment out your esc_html() then CMS Tree Page View hangs with an eternal “Loading…” indicator.

    Since you are escaping the HTML anyway, I’m not sure how using get_the_title() is helping plugins that ship HTML. But I also don’t know why this plugin hangs when the HTML is not escaped.

    Also, note, if you do find out how to allow the HTML through, as WP does, then you should probably change the "<Untitled page>" to (no title) as used by WP so that the angle brackets don’t make the text disappear. This would also be more like the rest of WP and avoid the issue that sometimes these are not “pages” but other content types.

    Thread Starter Eric

    (@eceleste)

    Ah! Getting closer… you use esc_html() because you want to sanitize the string for inclusion in the JSON block later. But then, when you bring it out of JSON in the JavaScript for display, you do not reconstitute the HTML. There must be another way…

    Thread Starter Eric

    (@eceleste)

    I think I have the fix you need, Pär…

    In your functions.php remove line 1255 (the esc_html() line).

    Make line 1325:

    "title": <?php echo json_encode($title) ?>,

    Make line 1355:

    "post_title": <?php echo json_encode($title) ?>

    Note the elimination of a set of quotes in 1325 and 1355 since json_encode() provides those quotes.

    Oh, and to keep the ‘no title’ case visible, replace line 1253 with:

    $title = __('(no title)', 'cms-tree-page-view');

    The plugin could probably be simplified by just constructing the whole array of values in PHP and then using json_encode() around the whole array to build the JSON. This might even fix other lurking problems. But for now, replacing esc_html() with json_encode() this way will do the trick!

    Plugin Author eskapism

    (@eskapism)

    Thanks eceleste for digging into this problem a bit more.

    I made your suggested changes and they seem to work fine. QTranslate and other plugins that modify the title works since the get_the_title is still being used, and using json_encode seems to make it work with wp-Typography.

    Submitting new version now, please try it and let me know if it works!

    Thread Starter Eric

    (@eceleste)

    Oops, Pär, I didn’t catch this note till now. Thanks so much for implementing this fix! Yes, it is working just fine.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘HTML in Titles’ is closed to new replies.