Advertisement
geminilabs

[site-reviews] Restrict max/min field length

Feb 6th, 2022 (edited)
1,689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. /**
  2.  * Restrict the title to 80 characters (client side)
  3.  * @param array $field
  4.  * @return array
  5.  */
  6. add_filter('site-reviews/field/text', function ($field) {
  7.     if ('title' === $field['path']) {
  8.         $field['maxlength'] = 80;
  9.     }
  10.     return $field;
  11. });
  12.  
  13. /**
  14.  * Require the review to have at least 10 characters (client side)
  15.  * @param array $field
  16.  * @return array
  17.  */
  18. add_filter('site-reviews/field/textarea', function ($field) {
  19.     if ('content' === $field['path']) {
  20.         $field['minlength'] = 10;
  21.     }
  22.     return $field;
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement