Created
September 24, 2020 16:37
-
-
Save ronalfy/daddbd993400afe6069b7e0599d56746 to your computer and use it in GitHub Desktop.
PMPro - jQuery - Move Asterisk
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 | |
/** | |
* Moves the asterisk next to the label. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_move_required_asterisk_checkout() { | |
if ( is_page( 'membership-checkout' ) && wp_script_is( 'jquery', 'done' ) ) { | |
?> | |
<script> | |
jQuery(function() { | |
jQuery( '.pmpro_asterisk' ).each( function() { | |
var asteriskHtml = '<span class="pmpro_asterisk"> * </span>'; | |
var asterisk = jQuery( this ); | |
var asteriskParent = asterisk.parent( '.pmpro_checkout-field' ); | |
var asteriskLabel = asteriskParent.find( 'label' ).first(); | |
asterisk.remove(); | |
asteriskLabel.append( asteriskHtml ); | |
} ); | |
}); | |
</script> | |
<?php | |
} | |
return; | |
} | |
add_action( 'wp_footer', 'pmpro_move_required_asterisk_checkout' ); | |
/* Styles | |
form.pmpro_form .pmpro_checkout-fields div.pmpro_checkout-field-radio-item, form.pmpro_form .pmpro_member_profile_edit-fields div.pmpro_checkout-field-radio-item { | |
display: block; | |
} | |
form.pmpro_form .pmpro_checkout-fields div.pmpro_checkout-field-radio-item input, form.pmpro_form .pmpro_member_profile_edit-fields div.pmpro_checkout-field-radio-item input { | |
width: auto; | |
} | |
.pmpro_checkout-field.pmpro_checkout-field-radio { | |
position: relative; | |
} | |
.pmpro_checkout-field.pmpro_checkout-field-text { | |
position: relative; | |
} | |
.pmpro_checkout-field.pmpro_checkout-field-bemail { | |
position: relative; | |
} | |
.pmpro_asterisk { | |
display: inline; | |
font-size: 1.0em; | |
color: red; | |
} | |
.pmpro_checkout-field label { | |
display: inline-block; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment