Skip to content

Commit

Permalink
Add a filter to alter custom field parameters for an event.
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Sep 8, 2024
1 parent 5748cd1 commit 737bdb8
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/mt-fields-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,18 @@ function mt_custom_field( $fields, $event_id ) {
$output = '';
foreach ( $custom_fields as $name => $field ) {
$continue = mt_apply_custom_field( $field, $event_id );
if ( $continue ) {
/**
* Modify a custom field's characteristics prior to rendering.
*
* @hook mt_field_parameters
*
* @param {array} $field Array of field information.
* @param {int} $event_id The event being rendered.
*
* @return {array}
*/
$field = apply_filters( 'mt_field_parameters', $field, $event_id );
if ( $continue && is_array( $field ) ) {
$user_value = esc_attr( stripslashes( mt_get_data( $name . '_' . $event_id ) ) );
$required = isset( $field['required'] ) ? ' required' : '';
$req_label = isset( $field['required'] ) ? ' <span class="required">' . __( 'Required', 'my-tickets' ) . '</span>' : '';
Expand Down Expand Up @@ -297,6 +308,17 @@ function mt_show_payment_field( $content, $payment_id ) {
$output = '';
foreach ( $custom_fields as $name => $field ) {
$data = get_post_meta( $payment_id, $name );
/**
* Customize the output of custom fields in the admin Payment record.
*
* @hook mt_custom_display_field
*
* @param {string} $output_html. Default empty string.
* @param {mixed} $data Saved data from post meta.
* @param {string} $name Field name array key.
*
* @return {string}
*/
$return = apply_filters( 'mt_custom_display_field', '', $data, $name );
if ( '' === $return ) {
foreach ( $data as $d ) {
Expand Down

0 comments on commit 737bdb8

Please sign in to comment.