Forked from spivurno/gp-pay-per-word-i-mean-character.js
Created
September 9, 2020 12:57
-
-
Save dexit/55ec0ff555cfc97749691187de29c031 to your computer and use it in GitHub Desktop.
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 characters
| /** | |
| * Gravity Perks // Pay Per Word // Surprise, Pay Per Character! | |
| * https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | |
| */ | |
| gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) { | |
| // Pay per character instead of words. | |
| var words = text.split( '' ); | |
| return words == null ? 0 : words.length; | |
| } ); |
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 characters
| <?php | |
| /** | |
| * Gravity Perks // Pay Per Word // Surprise, Pay Per Character! | |
| * https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | |
| */ | |
| add_filter( 'gpppw_word_count', function( $word_count, $words ) { | |
| $words = str_split( trim( $words ) ); | |
| return count( $words ); | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment