730 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

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

49 posts
  • Bought between 1 and 9 items
  • Has been a member for 6-7 years
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.

730 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

+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.

115 posts WordPress Wizard
  • Microlancer Beta Tester
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Most Wanted Bounty Winner
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
XiaoThemes 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
  • Bought between 1 and 9 items
  • Has been a member for 6-7 years
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.

115 posts WordPress Wizard
  • Microlancer Beta Tester
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Most Wanted Bounty Winner
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
XiaoThemes 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!

366 posts WordPress Guy
  • Envato Staff
  • Australia
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
  • Reviewer
+1 more
Japh Staff 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()?

115 posts WordPress Wizard
  • Microlancer Beta Tester
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Most Wanted Bounty Winner
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
XiaoThemes 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!

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Microlancer Beta Tester
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
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 50 and 99 users
  • Sold between 1 000 and 5 000 dollars
  • United States
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.

by
by
by
by
by
by