Skip to content

Commit

Permalink
RDV: Remove the wpcom_admin_interface hook for the admin_menu hook
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanUngureanu committed Dec 18, 2024
1 parent f52f223 commit 7869cd9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
4 changes: 4 additions & 0 deletions projects/packages/jetpack-mu-wpcom/changelog/fix-wp-admin-rdv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Exclude the wpcom_admin_interface from the admin_menu action
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ function wpcom_admin_get_user_option_jetpack( $value ) {
add_filter( 'get_user_option_jetpack_admin_menu_preferred_views', 'wpcom_admin_get_user_option_jetpack' );
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );

add_action(
'admin_menu',
function () {
remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
},
PHP_INT_MIN
);

add_action(
'admin_menu',
function () {
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );
},
PHP_INT_MAX
);
/**
* Hides the "View" switcher on WP Admin screens enforced by the "Remove duplicate views" experiment.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ function current_user_has_wpcom_account() {
* @return bool
*/
function wpcom_is_using_default_admin_menu() {
remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
$option = get_option( 'wpcom_admin_interface' ) !== 'wp-admin';
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );

return $option;
return get_option( 'wpcom_admin_interface' ) !== 'wp-admin';
}

/**
Expand Down
4 changes: 4 additions & 0 deletions projects/packages/masterbar/changelog/fix-wp-admin-rdv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Exclude the wpcom_admin_interface from the admin_menu action
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,7 @@ public function use_wp_admin_interface() {
* @return bool
*/
public function is_using_default_admin_menu() {
remove_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option' );
$option = get_option( 'wpcom_admin_interface' ) !== 'wp-admin';
if ( function_exists( 'wpcom_admin_interface_pre_get_option' ) ) {
add_filter( 'pre_option_wpcom_admin_interface', 'wpcom_admin_interface_pre_get_option', 10 );
}

return $option;
return get_option( 'wpcom_admin_interface' ) !== 'wp-admin';
}

/**
Expand Down

0 comments on commit 7869cd9

Please sign in to comment.