I recognize this would be better suited for the plugin's official support thread, but the developer doesn't appear to read the forums.

I'm using the Standout CSS3 Buttons plugin to add buttons via shortcode around my site. There's an optional parameter in the shortcode, cssclass, which allows you to specify a custom class for the button. Since my site is built on the Gantry framework, which already has rules for the .button class, I'd really like to simply declare cssclass="button" in the shortcode and let Gantry's CSS cover it. Unfortunately, when I do that, the plugin doesn't appear to recognize it, and when the page loads, the button does not have the .button class.

If, instead of cssclass="button", I specify a class defined by the plugin, such as "button-pinterest" or "button-rss", the button updates just fine, reflecting that class and the appropriate styles. It seems as though the plugin is stripping out any custom class--which seems to defeat the very purpose of offering custom CSS classes.

You can see a button generated by the plugin on a page here, in the sidebar. Right now, it's using the .button-pinterest class, and I'd like to give it the .button class instead.

I don't have the PHP chops to look at the plugin and figure out how to make it add the class I specify in the shortcode. Is there anyone who could kindly take a look at it and help me add my custom classes?


You can hijack the shortcode and use your own additional logic.

Sample code, not tested:

add_action( 'after_setup_theme', function()
    // Replace the plugin shortcode handler with your own.
    add_shortcode( 'standout-css3-button', function( $atts, $content = NULL )
        // Let the plugin make the button and store the result.
        $button = scss3button( $atts, $content );

        // No custom class, stop.
        if ( empty ( $atts['cssclass'] ) )
            return $button;

        // Inject your own class, and add a white space as class separator.
        return str_replace(
            'class="' . $atts['cssclass'] . ' ',

By the way: I wouldn’t use that plugin on any of my sites. The code makes me cringe. You should really consider implementing the buttons you need in your theme and get away with less and better code.

  • I wish I could upvote the last paragraph above the answer itself
    – Michal Mau
    Aug 28 '13 at 0:21
  • @toscho: Your last paragraph brought some sense to me. For some reason, I completely spaced on the notion that I could just include the HTML in a text widget instead of using a shortcode. That still might not be preferable to adding it directly to the theme, but it works for my purposes. Thanks!
    – SpencerDub
    Aug 28 '13 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.