Skip to content

Conflict With "Child Page List" And "Code Highlighter" Style Plugins

Published On:
Jul 13, 2015
Last Updated:
Jul 13, 2015

Certain pages around this website where not displaying source code correctly. I was using Crayon Syntax Highlighter to style the code. Instead of nicely formatted code like this:

Code displaying correctly.

I was left with Crayon shortcodes in the form

Code displaying incorrectly because of a bug with the SB Child List plugin.

It seemed that shortcodes with the form [crayon-55a318c46df22443583779/] were somehow not being processed (it might be that all shortcodes were not being processed, I did not test any others).

After about 5 long hours I managed to hunt down the cause, this single line in wp-content/plugins/sb_child_list.php (line 352 in the sb_cl_render_child_list() function):

$template = str_replace('[post_excerpt]', sb_cl_get_the_excerpt($p->ID), $template);

If this line of code happened to be called on a particular page because I had used the [sb_child_list] shortcode, and it had added links to child pages which hadn’t had manual excerpts added, this would stop Crayon Syntax Highlighter code blocks from rendering correctly further down the page (leaving me with text like [crayon-55a318c46df22443583779/] as explained above).

I tested all this on a development server with a fresh install of Wordpress and just these two plugins installed, so that rules out any older version incompatibilities or other plugin interaction issues.

I could comment out that perpetrating line in sb_child_list.php, but then page excerpts would not be rendered correctly. So the current workaround is to make sure that all pages have a manual excerpt added (this problem doesn’t occur if the child pages have manual excerpts.

I have opened an issue on the SB Child List’s GitHub repository.

Note: This issue also occurs when using a different code highlighter, and/or a different child pages list plugin (there a quite a few out there)! Suggesting that it may not be a bug specific to SB Child List.