Skip to content

Commit

Permalink
Merge pull request #892 from takayukister/dev/5.6
Browse files Browse the repository at this point in the history
Update config-validator.php
  • Loading branch information
takayukister authored Jul 18, 2022
2 parents 1e169e0 + 7113123 commit 5a11003
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions includes/config-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ public function validate() {
return $this->is_valid();
}


/**
* Saves detected errors as a post meta data.
*/
public function save() {
if ( $this->contact_form->initial() ) {
return;
Expand All @@ -273,6 +277,10 @@ public function save() {
}
}


/**
* Restore errors from the database.
*/
public function restore() {
$config_errors = get_post_meta(
$this->contact_form->id(), '_config_errors', true
Expand All @@ -298,6 +306,11 @@ public function restore() {
}
}


/**
* Callback function for WPCF7_MailTaggedText. Replaces mail-tags with
* the most conservative inputs.
*/
public function replace_mail_tags_with_minimum_input( $matches ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] == '[' && $matches[4] == ']' ) {
Expand Down Expand Up @@ -385,6 +398,10 @@ public function replace_mail_tags_with_minimum_input( $matches ) {
return $tag;
}


/**
* Runs error detection for the form section.
*/
public function validate_form() {
$section = 'form.body';
$form = $this->contact_form->prop( 'form' );
Expand All @@ -395,6 +412,12 @@ public function validate_form() {
$this->detect_colons_in_names( $section, $form );
}


/**
* Detects errors of multiple form controls in a single label.
*
* @link https://contactform7.com/configuration-errors/multiple-controls-in-label/
*/
public function detect_multiple_controls_in_label( $section, $content ) {
$pattern = '%<label(?:[ \t\n]+.*?)?>(.+?)</label>%s';

Expand Down Expand Up @@ -440,6 +463,12 @@ public function detect_multiple_controls_in_label( $section, $content ) {
return false;
}


/**
* Detects errors of unavailable form-tag names.
*
* @link https://contactform7.com/configuration-errors/unavailable-names/
*/
public function detect_unavailable_names( $section, $content ) {
$public_query_vars = array( 'm', 'p', 'posts', 'w', 'cat',
'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence',
Expand Down Expand Up @@ -481,6 +510,12 @@ public function detect_unavailable_names( $section, $content ) {
return false;
}


/**
* Detects errors of unavailable HTML elements.
*
* @link https://contactform7.com/configuration-errors/unavailable-html-elements/
*/
public function detect_unavailable_html_elements( $section, $content ) {
$pattern = '%(?:<form[\s\t>]|</form>)%i';

Expand All @@ -497,6 +532,12 @@ public function detect_unavailable_html_elements( $section, $content ) {
return false;
}


/**
* Detects errors of dots in form-tag names.
*
* @link https://contactform7.com/configuration-errors/dots-in-names/
*/
public function detect_dots_in_names( $section, $content ) {
$form_tags_manager = WPCF7_FormTagsManager::get_instance();

Expand All @@ -520,6 +561,11 @@ public function detect_dots_in_names( $section, $content ) {
}


/**
* Detects errors of colons in form-tag names.
*
* @link https://contactform7.com/configuration-errors/colons-in-names/
*/
public function detect_colons_in_names( $section, $content ) {
$form_tags_manager = WPCF7_FormTagsManager::get_instance();

Expand All @@ -543,6 +589,9 @@ public function detect_colons_in_names( $section, $content ) {
}


/**
* Runs error detection for the mail sections.
*/
public function validate_mail( $template = 'mail' ) {
$components = (array) $this->contact_form->prop( $template );

Expand Down

0 comments on commit 5a11003

Please sign in to comment.