Skip to content

Instantly share code, notes, and snippets.

@scyt
Created July 23, 2020 20:14
Show Gist options
  • Save scyt/0f0441486b15afd37804c2344f493097 to your computer and use it in GitHub Desktop.
Save scyt/0f0441486b15afd37804c2344f493097 to your computer and use it in GitHub Desktop.
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Line!
* 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( '\n' );
return words == null ? 0 : words.length;
} );
<?php
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Line!
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
add_filter( 'gpppw_word_count', function( $word_count, $words ) {
$words = explode("\n", $words);
return count( $words );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment