forked from gravitywiz/snippet-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated gpppw-split-words-on-specific-characters and added gpppw-pay-…
…per-character Original Gist for gpppw-pay-per-character: https://gist.github.com/spivurno/bf3b4a944b307d8ec57e29f77cd0ac91
- Loading branch information
Showing
4 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Gravity Perks // Pay Per Word // Surprise, Pay Per Character! (JS) | ||
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | ||
* | ||
* This snippet requires the PHP counterpart gpppw-pay-per-character.php | ||
*/ | ||
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/** | ||
* Gravity Perks // Pay Per Word // Surprise, Pay Per Character! (PHP) | ||
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | ||
* | ||
* This snippet requires the JS counterpart gpppw-pay-per-character.js | ||
*/ | ||
add_filter( 'gpppw_word_count', function( $word_count, $words ) { | ||
// Pay per character instead of words. | ||
$words = str_split( trim( $words ) ); | ||
return count( $words ); | ||
}, 10, 2 ); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/** | ||
* Gravity Perks // Pay Per Word // Split Words on Specific Characters (JS) | ||
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/ | ||
* | ||
* This snippet requires the PHP counterpart gpppw-split-words-on-specific-characters.php | ||
*/ | ||
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) { | ||
// Splits words on periods, underscores, and asterisks. | ||
// Splits words on periods, underscores, and asterisks. | ||
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