737 posts
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 more
mordauk says

Please, please stop using this. I can give you dozens of examples of why this is terrible practice.

49 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 1+ items on Envato Market
carlhancock says

Under no circumstances should ANY theme developer implement this code in their theme if they are selling it to the general public. DON ’T USE THIS CODE IN YOUR THEME , IT WILL BREAK THINGS .

A theme should NOT be changing core WordPress behavior this way. YES it’s true that it does not “remove” the autop behavior, it “moves” it. BUT that has major ramifications.

The end result is this shortcode changes default WordPress behavior and parses ALL shortcode output through autop. Plugins do NOT expect this to happen and it CAN and WILL break things.

This is BAD , BAD, BAD .

We develop a little plugin called Gravity Forms. Inclusion of this code by theme developers costs us countless hours in support time assisting users who encounter problems with Gravity Forms beause of poorly developed themes that include this code.

Quit copy-n-pasting shit you find online and try fully understanding the code you place in your themes before you go selling them to people.

737 posts
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 more
mordauk says

+1000x to what Carl said. For anyone that doesn’t understand why this is bad, ask me or Carl, both of us will be more than happy to explain to why you should never do this.

137 posts WordPress Wizard
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
+6 more
CODE9RS says

Hi @mordauk

I would like to hear what is the best option in your opinion, what the theme developers would use to help plugin developers like you and Carl?

A example code is really appreciated.

Waiting :)

49 posts
  • Has been part of the Envato Community for over 6 years
  • Has collected 1+ items on Envato Market
carlhancock says

Best option for what exactly? Describe to me the problem or the issue that theme developers are thinking they are solving by implementing this code.

One thing theme developers should never be doing is implementing code that globally changes fundamental WordPress behavior that plugins rely on to function properly.

The theme is just that. A theme. Too many developers have lost sight of that. The theme shouldn’t be making such deep global changes to WordPress itself. It should simply handle the presentation layer of the site.

I have to say that I think ThemeForest’s newer policy of pricing a theme based on how complex it’s functionality is probably adds to the problem. To sell my theme for more money I simply need to make it more complex and provide more functionality? TERRIBLE THINKING . Themes do TOO MUCH and really should DO LESS . Plugins should handle the heavy lifting and more advanced functionality.

Another important point to make is developers who are building themes that they are selling to the public need to FULLY understand any code they are implementing in the theme and it’s ramifications. Anyone that truly understands how WordPress works should be able to look at this code and see what kind of negative impacts it could have.

Unfortunately too many people are copy-n-pasting bad code like this and including it without fully understanding it. This thread is a great example of that. It’s being posted for other developers to use because “it’s cool”. No, it’s not cool.

137 posts WordPress Wizard
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
+6 more
CODE9RS says

I would like to know more about your opinion of the use of [raw] shortcodes, that changes the wpautop behavior, or better, the default WP behavior.

Almost authors do it to ensure the code won’t be returned with a lot of few that can break the code, of a little slider shortcode for example…

What you recommend to do instead change the default WP behavior and ensure that WP won’t add auto in the shortcode code?

I agree with you that themes would just do less than they actually do, but as a theme seller, I can say that users aren’t good with a theme that doesn’t do X thing, they don’t want search for a plugin to shortcodes, or contact form, they need that this comes with the theme, else they will say your theme is poor….

And as we (theme devs of TF) depends of the money that users waste in our themes, we need do it, change this kind of think would require a general change in all themes OR a change in the customer mind … both really hard :P

Cheers!

373 posts WordPress Guy
  • Has referred 1+ members
  • Has sold $100+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in Australia
+4 more
Japh says

One thing theme developers should never be doing is implementing code that globally changes fundamental WordPress behavior that plugins rely on to function properly.

I agree with this.

@RDever, can you provide an example of slider shortcodes that are broken by wpautop()?

137 posts WordPress Wizard
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
+6 more
CODE9RS says

Hi Japh, for example, this:


/*-----------------------------------------------------------------------------------*/
/* [flex_slider]
/*-----------------------------------------------------------------------------------*/

function wpts_flex_slider($atts, $content = null, $code) {
    extract(shortcode_atts(array(
        'attr' => '',
    ), $atts));

    return '[raw]
        <div class="flexslider home">
                <ul class="slides">
                    '.do_shortcode($content).'
                </ul>
        </div>
        [/raw]';
}
add_shortcode('flex_slider', 'wpts_flex_slider');

/*-----------------------------------------------------------------------------------*/
/* [flex_item]
/*-----------------------------------------------------------------------------------*/

function wpts_flex_item($atts, $content = null, $code) {
    extract(shortcode_atts(array(
        'src' => '',
        'caption' => '',
        'href' => '',
        'type' => 'normal'
    ), $atts));

    $class= 'slider-caption';

    $text = '';

    $aBegin = '';
    $aEnd = '';

    if($type != 'normal') {
        $class = 'slider-caption-2';
    }

    if($content != '')
        $text = '<p>'.trim($content).'</p>';

    if($caption != '')
        $caption = '<h3>'.$caption.'</h3>';

    if($href != '') {
        $aBegin = '<a href="'.$href.'">';
        $aEnd = '</a>';
    }

    return '
                '.$aBegin.'
                <img src="'.$src.'" alt="" />
                '.$aEnd.'
                <div class="'.$class.'">
                    '.$caption.'
                    '.$text.'
                </div>
            ';
}
add_shortcode('flex_item', 'wpts_flex_item');

Note that the [raw] avoid that the caption display looks like:

<p>My Caption></p>
<p></p>

Cheers!

709 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+2 more
ChillThemes says

Shortcodes just overcomplicate what would otherwise be simple HTML markup. There’s plenty of great “shortcode” plugins out there. Clean well formed code > 40+ shortcodes.

158 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
+1 more
greenshady says

The solution to the problem is pretty simple — stop trying to be plugin developers when you’re clearly not. Let plugins do their jobs and themes do their jobs.

Plugins are about the functionality of a site. Themes are about the presentation.

Until every theme developer here understands that basic concept or until the higher-ups at Envato start banning plugin functionality in themes, we’ll be stuck in this endless cycle of the same ol’ discussions about how crappy the code is in Theme Forest themes.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by