: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @link https://contactform7.com/reflection/
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_reflection', 10, 0 );
* Registers reflection-related form-tag types.
function wpcf7_add_form_tag_reflection() {
wpcf7_add_form_tag( 'reflection',
'wpcf7_reflection_form_tag_handler',
wpcf7_add_form_tag( 'output',
'wpcf7_output_form_tag_handler',
* The form-tag handler for the reflection type.
function wpcf7_reflection_form_tag_handler( $tag ) {
if ( empty( $tag->name ) ) {
$values = $tag->values ? $tag->values : array( '' );
if ( ! wpcf7_get_validation_error( $tag->name ) ) {
$hangover = array_filter( (array) wpcf7_get_hangover( $tag->name ) );
static function ( $carry, $item ) use ( $tag ) {
'<output %1$s>%2$s</output>',
wpcf7_format_atts( array(
( '' !== $item ) ? esc_html( $item ) : ' '
return $carry . $output_tag;
'<fieldset %1$s>%2$s</fieldset>',
wpcf7_format_atts( array(
'data-reflection-of' => $tag->name,
'class' => $tag->get_class_option(
wpcf7_form_controls_class( $tag->type )
'id' => $tag->get_id_option(),
* The form-tag handler for the output type.
function wpcf7_output_form_tag_handler( $tag ) {
if ( empty( $tag->name ) ) {
$value = (string) reset( $tag->values );
if ( ! wpcf7_get_validation_error( $tag->name ) ) {
$hangover = array_filter( (array) wpcf7_get_hangover( $tag->name ) );
$value = (string) reset( $hangover );
'<output %1$s>%2$s</output>',
wpcf7_format_atts( array(
'data-reflection-of' => $tag->name,
'data-default' => $value,
'class' => $tag->get_class_option(
wpcf7_form_controls_class( $tag->type )
'id' => $tag->get_id_option(),