-
Notifications
You must be signed in to change notification settings - Fork 171
Add 'Settings' action link to plugin list for quick access to profile… Addresses #732
#740
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 'Settings' action link to plugin list for quick access to profile… Addresses #732
#740
Conversation
kasparsd
left a comment
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.
Thanks for your contribution @hardikRathi!
The code looks good and I only had suggestion about the organization.
two-factor.php
Outdated
| return $links; | ||
| } | ||
|
|
||
| add_filter( |
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.
Could we move this to the rest of the hooks here along with the callback method?
two-factor/class-two-factor-core.php
Lines 95 to 132 in ae3cdaa
| public static function add_hooks( $compat ) { | |
| add_action( 'init', array( __CLASS__, 'get_providers' ) ); // @phpstan-ignore return.void | |
| add_action( 'wp_login', array( __CLASS__, 'wp_login' ), 10, 2 ); | |
| add_filter( 'wp_login_errors', array( __CLASS__, 'maybe_show_reset_password_notice' ) ); | |
| add_action( 'after_password_reset', array( __CLASS__, 'clear_password_reset_notice' ) ); | |
| add_action( 'login_form_validate_2fa', array( __CLASS__, 'login_form_validate_2fa' ) ); | |
| add_action( 'login_form_revalidate_2fa', array( __CLASS__, 'login_form_revalidate_2fa' ) ); | |
| add_action( 'show_user_profile', array( __CLASS__, 'user_two_factor_options' ) ); | |
| add_action( 'edit_user_profile', array( __CLASS__, 'user_two_factor_options' ) ); | |
| add_action( 'personal_options_update', array( __CLASS__, 'user_two_factor_options_update' ) ); | |
| add_action( 'edit_user_profile_update', array( __CLASS__, 'user_two_factor_options_update' ) ); | |
| add_filter( 'manage_users_columns', array( __CLASS__, 'filter_manage_users_columns' ) ); | |
| add_filter( 'wpmu_users_columns', array( __CLASS__, 'filter_manage_users_columns' ) ); | |
| add_filter( 'manage_users_custom_column', array( __CLASS__, 'manage_users_custom_column' ), 10, 3 ); | |
| /** | |
| * Keep track of all the user sessions for which we need to invalidate the | |
| * authentication cookies set during the initial password check. | |
| * | |
| * Is there a better way of doing this? | |
| */ | |
| add_action( 'set_auth_cookie', array( __CLASS__, 'collect_auth_cookie_tokens' ) ); | |
| add_action( 'set_logged_in_cookie', array( __CLASS__, 'collect_auth_cookie_tokens' ) ); | |
| // Run only after the core wp_authenticate_username_password() check. | |
| add_filter( 'authenticate', array( __CLASS__, 'filter_authenticate' ), 50 ); | |
| // Run as late as possible to prevent other plugins from unintentionally bypassing. | |
| add_filter( 'authenticate', array( __CLASS__, 'filter_authenticate_block_cookies' ), PHP_INT_MAX ); | |
| add_filter( 'attach_session_information', array( __CLASS__, 'filter_session_information' ), 10, 2 ); | |
| add_action( 'admin_init', array( __CLASS__, 'trigger_user_settings_action' ) ); | |
| add_filter( 'two_factor_providers', array( __CLASS__, 'enable_dummy_method_for_debug' ) ); | |
| $compat->init(); | |
| } |
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.
Thanks for the feedback! I’ve moved the plugin_action_links hook and callback into Two_Factor_Core::add_hooks() as suggested. Verified that the Settings link still appears correctly on the Plugins screen.
kasparsd
left a comment
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 is great, thank you!
|
Thank you very much @kasparsd |
What?
Adds a "Settings" link to the plugin action links on the Plugins screen in the WordPress admin.
Why?
The plugin currently does not display a “Settings” link under its name on the Plugins page (
/wp-admin/plugins.php).This makes it less intuitive for users to access the plugin’s configuration section (
/wp-admin/profile.php#application-passwords-section), which is standard behavior for most WordPress plugins.Fixes #<issue_number> (replace with the actual issue ID if one exists).
How?
Introduced a new function
two_factor_add_settings_action_link()intwo-factor.phpthat hooks into theplugin_action_links_{plugin_basename}filter to prepend a "Settings" link.The link directs users to
/wp-admin/profile.php#application-passwords-section.