我正在構建我的第一個wordpress插件,錯誤日誌引發了以下錯誤。插件錯誤 - array_merge():參數#2不是數組
[06-Jul-2014 20:07:21 UTC] PHP Warning: array_merge(): Argument #2 is not an array in \wp-content\plugins\test-plugin\screen.php on line 49
[06-Jul-2014 20:07:21 UTC] PHP Warning: array_merge(): Argument #2 is not an array in \wp-content\plugins\test-plugin\screen.php on line 50
[06-Jul-2014 20:07:21 UTC] PHP Warning: end() expects parameter 1 to be array, null given in \wp-content\plugins\test-plugin\screen.php on line 323
[06-Jul-2014 20:07:21 UTC] PHP Warning: Invalid argument supplied for foreach() in \wp-content\plugins\test-plugin\screen.php on line 324
有關行的誤差49 & 50的代碼是:
function register_settings() {
global $menu;
global $submenu;
$this->menus = array_merge(array(), $menu);
$this->submenus = array_merge(array(), $submenu);
$this->settings = get_option($this->settings_name);
register_setting('admin-theme', $this->settings_name);
}
有關行的誤差323 & 324的代碼是:
function admin_menu() {
global $menu;
global $submenu;
// update menu
end($menu);
foreach ($menu as $k=>&$v){
$id = explode(' <span', $v[0]);
$slug = 'menu_'.strtolower(str_replace(' ','_',$id[0]));
$slug_hide = $slug.'_hide';
if($id[0] != NULL && $this->get_setting($slug) !== NULL){
$v[0] = $this->get_setting($slug). (isset($id[1]) ? ' <span '.$id[1] : '');
}
if($this->get_setting($slug_hide)){
unset($menu[$k]);
}
// update the submenu
if(isset($submenu[$v[2]])){
foreach ($submenu[$v[2]] as $key=>&$val){
$id = explode(' <span', $val[0]);
$slug_sub = $slug.'_'.strtolower(str_replace(' ','_',$id[0]));
$slug_sub_hide = $slug_sub.'_hide';
if($id[0] != NULL && $this->get_setting($slug_sub) !== NULL){
$val[0] = $this->get_setting($slug_sub). (isset($id[1]) ? ' <span '.$id[1] : '');
}
if($this->get_setting($slug_sub_hide)){
unset($submenu[$v[2]][$key]);
}
}
}
}
}
我似乎無法弄清楚,所以如果任何人可以幫助或指出我的權利方向它將不勝感激。
參數#2是不是數組 – Phantom