admin管理员组文章数量:1391943
After a third-party developer was used to reconnect our calendar with the Google Calendar API 3, we found that our .../wp_admin/error_log infinitely wrote:
[14-Apr-2015 11:46:59 America/New_York] PHP Warning: in_array() expects parameter 2 to be array, null given in /home/USERFOLDER/public_html/wp-content/themes/THEMENAME/functions.php on line 2410
We have disabled writing to the error log, as it literally repeats that error until the HDD fills. In the functions.php file, line 2410 referenced in the error above is blank; the code around it is as follows:
function THEMENAME_sort_terms_hierarchicaly($cats, Array &$into, $parentId = 0, $level = 0){
foreach ($cats as $i => $cat) {
if ($cat->parent == $parentId) {
$into[$cat->term_id] = $cat;
$into[$cat->term_id]->level = $level;
unset($cats[$i]);
}
}
///THIS IS LINE 2410
$level++;
foreach ($into as $topCat) {
$topCat->children = array();
THEMENAME_sort_terms_hierarchicaly($cats, $topCat->children, $topCat->term_id, $level);
}
return $into;
}
Howdy_McGee points out below that in_array() is not within the code snippet, I am reviewing the 6 in_array(...) instances from the functions.php page but have not yet found the issue.
These first two are likely more precedent as they fall within the //Admin Section of the functions.php code.
// Adding is login page function
function is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
Other in_array(..) from admin section:
// Remove unwanted items from admin menu
function THEMENAME_remove_admin_menu_items() {
$remove_menu_items = array(__('Dashboard'),__('Posts'),__('Media'),__('Pages'),__('Comments'),__('Appearance'),__('Plugins'),__('Users'),__('Tools'),__('Settings'),);
global $menu;
end ($menu);
while (prev($menu)){
$item = explode(' ',$menu[key($menu)][0]);
if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
unset($menu[key($menu)]);}
}
}
Is there something here that I have missed that would reference line 2410 and cause this error? Do I need to rewrite each of my...
in_array(x,$y)
with... ?
is_array($y) && in_array(x,$y)
After a third-party developer was used to reconnect our calendar with the Google Calendar API 3, we found that our .../wp_admin/error_log infinitely wrote:
[14-Apr-2015 11:46:59 America/New_York] PHP Warning: in_array() expects parameter 2 to be array, null given in /home/USERFOLDER/public_html/wp-content/themes/THEMENAME/functions.php on line 2410
We have disabled writing to the error log, as it literally repeats that error until the HDD fills. In the functions.php file, line 2410 referenced in the error above is blank; the code around it is as follows:
function THEMENAME_sort_terms_hierarchicaly($cats, Array &$into, $parentId = 0, $level = 0){
foreach ($cats as $i => $cat) {
if ($cat->parent == $parentId) {
$into[$cat->term_id] = $cat;
$into[$cat->term_id]->level = $level;
unset($cats[$i]);
}
}
///THIS IS LINE 2410
$level++;
foreach ($into as $topCat) {
$topCat->children = array();
THEMENAME_sort_terms_hierarchicaly($cats, $topCat->children, $topCat->term_id, $level);
}
return $into;
}
Howdy_McGee points out below that in_array() is not within the code snippet, I am reviewing the 6 in_array(...) instances from the functions.php page but have not yet found the issue.
These first two are likely more precedent as they fall within the //Admin Section of the functions.php code.
// Adding is login page function
function is_login_page() {
return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));
}
Other in_array(..) from admin section:
// Remove unwanted items from admin menu
function THEMENAME_remove_admin_menu_items() {
$remove_menu_items = array(__('Dashboard'),__('Posts'),__('Media'),__('Pages'),__('Comments'),__('Appearance'),__('Plugins'),__('Users'),__('Tools'),__('Settings'),);
global $menu;
end ($menu);
while (prev($menu)){
$item = explode(' ',$menu[key($menu)][0]);
if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
unset($menu[key($menu)]);}
}
}
Is there something here that I have missed that would reference line 2410 and cause this error? Do I need to rewrite each of my...
in_array(x,$y)
with... ?
is_array($y) && in_array(x,$y)
Share
Improve this question
edited Apr 15, 2015 at 15:54
beta208
asked Apr 15, 2015 at 13:26
beta208beta208
1911 silver badge13 bronze badges
4
|
1 Answer
Reset to default 0In case you use a "child theme", i would search also in the parent themes function.php
@see https://codex.wordpress/Child_Themes
本文标签: wp adminWhat is wrong with functionsphp Fills error log with same error
版权声明:本文标题:wp admin - What is wrong with functions.php? Fills error log with same error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744682703a2619509.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
in_array()
in the code you posted. Search your file forin_array()
calls and every instance add a conditional to verify what is given is! empty()
– Howdy_McGee ♦ Commented Apr 15, 2015 at 13:382410
of yourfunctions.php
- neither of those snippets should be the cause of the problem, because in both cases argument 2 is always an array. – TheDeadMedic Commented Apr 16, 2015 at 8:40