Skip to content

Instantly share code, notes, and snippets.

@matadorjobs
Created July 13, 2020 17:01
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 matadorjobs/cff32288ba5feab6f78c101f338ced10 to your computer and use it in GitHub Desktop.
Save matadorjobs/cff32288ba5feab6f78c101f338ced10 to your computer and use it in GitHub Desktop.
Apply template class names to Matador Buttons
<?php // omit opening PHP tag
add_filter( 'matador_template_button_classes', 'mdocs_matador_template_button_classes', 10, 2 );
/**
* Matador Template Button Classes Example Filter
*
* @since 2020-07-12
*
* @param string $classes Space-separated string of classes for a button
* @param string $context Button context, for filtering purposes, either 'primary', 'secondary', or 'tertiary'
*
* @return string
*/
function mdocs_matador_template_button_classes( $classes, $context = 'primary' ) {
$classes .= ' button';
if ( 'tertiary' === $context ) {
$classes .= ' button-tertiary';
} elseif ( 'secondary' === $context ) {
$classes .= ' button-secondary';
} elseif ( 'primary' === $context ) {
$classes .= ' button-primary' );
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment