In an effort to jazz up the site, TKBB has added drop caps to the first letter of every post. Usually, drop caps are manually inserted into the code via a simple CSS addition and a few characters of HTML code. The implementation either uses a span or an image. However, in the case of WordPress, it’s easier to use a plugin – in this case the Milburn Drop Caps plugin. Essentially, the plugin finds the beginning of a paragraph and inserts the CSS styling to the first character. The default is to produce a drop cap with shadow effect on posts, pages, comments, and search results of your choosing. However, despite an option to disable styling on attachments, the drop cap still shows in attachment text (such as captions) when it is marked not to. TKBB has a caption before the main text 90% of the time. Luckily, with some trial-and-error, it is possible enable functioning drop caps for such a scenario using the WordPress plugin.
$pattern = ‘/<p( .*)?()??( .*)?>((<[^>]*>|\s)*)(("|“|‘|‘|“|\’)?[A-Z])/U’;
with:
$pattern = ‘/<p>?([A-Z])/U’;
$replacement = ‘<p$1$4>$5<span title=”$7″><span>$7</span></span>’;
with:
$replacement = ‘<p class=”first-child”> <span title=”$1″><span>$1</span></span>’;
$pattern = ‘/<p>(("| |“|‘|‘|“|\’)?[A-Z])/’;
