Created
May 5, 2020 16:07
-
-
Save scyt/8f92c925f201f4337fdc5048741b2564 to your computer and use it in GitHub Desktop.
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
/** | |
* Gravity Perks // Pay Per Word // Ignore Words Between Parentheses (JS) | |
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | |
*/ | |
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) { | |
// Removes words between parentheses. | |
var words = text.replace( /\(([^)]+)\)/g, '' ).match( /\S+/g ); | |
return words == null ? 0 : words.length; | |
} ); |
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
<?php | |
/** | |
* Gravity Perks // Pay Per Word // Ignore Words Between Parentheses (PHP) | |
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | |
*/ | |
add_filter( 'gpppw_word_count', function( $word_count, $words ) { | |
// Removes words between parentheses. | |
$words = preg_replace( '/\(([^)]+)\)/', ' ', $words ); | |
return count( array_filter( preg_split( '/[ \n\r]+/', trim( $words ) ) ) ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment