Skip to content

Commit

Permalink
Version 1.0
Browse files Browse the repository at this point in the history
Version 1.0
  • Loading branch information
suryatanjung committed Jan 25, 2024
1 parent e07d78c commit b7d3a6d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ function limit_keyword_length( $error, $url, $keyword ) {
$max_length = 100; // Set max length limit for custom keyword
$min_length = 1; // Set min length limit for custom keyword
$length = strlen( $keyword );

if ( $length > $max_length || ( $length < $min_length && $length > 0 ) ) {
$error['status'] = 'fail';
$error['code'] = 'error:keyword';
$error['message'] = ( $length > $max_length )
? "the keyword is too long. It can't be more than {$max_length} characters"
: "the keyword is too short. It needs to have at least {$min_length} characters";
return yourls_apply_filter( 'add_new_link_keyword_length_error', $error );
}

return false;
}

0 comments on commit b7d3a6d

Please sign in to comment.