Skip to content

Commit 98f8893

Browse files
author
Zed
committed
Moved workaround for bbPress frontend profile edit screen crash to two-factor-compat class;
Also changed function check from bbp_is_user_home_edit() to bbp_is_single_user_edit() as this is more generally used
1 parent 1f486c5 commit 98f8893

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

class-two-factor-compat.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ public function init() {
2525
* @see https://wordpress.org/plugins/jetpack/
2626
*/
2727
add_filter( 'two_factor_rememberme', array( $this, 'jetpack_rememberme' ) );
28+
29+
/**
30+
* bbPress
31+
*
32+
* Workaround for profile page breakage
33+
* @see https://github.com/WordPress/two-factor/issues/175
34+
*/
35+
add_action( 'wp', array( $this, 'bbpress_remove_twofactor' ) );
2836
}
2937

3038
/**
@@ -52,4 +60,16 @@ public function jetpack_rememberme( $rememberme ) {
5260
public function jetpack_is_sso_active() {
5361
return ( method_exists( 'Jetpack', 'is_module_active' ) && Jetpack::is_module_active( 'sso' ) );
5462
}
63+
64+
/**
65+
* Helper function to apply bbPress workaround at the right time.
66+
*
67+
* @return void
68+
*/
69+
public function bbpress_remove_twofactor() {
70+
if ( function_exists('bbp_is_single_user_edit') && bbp_is_single_user_edit() ) {
71+
remove_action( 'show_user_profile', array( 'Two_Factor_Core', 'user_two_factor_options' ) );
72+
remove_action( 'edit_user_profile', array( 'Two_Factor_Core', 'user_two_factor_options' ) );
73+
}
74+
}
5575
}

class-two-factor-core.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -932,11 +932,7 @@ public static function manage_users_custom_column( $output, $column_name, $user_
932932
* @param WP_User $user WP_User object of the logged-in user.
933933
*/
934934
public static function user_two_factor_options( $user ) {
935-
936-
/* workaround for two factor options crashing bbpress' profile page */
937-
if ( function_exists('bbp_is_user_home_edit') && bbp_is_user_home_edit() ) return;
938-
/* end workaround */
939-
935+
940936
wp_enqueue_style( 'user-edit-2fa', plugins_url( 'user-edit.css', __FILE__ ), array(), TWO_FACTOR_VERSION );
941937

942938
$enabled_providers = array_keys( self::get_available_providers_for_user( $user ) );

0 commit comments

Comments
 (0)