Skip to content

Instantly share code, notes, and snippets.

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/0497c0e6864a7befe2b1b1769580539e to your computer and use it in GitHub Desktop.
Save matadorjobs/0497c0e6864a7befe2b1b1769580539e to your computer and use it in GitHub Desktop.
Assuming our theme has previously defined classes for buttons of 'button', 'button-secondary', and 'button-alternate', give those CSS classes to Matador Buttons so to adopt theme CSS conventions.
<?php //omit opening tag
add_filter( 'matador_template_button_classes', 'matador_docs_theme_button_classes', 10, 2 );
/**
* Matador Docs Example: Theme Button Classes
*
* Assuming our theme has previously defined classes for buttons of 'button', 'button-secondary', and 'button-alternate', give those CSS classes to Matador Buttons so to adopt theme CSS conventions.
*
* @since 2023-05-01
*
* @author Matador US, LP, @jeremyescott, @pbearne
*
* @param string $classes Defaults to 'matador-button' and adds 'matador-button-secondary' or 'matador-button-tertiary' if $context is 'secondary' or 'tertiary', respectively.
* @param string $context Can be 'primary', 'secondary', or 'tertiary' depending on the button.
*
* @return string
**/
function matador_docs_theme_button_classes( $classes, $context ) {
if ( 'tertiary' === $context ) {
return 'button button-alternate';
} elseif ( 'secondary' === $context ) {
return 'button button-secondary';
} else {
return 'button';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment