Skip to content

Commit

Permalink
Add a filter to provide fine grained control over user caps
Browse files Browse the repository at this point in the history
  • Loading branch information
nlemoine committed Jan 17, 2025
1 parent e52e6a9 commit 86c82c7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wp-environment-switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ function get_translated_url( string $environment_url ): string {
* Register the admin environment switcher in the admin bar.
*/
function register_admin_bar(): void {
/**
* Filter the ability to show the environment switcher in the admin bar.
*
* @param bool $can_show_menu The current environment.
*/
$can_show_menu = (bool) apply_filters( 'wp_environment_switcher_can_show_menu', current_user_can( 'view_environment_switcher' ) );

// Check if the user has permission to view the switcher.
if ( ! current_user_can( 'view_environment_switcher' ) ) {
if ( ! $can_show_menu ) {
return;
}

Expand Down

0 comments on commit 86c82c7

Please sign in to comment.