@@ -999,9 +999,10 @@ public function callback_repeater( $args ) {
999999 $ class = $ this ->get_field_class ( $ args );
10001000 $ attributes = $ this ->get_boolean_attributes ( $ args ) . $ this ->build_field_attributes ( $ args );
10011001
1002- $ data_index = (string ) count ( $ value );
1003- $ live_update_field = ! empty ( $ args ['live_update_field ' ] ) ? $ args ['live_update_field ' ] : 'name ' ;
1004- $ fallback_title = ! empty ( $ args ['new_item_text ' ] ) ? $ args ['new_item_text ' ] : $ this ->translation_strings ['repeater_new_item ' ];
1002+ $ data_index = (string ) count ( $ value );
1003+ $ live_update_field = ! empty ( $ args ['live_update_field ' ] ) ? $ args ['live_update_field ' ] : 'name ' ;
1004+ $ fallback_title = ! empty ( $ args ['new_item_text ' ] ) ? $ args ['new_item_text ' ] : $ this ->translation_strings ['repeater_new_item ' ];
1005+ $ live_update_options = ! empty ( $ args ['live_update_field_options ' ] ) && is_array ( $ args ['live_update_field_options ' ] ) ? $ args ['live_update_field_options ' ] : array ();
10051006
10061007 ob_start ();
10071008 ?>
@@ -1010,6 +1011,9 @@ public function callback_repeater( $args ) {
10101011 data-index="<?php echo esc_attr ( $ data_index ); ?> "
10111012 data-live-update-field="<?php echo esc_attr ( $ live_update_field ); ?> "
10121013 data-fallback-title="<?php echo esc_attr ( $ fallback_title ); ?> "
1014+ <?php if ( ! empty ( $ live_update_options ) ) : ?>
1015+ data-live-update-field-options="<?php echo esc_attr ( wp_json_encode ( $ live_update_options ) ); ?> "
1016+ <?php endif ; ?>
10131017 <?php echo $ attributes ; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> >
10141018
10151019 <div class="<?php echo esc_attr ( $ args ['id ' ] ); ?> -items wz-repeater-items">
@@ -1069,9 +1073,14 @@ public function render_repeater_item( $args, $index, $item = null ) {
10691073 <input type="hidden" name="<?php echo esc_attr ( $ this ->settings_key ); ?> [<?php echo esc_attr ( $ args ['id ' ] ); ?> ][<?php echo esc_attr ( $ index ); ?> ][row_id]" value="<?php echo esc_attr ( $ item_id ); ?> " />
10701074 <div class="repeater-item-header">
10711075 <?php
1072- $ display_field = ! empty ( $ args ['live_update_field ' ] ) ? $ args ['live_update_field ' ] : 'name ' ;
1076+ $ display_field = ! empty ( $ args ['live_update_field ' ] ) ? $ args ['live_update_field ' ] : 'name ' ;
1077+ $ live_options = ! empty ( $ args ['live_update_field_options ' ] ) && is_array ( $ args ['live_update_field_options ' ] ) ? $ args ['live_update_field_options ' ] : array ();
1078+ $ raw_live_value = ! empty ( $ item ['fields ' ][ $ display_field ] ) ? (string ) $ item ['fields ' ][ $ display_field ] : '' ;
1079+ $ display_value = '' !== $ raw_live_value
1080+ ? ( isset ( $ live_options [ $ raw_live_value ] ) ? $ live_options [ $ raw_live_value ] : $ raw_live_value )
1081+ : $ fallback_title ;
10731082 ?>
1074- <span class="repeater-title"><?php echo esc_html ( ! empty ( $ item [ ' fields ' ][ $ display_field ] ) ? $ item [ ' fields ' ][ $ display_field ] : $ fallback_title ); ?> </span>
1083+ <span class="repeater-title"><?php echo esc_html ( $ display_value ); ?> </span>
10751084 <span class="toggle-icon">▼</span>
10761085 </div>
10771086 <div class="repeater-item-content" style="display: none;">
0 commit comments