diff --git a/inc/stream/namespace.php b/inc/stream/namespace.php index 01935e7..96cfa29 100644 --- a/inc/stream/namespace.php +++ b/inc/stream/namespace.php @@ -3,6 +3,7 @@ namespace HM\Platform\Security\Stream; use const HM\Platform\ROOT_DIR; +use WP_Admin_Bar; function bootstrap() { add_filter( 'wp_stream_admin_menu_title', function () : string { @@ -16,6 +17,7 @@ function bootstrap() { add_filter( 'site_option_wp_stream_network', __NAMESPACE__ . '\\default_stream_network_options' ); add_filter( 'default_site_option_wp_stream_network', __NAMESPACE__ . '\\default_stream_network_options' ); add_action( 'network_admin_menu', __NAMESPACE__ . '\\remove_stream_admin_pages', 11 ); + add_action( 'admin_bar_menu', __NAMESPACE__ . '\\override_network_admin_bar_menu', 100 ); require_once ROOT_DIR . '/vendor/humanmade/stream/stream.php'; } @@ -51,3 +53,27 @@ function remove_stream_admin_pages() { global $wp_stream; remove_submenu_page( $wp_stream->admin->records_page_slug, $wp_stream->admin->network->network_settings_page_slug ); } + +/** + * Override the Stream admin bar menu. + * + * @param WP_Admin_Bar $wp_admin_bar + */ +function override_network_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) { + $wp_admin_bar->remove_menu( 'network-admin-stream' ); + $href = add_query_arg( + [ + 'page' => wp_stream_get_instance()->admin->records_page_slug, + ], + network_admin_url( wp_stream_get_instance()->admin->admin_parent_page ) + ); + + $wp_admin_bar->add_menu( + [ + 'id' => 'network-admin-stream', + 'parent' => 'network-admin', + 'title' => esc_html__( 'Audit Log', 'hm-platform' ), + 'href' => esc_url( $href ), + ] + ); +}