Created
November 12, 2015 12:14
-
-
Save getdave/3a26392824853ce7f80d to your computer and use it in GitHub Desktop.
Remove Gravity Forms jQuery and all inline <script> tags
This file contains 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 characters
/** | |
* Force GFORM Scripts inline next to Form Output | |
* | |
* force the script tags inline next to the form. This allows | |
* us to regex them out each time the form is rendered. | |
* | |
* see strip_inline_gform_scripts() function below | |
* which implements the required regex | |
*/ | |
function force_gform_inline_scripts() { | |
return false; | |
} | |
add_filter("gform_init_scripts_footer", "force_gform_inline_scripts"); | |
/** | |
* Strip out GForm Script tags | |
* | |
* note: this diables post and pre render hooks which are triggered | |
* when the form renders so if you need these then it's important | |
* to manually re-add them in your compiled JS source code | |
*/ | |
function strip_inline_gform_scripts( $form_string, $form ) { | |
return $form_string = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $form_string); | |
} | |
add_filter("gform_get_form_filter", "strip_inline_gform_scripts", 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use?