You can use an anonymous function so it’s only compatible with PHP version 5.3 and above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | add_action( 'admin_menu', function () { $position = 29; global $menu; $separator = [ 0 => '', 1 => 'read', 2 => 'separator' . $position, 3 => '', 4 => 'wp-menu-separator' ]; if (isset($menu[$position])) { $menu = array_splice($menu, $position, 0, $separator); } else { $menu[$position] = $separator; } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.