Skip to content

Instantly share code, notes, and snippets.

@joshuafredrickson
Forked from bitfade/gist:4555047
Last active August 29, 2015 14:25
Show Gist options
  • Save joshuafredrickson/dc1b469f34908a8b7da1 to your computer and use it in GitHub Desktop.
Save joshuafredrickson/dc1b469f34908a8b7da1 to your computer and use it in GitHub Desktop.

Revisions

  1. joshuafredrickson renamed this gist Jul 19, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. joshuafredrickson revised this gist Jul 19, 2015. 1 changed file with 12 additions and 16 deletions.
    28 changes: 12 additions & 16 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,14 @@
    <?php

    add_filter("the_content", "the_content_filter");

    function the_content_filter($content) {

    // array of custom shortcodes requiring the fix
    $block = join("|",array("col","shortcode2","shortcode3"));

    // opening tag
    $rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
    // Remove empty p tags for custom shortcodes
    add_filter('the_content', 'op_content_filter');
    function op_content_filter($content) {
    // array of custom shortcodes requiring the fix
    $block = join('|',array('shortcode1'));

    // opening tag
    $rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);

    // closing tag
    $rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);

    return $rep;
    // closing tag
    $rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);

    }
    return $rep;
    }
  3. @bitfade bitfade revised this gist Jan 17, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php

    add_filter("the_content", "the_content_filter));
    add_filter("the_content", "the_content_filter");

    function the_content_filter($content) {

  4. @bitfade bitfade revised this gist Jan 17, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    <?php

    add_filter("the_content", "the_content_filter));
    function the_content_filter($content) {
  5. @bitfade bitfade created this gist Jan 17, 2013.
    16 changes: 16 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    add_filter("the_content", "the_content_filter));

    function the_content_filter($content) {

    // array of custom shortcodes requiring the fix
    $block = join("|",array("col","shortcode2","shortcode3"));

    // opening tag
    $rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);

    // closing tag
    $rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);

    return $rep;

    }