Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.