From 6986da8185300ac37aa641776f44975dd7074db8 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Wed, 17 Apr 2019 11:10:05 +0700 Subject: [PATCH 1/2] Override the admin bar item It shows as "Stream", elsewhere we filter this, but Stream doesn't have a filter for this perticular label. --- inc/stream/namespace.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/inc/stream/namespace.php b/inc/stream/namespace.php index 01935e7..5f3b89d 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( + array( + '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( + array( + 'id' => 'network-admin-stream', + 'parent' => 'network-admin', + 'title' => esc_html__( 'Audit Log', 'hm-platform' ), + 'href' => esc_url( $href ), + ) + ); +} From 059fe095f723a62bd529baf68fd0da43eb5ac682 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Mon, 29 Apr 2019 11:18:43 +0700 Subject: [PATCH 2/2] Short array --- inc/stream/namespace.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/stream/namespace.php b/inc/stream/namespace.php index 5f3b89d..96cfa29 100644 --- a/inc/stream/namespace.php +++ b/inc/stream/namespace.php @@ -62,18 +62,18 @@ function remove_stream_admin_pages() { function override_network_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ) { $wp_admin_bar->remove_menu( 'network-admin-stream' ); $href = add_query_arg( - array( + [ '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( - array( + [ 'id' => 'network-admin-stream', 'parent' => 'network-admin', 'title' => esc_html__( 'Audit Log', 'hm-platform' ), 'href' => esc_url( $href ), - ) + ] ); }