Last active
January 4, 2022 19:26
-
-
Save lelandf/ec7d91f29bd282fe325bc6c02b5e7597 to your computer and use it in GitHub Desktop.
[TEC] Add (required) to required custom fields on community edit event page.
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
add_action( 'wp_footer', function() { | |
// Stop if we're not on the community edit event page | |
if ( ! tribe_is_community_edit_event_page() ) { | |
return; | |
} | |
?> | |
<script> | |
// Function to add message to label | |
const addRequiredMessageToLabel = ( element ) => { | |
// Traverse to find the label | |
const label = element.closest( '.tribe-section-content-row' ).querySelector( 'label' ); | |
// Add message to label | |
label.insertAdjacentHTML( 'beforeend', `<span class="tec-required-label">(required)</span>` ); | |
}; | |
// Select all required fields | |
const requiredFields = document.querySelectorAll( '.tribe-section-custom-fields .required' ); | |
// Apply the function to each required field | |
requiredFields.forEach( addRequiredMessageToLabel ); | |
</script> | |
<?php | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment