Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Hamilton Fantikerz

View GitHub Profile
@Fantikerz
Fantikerz / .gitignore
Created May 11, 2013
Web developer-centric gitignore. Tailored for a CakePHP, CodeIgniter, and Wordpress under a Sublime Text 2 workflow.
View .gitignore
######################
## Operating System ##
######################
# Windows
Thumbs.db
Desktop.ini
# OSX
.DS_Store
@Fantikerz
Fantikerz / strip-empty-paragraphs.php
Last active Jun 22, 2017 — 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.
View strip-empty-paragraphs.php
<?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);