wpcf7_mask_password()
Masks a password with asterisks (*).
Хуков нет.
Возвращает
Строку
. Text of masked password.
Использование
wpcf7_mask_password( $text, $right, $left );
- $text (обязательный)
- -
- $right(int)
- Length of right-hand unmasked text.
- $left(int)
- Length of left-hand unmasked text.
Код wpcf7_mask_password() wpcf7 mask password CF7 6.0.6
function wpcf7_mask_password( $text, $right = 0, $left = 0 ) { $length = strlen( $text ); $right = absint( $right ); $left = absint( $left ); if ( $length < $right + $left ) { $right = $left = 0; } if ( $length <= 48 ) { $masked = str_repeat( '*', $length - ( $right + $left ) ); } elseif ( $right + $left < 48 ) { $masked = str_repeat( '*', 48 - ( $right + $left ) ); } else { $masked = '****'; } $left_unmasked = $left ? substr( $text, 0, $left ) : ''; $right_unmasked = $right ? substr( $text, -1 * $right ) : ''; $text = $left_unmasked . $masked . $right_unmasked; return $text; }