From a6a0b55c132e7c41b4e91b014f7bb4705e2466c2 Mon Sep 17 00:00:00 2001 From: sksaju Date: Mon, 11 Mar 2024 02:16:46 +0600 Subject: [PATCH] remove comments from admin menu and bar --- .../AdminCustomizations/Customizations.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/includes/classes/AdminCustomizations/Customizations.php b/includes/classes/AdminCustomizations/Customizations.php index 7eafdd4..862ba96 100644 --- a/includes/classes/AdminCustomizations/Customizations.php +++ b/includes/classes/AdminCustomizations/Customizations.php @@ -28,6 +28,10 @@ public function setup() { add_action( 'admin_bar_menu', [ $this, 'add_about_menu' ], 11 ); add_action( 'admin_menu', [ $this, 'register_admin_pages' ] ); add_filter( 'admin_title', [ $this, 'admin_title_fix' ], 10, 2 ); + + // Remove comments-related UI elements + add_action( 'admin_menu', [ $this, 'remove_comments_admin_menus' ] ); + add_action( 'wp_before_admin_bar_render', [ $this, 'remove_comments_admin_bar_links' ] ); } /** @@ -195,4 +199,23 @@ public function filter_admin_footer_text() { $new_text = sprintf( __( 'Thank you for creating with WordPress and 10up.', 'tenup' ) ); return $new_text; } + + /** + * Remove comments admin menus + * + * @return void + */ + public function remove_comments_admin_menus() { + remove_menu_page( 'edit-comments.php' ); + } + + /** + * Remove comments admin bar links + * + * @return void + */ + public function remove_comments_admin_bar_links() { + global $wp_admin_bar; + $wp_admin_bar->remove_menu( 'comments' ); + } }