0

if I don't have active debug mode, I can't see any media in back end (in Media menu or even as in created gallery in a post editor). When I turn on debug mode:

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__) . '/');

I've got following error. But system file plugin.php ends at line 992 or so. Any ideas what can cause this problem and how to solve it? Thanks a lot, it's my custom theme.

[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

It looks like this part is causing troubles:

//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');
  • 2
    You are looking in the wrong plugin.php (includes/plugin.php) - your error is in wp-admin/includes/plugin.php, within the function remove_submenu_page() – Matt van Andel Apr 29 '15 at 22:39
  • 2
    In your second code snippet, admin_init should be admin_menu – TheDeadMedic Apr 30 '15 at 12:46
1

@TheDeadMedic was right, in my second code snippet, admin_init should be admin_menu. That solved my problem, thanks a lot to all of you!

Corrected code:

//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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.