2 posts
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
ianmh says

Old post, but in case it helps anyone else, I’m just using the php function strip_tags.

strip_tags($content)

This only works if don’t need html formatting within your shortcodes.

3007 posts
  • Author had a File in an Envato Bundle
  • Bought between 1 and 9 items
  • Elite Author
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 100 and 199 users
+2 more
duotive says

strip_tags – This function tries to return a string with all NUL bytes, HTML and PHP tags stripped from a given str.

If you have a onethird par example shortcode any anchors, bolds, headings or whatever inside will be removed. So this is not a solution.

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

you’ll want to use something like
//Clean Up WordPress Shortcode Formatting - important for nested shortcodes
//adjusted from http://donalmacarthur.com/articles/cleaning-up-wordpress-shortcode-formatting/
function parse_shortcode_content( $content ) {

   /* Parse nested shortcodes and add formatting. */
    $content = trim( do_shortcode( shortcode_unautop( $content ) ) );

    /* Remove '' from the start of the string. */
    if ( substr( $content, 0, 4 ) == '' )
        $content = substr( $content, 4 );

    /* Remove '' from the end of the string. */
    if ( substr( $content, -3, 3 ) == '' )
        $content = substr( $content, 0, -3 );

    /* Remove any instances of ''. */
    $content = str_replace( array( '<p></p>' ), '', $content );
    $content = str_replace( array( '<p>  </p>' ), '', $content );

    return $content;
}

//move wpautop filter to AFTER shortcode is processed
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop',100 );

Sorry for the push of this old post.

This code works fine. BUT I also use shortcodes with text areas in the options menu (option tree).

e.g. in the index.php: do_shortcode(ot_get_option( ‘fp_textbox’ ));

How can I also remove the empty p-Tags there?

175 posts
  • Has been a member for 4-5 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Europe
  • Referred between 100 and 199 users
  • Bought between 10 and 49 items
ThemePrince says

Try to return the shortcode with [raw] like this:

function my_shortcode($atts, $content = null){
//your code

   return '[raw]'.$your_output.'[/raw]';
}
145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

thanks. found the same thing here: http://www.wprecipes.com/disable-wordpress-automatic-formatting-on-posts-using-a-shortcode

But If I use RAW it just types [raw] in the text.

return '[raw]<div class="one-third ' . $align . '">[/raw]'. do_shortcode($content) .'[raw]</div>[/raw]';
175 posts
  • Has been a member for 4-5 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Europe
  • Referred between 100 and 199 users
  • Bought between 10 and 49 items
ThemePrince says

Complete shortcode function, put this into function.php:

function my_shortcode($atts, $content = null){
   //your code

   return '[raw]'.$your_output.'[/raw]';
}
add_shortcode("mysc", "my_shortcode");

After that you’ll be able to use [mysc] shortcode in post/page editor.

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

I’ve done it exactly like that. Here’s the whole code:

function lld_one_third( $atts, $content = null ) {
    extract( shortcode_atts( array(
        'align' => ''
    ), $atts));
    return '[raw]<div class="one-third ' . $align . '">[/raw]'. do_shortcode($content) .'[raw]</div>[/raw]';
}
add_shortcode("one_third", "lld_one_third");

And I’ve implemented the code from the link in the functions.php (also tried in the same shortcodes.php). But it still types the [raw] as text

731 posts
  • Elite Author
  • Attended a Community Meetup
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Bought between 50 and 99 items
  • Exclusive Author
  • Most Wanted Bounty Winner
+2 more
mordauk says

You can also strip formatting by wrapping it in a shortcode like this.

No, do not ever do that. That is one of the worst practices that has plagued WordPress theme development. Covered it a lot over here: http://themeforest.net/forums/thread/wp-theme-forward-compatibility-shortcodescpts/75050

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

The RAW tag works for the shortcodes used in a post or page

But I also use Shortcodes when using Theme Options, e.g. do_shortcode(ot_get_option( ‘fp_textbox’ ));

And then it just types [raw] Texttexttext [/raw]

Do you have a solution for that?

145 posts
  • Austria
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
LovelessDesign says

Do I have to change “the_content” to something else to make it work?

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop',100 );
by
by
by
by
by
by