-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add filter for plugins to add support link to login form. #615
base: master
Are you sure you want to change the base?
Add filter for plugins to add support link to login form. #615
Conversation
class-two-factor-core.php
Outdated
/* | ||
* Allow plugins to add links to the two-factor login form. | ||
*/ | ||
$links = apply_filters( 'two_factor_login_support_links', $links ); | ||
|
||
// Echo out the filtered links | ||
foreach ( $links as $link ) { | ||
echo wp_kses_post( $link ); | ||
} |
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.
/* | |
* Allow plugins to add links to the two-factor login form. | |
*/ | |
$links = apply_filters( 'two_factor_login_support_links', $links ); | |
// Echo out the filtered links | |
foreach ( $links as $link ) { | |
echo wp_kses_post( $link ); | |
} | |
/* | |
* Allow plugins to filter the backup method links on the login form. | |
*/ | |
$links = apply_filters( 'two_factor_login_backup_links', $links ); | |
// Echo out the filtered links | |
echo implode( '', $links ); |
Given this filter only runs when there are backup providers, calling it a support links might be confusing for some, we can probably name it something like two_factor_login_backup_links
?
There's probably an argument that this should be built prior to the if ( $backup_providers )
conditional to output filtered data even when there exist no backup methods for the given user?
I don't think we need to explicitly sanitize the HTML here either, it's either hard-coded HTML or from a PHP function that can do anything anyway.
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.
This appears to be addressed in the follow-up commits.
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.
These points remain:
Given this filter only runs when there are backup providers, calling it a support links might be confusing for some, we can probably name it something like two_factor_login_backup_links?
OR
There's probably an argument that this should be built prior to the if ( $backup_providers ) conditional to output filtered data even when there exist no backup methods for the given user?
I suspect the intention of the filter was actually to be used when the user has no backup provider, or, at least that others who would have a use for it would be in that group.
b658956
to
8918127
Compare
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.
@StevenDufresne Was there anything else you wanted to include here or is this ready for merge?
If you don't get around to it, we'll extend the inline docblock for the filter to include documentation for the arguments (like here) and also add it to the relevant readme section.
What?
Sometimes users have difficulty with their two-factor settings. In the "Having Problems?" section, we currently don't have a way to add links that are not providers.
This PR adds a filter called
two_factor_login_support_links
to allow plugins to provide non-provider support links.Why?
We want to give users access to documentation that can help them with using 2fa or with recovering their account.
For example, it would allow us to do
How?
It adds a filter inside the
<ul>
so HTML can be passed in like so:Testing Instructions
Changelog Entry