无法加载媒体并收到“PHP警告:为Foreach(”“)提供的参数无效”

时间:2015-04-29 作者:Karolína Vyskočilová

如果我没有激活的调试模式,我在后端看不到任何媒体(在“媒体”菜单中,甚至在后期编辑器中创建的库中)。打开调试模式时:

define(\'WP_DEBUG\', true);

// Enable Debug logging to the /wp-content/debug.log file
define(\'WP_DEBUG_LOG\', true);

// Disable display of errors and warnings
define(\'WP_DEBUG_DISPLAY\', false);
@ini_set(\'display_errors\',0);if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');
我有以下错误。但是系统文件插件。php在第992行左右结束。有什么想法可以导致这个问题以及如何解决它?非常感谢,这是我的自定义主题。

[29-Apr-2015 22:23:50 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
[29-Apr-2015 22:23:50 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
[29-Apr-2015 22:23:50 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
[29-Apr-2015 22:23:51 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
[29-Apr-2015 22:23:51 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
[29-Apr-2015 22:23:51 UTC] PHP Warning:  Invalid argument supplied for foreach() in /data/web/virtuals/51889/virtual/www/domains/demo.kybernaut.cz/detsky-svet-masa/wp-admin/includes/plugin.php on line 1422
看起来这部分有问题:

//remove from menu
function remove_posts_menu() {
    remove_menu_page(\'edit.php\');
    remove_menu_page(\'edit.php?post_type=page\');
    remove_menu_page(\'edit-comments.php\' );
}
add_action(\'admin_init\', \'remove_posts_menu\');

1 个回复
最合适的回答,由SO网友:Karolína Vyskočilová 整理而成

@HeadMedic是对的,在我的第二段代码中,admin_init 应该是admin_menu. 这解决了我的问题,非常感谢你们!

更正的代码:

//remove from menu
function remove_posts_menu() {
    remove_menu_page(\'edit.php\');
    remove_menu_page(\'edit.php?post_type=page\');
    remove_menu_page(\'edit-comments.php\' );
}
add_action(\'admin_menu\', \'remove_posts_menu\');

结束