Skip to content

Instantly share code, notes, and snippets.

@plasticmind
Created October 2, 2012 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plasticmind/3823053 to your computer and use it in GitHub Desktop.
Save plasticmind/3823053 to your computer and use it in GitHub Desktop.
Inject class into $before_widget variable
// Let's inject a little class into our $before_widget variable
if( strpos($before_widget, 'class') === false ) { // It has no class... let's add it!
$before_widget = str_replace('>', ' class="custom-class-name">', $before_widget);
} else { // We have class... let's append it!
$before_widget = str_replace('class="', 'class="custom-class-name ', $before_widget);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment