Skip to content

Instantly share code, notes, and snippets.

View Fantikerz's full-sized avatar

Ryan Hamilton Fantikerz

View GitHub Profile
@Fantikerz
Fantikerz / .gitignore
Created May 11, 2013 03:04
Web developer-centric gitignore. Tailored for a CakePHP, CodeIgniter, and Wordpress under a Sublime Text 2 workflow.
######################
## Operating System ##
######################
# Windows
Thumbs.db
Desktop.ini
# OSX
.DS_Store
@Fantikerz
Fantikerz / strip-empty-paragraphs.php
Last active June 22, 2017 06:48 — forked from ninnypants/remove-empty-p.php
WordPress' wpautop adds line breaks and empty paragraphs in some cases, especially when the first item in the post is an image. This attempts to strip those tags which may be desirable if you have special paragraph styling or have a consistently desired post format.
<?php
function remove_empty_p($content)
{
$content = force_balance_tags($content);
$return = preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
$return = preg_replace('~\s?<p>(\s|&nbsp;)+</p>\s?~', '', $return);
return $return;
}
add_filter('the_content', 'remove_empty_p', 20, 1);