Created
October 24, 2024 15:08
-
-
Save kimcoleman/7100c786d16f88b20e00c68ab48f1549 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add custom card classes to the Terms of Service (TOS) field in PMPro checkout. | |
* | |
* This function uses the 'pmpro_element_class' filter to add custom classes | |
* to the TOS fieldset, form fields, and other elements within the TOS area. | |
* | |
* @param array $class Array of element class names. | |
* @param string $element The element to return class names for. | |
* | |
* @return array Modified array of class names. | |
*/ | |
function my_pmpro_add_tos_card_classes( $class, $element ) { | |
// Add 'pmpro_card' class to the fieldset for the TOS fields. | |
if ( $element === 'pmpro_tos_fields' ) { | |
$class[] = 'pmpro_card'; | |
} | |
// Add 'pmpro_card_content' class to the form fields within the TOS fieldset. | |
if ( $element === 'pmpro_form_fields' ) { | |
$class[] = 'pmpro_card_content'; | |
} | |
return $class; | |
} | |
add_filter( 'pmpro_element_class', 'my_pmpro_add_tos_card_classes', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I modified this slightly as this version would apply the
pmpro_card_contents
to other cards as well as the tos element. My php is not great, but this seemed to work: