Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created May 10, 2017 19:25
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 jaredatch/71e20c759e4800d56494bd7d4fc9f2ab to your computer and use it in GitHub Desktop.
Save jaredatch/71e20c759e4800d56494bd7d4fc9f2ab to your computer and use it in GitHub Desktop.
WPForms smart tags inside checkbox labels
<?php
/**
* Process smart tags inside checkbox choice labels,
*
* @param array $field
* @param array $deprecated
* @param array $form_data
* @return array
*/
function wp_checkbox_choices_process_smarttags( $field, $deprecated, $form_data ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( ! empty( $choice['label'] ) ) {
$field['choices'][ $key ]['label'] = apply_filters( 'wpforms_process_smart_tags', $choice['label'], $form_data );
}
}
return $field;
}
add_filter( 'wpforms_checkbox_field_display', 'wp_checkbox_choices_process_smarttags', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment