Shortcodes and wpautop()

@cosmincotor there really isn’t a great code snippet out there. I would personally recommend not trying to use any code snippet as every single one of them goes against what should be happening.

I also wouldn’t be including short codes (except very specialized ones in your themes). For example, if you want to add columns, suggest your users install this plugin: https://github.com/justintadlock/grid-columns

The problem is actually an issue with WordPress, not themes (except themes that try to fix it). The best thing to do is work on fixing the issue in core and submit a patch.

ZoomIt said

Would be nice to provide the fix since you started the thread and others may be intersted :d

I have used this plugin, those of the users who will have a problem with the paragraph tags and breaks added to the shortcodes will use it and the others wont. Maybe it’s not the best… next time I will try the solution from this topic :wink:

mordauk said

@cosmincotor there really isn’t a great code snippet out there. I would personally recommend not trying to use any code snippet as every single one of them goes against what should be happening.

I also wouldn’t be including short codes (except very specialized ones in your themes). For example, if you want to add columns, suggest your users install this plugin: https://github.com/justintadlock/grid-columns

The problem is actually an issue with WordPress, not themes (except themes that try to fix it). The best thing to do is work on fixing the issue in core and submit a patch.

Well, I guess I’ll have to re-think the shortcodes (which ones are absolutely necessary), and hopefully WP will receive an update that deals with this issue.

Thanks :slight_smile:

cosmincotor said
mordauk said

@cosmincotor there really isn’t a great code snippet out there. I would personally recommend not trying to use any code snippet as every single one of them goes against what should be happening.

I also wouldn’t be including short codes (except very specialized ones in your themes). For example, if you want to add columns, suggest your users install this plugin: https://github.com/justintadlock/grid-columns

The problem is actually an issue with WordPress, not themes (except themes that try to fix it). The best thing to do is work on fixing the issue in core and submit a patch.

Well, I guess I’ll have to re-think the shortcodes (which ones are absolutely necessary), and hopefully WP will receive an update that deals with this issue.

Thanks :slight_smile:

I wouldnt hold your breath

There are many best-selling TF themes which still use for instance:
$new_content .= wptexturize(wpautop($piece));

This forces wpautop and messes up the content generated by the new plugin I am working at.
It adds

to my generated content and I haven’t found any good solution yet to get rid of the

added

I thought theme authors are not allowed to force wpautop?? Or are they?

So what’s the verdict, I’m writing a theme, and definitely need to use the shortcode empty paragraph fix posted…will theme get rejected because of this?

Otherwise the wpautop wreaks havoc with my shortcodes :stuck_out_tongue:

Hi, just had a theme soft rejected and one of the reasons was for using:

function shortcode_empty_paragraph_fix($content){   
	$array = array (
		'

[' => '[', ']

' => ']', ']
' => ']' ); $content = strtr($content, $array); return $content; }

Ive always used this but it looks like this is no longer allowed, what are you doing to do this?

Check this out: https://gist.github.com/bitfade/4555047

OriginalEXE said

Check this out: https://gist.github.com/bitfade/4555047

That is basically doing the same thing, so why would that pass and the one I am doing not?

UBL said
OriginalEXE said

Check this out: https://gist.github.com/bitfade/4555047

That is basically doing the same thing, so why would that pass and the one I am doing not?

There is one big difference, your code affects all shortcodes, but with the code I linked you have the control over what shortcodes get "cleaned"
OriginalEXE said
UBL said
OriginalEXE said

Check this out: https://gist.github.com/bitfade/4555047

That is basically doing the same thing, so why would that pass and the one I am doing not?

There is one big difference, your code affects all shortcodes, but with the code I linked you have the control over what shortcodes get "cleaned"

The soft rejection was not about how many times it was used on shortcodes, it was for:

encouraging authors to use another methods rather than stripping out or modifying the_content() output as this may cause problems with third party plugins.

Which basically means the version you gave will not pass either.

I can understand that, by adding curtain shortcodes may help the 3rd party plugins work better but its still filtering the_content();

Or am I just mis reading the reviewers comment?

They don’t want you to affect 3rd party plugins but the code I linked to only affects your own shortcodes, so it should be accepted with no problems.

OriginalEXE said

They don’t want you to affect 3rd party plugins but the code I linked to only affects your own shortcodes, so it should be accepted with no problems.

Thank you, it looks like its just me mis reading the comments then…

Thanks for the link and thank you bitfade for the good function :slight_smile: