从管理栏中删除项目 this放置在functions.php中,从管理栏中删除了两个项目。 我想知道的是可以合并吗? $ WP_ADMIN_BAR-> remove_node('Fimify'); //这删除了幻想菜单。 $

问题描述 投票:0回答:1
在一个动作下结合吗?

// remove imagify from admin bar add_action('wp_before_admin_bar_render', function() { global $wp_admin_bar; $wp_admin_bar->remove_node('imagify'); // This removes the Imagify menu. }); // remove maintenance from admin bar add_action('wp_before_admin_bar_render', function() { global $wp_admin_bar; $wp_admin_bar->remove_node('maintenance_options'); // This removes the maintenance menu. });
管理,以使两部代码正常工作。想知道它是否可以减少。
    

您可以将两个WP_ADMIN_BAR-> remove_node()调用组合到单个操作钩中,以使代码更简洁。 您可以将两个单独的函数放在一个匿名函数中。
在这里您可以将它们结合在一起:

add_action('wp_before_admin_bar_render', function() { global $wp_admin_bar; $wp_admin_bar->remove_node('imagify'); // Remove the Imagify menu $wp_admin_bar->remove_node('maintenance_options'); // Remove the Maintenance menu });

php wordpress items
1个回答
0
投票

© www.soinside.com 2019 - 2025. All rights reserved.