在WordPress中,当注册管理页面或自定义帖子类型时,我们可以指定menu_position。但是,如果两个页面共享相同的menu_position,则只会显示其中一个页面。
在像WordPress这样的多插件/多开发者环境中,如何避免这样的冲突?如何检查menu_position是否尚未执行?
从5到100甚至null的任何值都可能导致冲突。
发布于 2014-03-13 23:08:44
可能不是最好的解决方案,但为了将风险降到最低,请尝试使用小数来定位:)而不是"3“尝试使用"3.1","3.2","3.3”etc...another方法可能是使用类似如下的函数:
function get_free_menu_position($start, $increment = 0.3)
{
foreach ($GLOBALS['menu'] as $key => $menu) {
$menus_positions[] = $key;
}
if (!in_array($start, $menus_positions)) return $start;
/* the position is already reserved find the closet one */
while (in_array($start, $menus_positions)) {
$start += $increment;
}
return $start;
}为了给你最接近的空位,你want....You可以阅读更多关于它的信息here
https://stackoverflow.com/questions/21906500
复制相似问题