Last active
October 23, 2024 12:16
-
-
Save galbaras/db88efe5f80a7af68f02 to your computer and use it in GitHub Desktop.
Revisions
-
galbaras revised this gist
Sep 3, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ add_filter( 'wpcf7_validate_text', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_text*', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_textarea', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_textarea*', 'no_urls_allowed', 10, 3 ); function no_urls_allowed( $result, $tag ) { $tag = new WPCF7_Shortcode( $tag ); @@ -24,8 +28,4 @@ function no_urls_allowed( $result, $tag ) { } } return $result; } -
galbaras created this gist
Aug 31, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ function no_urls_allowed( $result, $tag ) { $tag = new WPCF7_Shortcode( $tag ); $type = $tag->type; $name = $tag->name; $value = isset( $_POST[$name] ) ? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) ) : ''; // If this is meant to be a URL field, do nothing if ( 'url' == $tag->basetype || stristr($name, 'url') ) { return $result; } // Check for URLs $value = $_POST[$name]; $not_allowed = array( 'http://', 'https://', 'www.', '[url', '<a ', ' seo ' ); foreach ( $not_allowed as $na ) { if ( stristr( $value, $na ) ) { $result->invalidate( $tag, 'URLs are not allowed' ); return $result; } } return $result; } add_filter( 'wpcf7_validate_text', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_text*', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_textarea', 'no_urls_allowed', 10, 3 ); add_filter( 'wpcf7_validate_textarea*', 'no_urls_allowed', 10, 3 );