-
Notifications
You must be signed in to change notification settings - Fork 176
Alternative to #741 - Autosubmit Tweak #820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e17c5b3
1fada25
23b8907
698c7a5
e9b935d
4659913
18732c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,15 +142,18 @@ public static function is_supported_for_user( $user = null ) { | |
| } | ||
|
|
||
| /** | ||
| * Generate a random eight-digit string to send out as an auth code. | ||
| * Generate a random string to send out as an auth code. Default is an 8 digit numeric code, but the length and characters can be customized. | ||
| * | ||
| * @since 0.1-dev | ||
| * | ||
| * @param int $length The code length. | ||
| * @param string|array $chars Valid auth code characters. | ||
| * @return string | ||
| */ | ||
| public static function get_code( $length = 8, $chars = '1234567890' ) { | ||
| public static function get_code( $length = null, $chars = '1234567890' ) { | ||
| if ( is_null( $length ) ) { | ||
| $length = self::get_code_length( 8, static::class ); | ||
| } | ||
| $code = ''; | ||
| if ( is_array( $chars ) ) { | ||
| $chars = implode( '', $chars ); | ||
|
|
@@ -161,6 +164,29 @@ public static function get_code( $length = 8, $chars = '1234567890' ) { | |
| return $code; | ||
| } | ||
|
|
||
| /** | ||
| * Get the code length for a provider. | ||
| * | ||
| * @since 0.?.0 | ||
| * | ||
| * @param int $default Default code length if not filtered. | ||
| * @param string|null $provider The provider class name. Null uses the called class. | ||
| * @return int Number of characters. | ||
| */ | ||
| public static function get_code_length( $default = 8, $provider = null ) { | ||
| /** | ||
| * Filter the default code length for a provider. | ||
| * | ||
| * @since 0.?.0 | ||
|
Comment on lines
+170
to
+180
|
||
| * | ||
| * @param int $code_length Length of the code. Default 8. | ||
| * @param string $provider The provider class name. | ||
| */ | ||
| $code_length = (int) apply_filters( 'two_factor_code_length', $default, $provider ?: static::class ); | ||
|
|
||
| return $code_length; | ||
| } | ||
georgestephanis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Sanitizes a numeric code to be used as an auth code. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
@since 0.?.0version placeholder in thetwo_factor_autosubmit_lengthfilter documentation needs to be replaced with the actual release version before merging.