WPCF7_ConfigValidator::replace_mail_tags_with_minimum_input()
Callback function for WPCF7_MailTaggedText. Replaces mail-tags with the most conservative inputs.
Метод класса: WPCF7_ConfigValidator{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$WPCF7_ConfigValidator = new WPCF7_ConfigValidator(); $WPCF7_ConfigValidator->replace_mail_tags_with_minimum_input( $matches );
- $matches (обязательный)
- -
Код WPCF7_ConfigValidator::replace_mail_tags_with_minimum_input() WPCF7 ConfigValidator::replace mail tags with minimum input CF7 5.7.7
public function replace_mail_tags_with_minimum_input( $matches ) { // allow [[foo]] syntax for escaping a tag if ( $matches[1] == '[' && $matches[4] == ']' ) { return substr( $matches[0], 1, -1 ); } $tag = $matches[0]; $tagname = $matches[2]; $values = $matches[3]; $mail_tag = new WPCF7_MailTag( $tag, $tagname, $values ); $field_name = $mail_tag->field_name(); $example_email = 'example@example.com'; $example_text = 'example'; $example_blank = ''; $form_tags = $this->contact_form->scan_form_tags( array( 'name' => $field_name ) ); if ( $form_tags ) { $form_tag = new WPCF7_FormTag( $form_tags[0] ); $is_required = ( $form_tag->is_required() || 'radio' == $form_tag->type ); if ( ! $is_required ) { return $example_blank; } if ( wpcf7_form_tag_supports( $form_tag->type, 'selectable-values' ) ) { if ( $form_tag->pipes instanceof WPCF7_Pipes ) { if ( $mail_tag->get_option( 'do_not_heat' ) ) { $before_pipes = $form_tag->pipes->collect_befores(); $last_item = array_pop( $before_pipes ); } else { $after_pipes = $form_tag->pipes->collect_afters(); $last_item = array_pop( $after_pipes ); } } else { $last_item = array_pop( $form_tag->values ); } if ( $last_item and wpcf7_is_mailbox_list( $last_item ) ) { return $example_email; } else { return $example_text; } } if ( 'email' == $form_tag->basetype ) { return $example_email; } else { return $example_text; } } else { // maybe special mail tag // for back-compat $field_name = preg_replace( '/^wpcf7\./', '_', $field_name ); if ( '_site_admin_email' == $field_name ) { return get_bloginfo( 'admin_email', 'raw' ); } elseif ( '_user_agent' == $field_name ) { return $example_text; } elseif ( '_user_email' == $field_name ) { return $this->contact_form->is_true( 'subscribers_only' ) ? $example_email : $example_blank; } elseif ( '_user_' == substr( $field_name, 0, 6 ) ) { return $this->contact_form->is_true( 'subscribers_only' ) ? $example_text : $example_blank; } elseif ( '_' == substr( $field_name, 0, 1 ) ) { return '_email' == substr( $field_name, -6 ) ? $example_email : $example_text; } } return $tag; }