Skip to content

Conversation

@hardikRathi
Copy link
Contributor

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() in two-factor.php that hooks into the plugin_action_links_{plugin_basename} filter to prepend a "Settings" link.
The link directs users to /wp-admin/profile.php#application-passwords-section.

add_filter(
	'plugin_action_links_' . plugin_basename( __FILE__ ),
	'two_factor_add_settings_action_link'
);

Testing Instructions

1. Install and activate this branch of the plugin.
2. Navigate to Plugins → Installed Plugins.
3. Verify that a “Settings” link appears below the Two-Factor plugin name.
4. Click the link and confirm it redirects correctly to /wp-admin/profile.php#application-passwords-section.


Changelog Entry

Added - Settings action link on the Plugins screen for quick navigation to the plugin's configuration section.

Copy link
Collaborator

@kasparsd kasparsd left a 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(
Copy link
Collaborator

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?

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();
}

Copy link
Contributor Author

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.

Copy link
Collaborator

@kasparsd kasparsd left a 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!

@kasparsd kasparsd merged commit c9200d5 into WordPress:master Dec 12, 2025
27 checks passed
@hardikRathi
Copy link
Contributor Author

Thank you very much @kasparsd

@hardikRathi hardikRathi deleted the add-settings-action-link branch December 12, 2025 09:51
@jeffpaul jeffpaul added this to the 0.15.0 milestone Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants