Fact Maven Corp. on "Unable to hide all submenus items using foreach construct"

ساخت وبلاگ

I made a function to remove certain submenu items in the admin dashboard using remove_submenu_page:

$submenu = array( 'tools.php' => 'tools.php', // Tools > Available Tools 'options-general.php' => 'options-writing.php', // Settings > Writing 'options-general.php' => 'options-discussion.php' // Settings > Discussion );
foreach ( $submenu as $main => $sub ) { remove_submenu_page( $main, $sub );
}

All of items are hidden except for the Settings > Writing menu. It looks like it has to due with the fact that I am also hidding another submenu under Settings (Settings > Discussion), but I am not sure why it's being "skipped".

I could just do the following which would fix this:

remove_submenu_page( 'tools.php', 'tools.php' ); // Tools > Available Tools
remove_submenu_page( 'options-general.php', 'options-writing.php' ); // Settings > Writing
remove_submenu_page( 'options-general.php', 'options-discussion.php' ); // Settings > Discussion

But I want to use the foreach method instead and to understand why this logic isn't working 100%. Any help is appreciated.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 181 تاريخ : شنبه 22 خرداد 1395 ساعت: 7:47