WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: IM8 Box Hide] This error occurs when accessing the plugin! (6 posts)

  1. potel
    Member
    Posted 4 years ago #

    Hello, the plugin has a good functionality, the more this occurs the following error when I try to access it:
    Warning: Invalid argument supplied for foreach () in D: \ wamp \ www \ wordpteste \ wp-content \ plugins \ IM8-box-hide \ IM8-box-hide.php on line 133

    Warning: Invalid argument supplied for foreach () in D: \ wamp \ www \ wordpteste \ wp-content \ plugins \ IM8-box-hide \ IM8-box-hide.php on line 138

    What could it be?

    http://wordpress.org/extend/plugins/im8-box-hide/

  2. intermedi8
    Member
    Posted 4 years ago #

    Hi,
    can you please give me more details of ur wordpress configuration? Which version and which additional plugins you have installed? If u provide me with the informations im gonna fix the bug... thank you

    Greetz ... IM8

  3. straddieplastic
    Member
    Posted 4 years ago #

    to fix, replace

    foreach($wp_meta_boxes['post'] as $context)
    			foreach($context as $priority)
    				foreach($priority as $box)
    					array_push($this->postboxes,array($box['id'],$box['title']));
    
    		foreach($wp_meta_boxes['page'] as $context)
    			foreach($context as $priority)
    				foreach($priority as $box)
    					array_push($this->pageboxes,array($box['id'],$box['title']));

    with

    if ($wp_meta_boxes['post']) {
    		foreach($wp_meta_boxes['post'] as $context)
    			foreach($context as $priority)
    				foreach($priority as $box)
    					array_push($this->postboxes,array($box['id'],$box['title']));
    	}
    	if ($wp_meta_boxes['page']) {
    		foreach($wp_meta_boxes['page'] as $context)
    			foreach($context as $priority)
    				foreach($priority as $box)
    					array_push($this->pageboxes,array($box['id'],$box['title']));
    	}

    ie, wrap foreach with condition check, if ($wp_meta_boxes['page']) { ....

  4. intermedi8
    Member
    Posted 4 years ago #

    Great! Thanks for ur support straddieplastic!

    I will roll out a bugfix update ...

  5. Richard Tape
    Member
    Posted 4 years ago #

    Hi,

    Small errors too on lines 45 and 48 of im8-box-hide.php:

    Replace:

    foreach ($hide[$user_role]['post'] as $box => $value)
    			foreach (array('normal', 'advanced', 'side') as $context) remove_meta_box($box, 'post', $context);
    
    		foreach ($hide[$user_role]['page'] as $box => $value)
    			foreach (array('normal', 'advanced', 'side') as $context) remove_meta_box($box, 'page', $context);

    with

    if($hide[$user_role]['post']){
    		foreach ($hide[$user_role]['post'] as $box => $value)
    			foreach (array('normal', 'advanced', 'side') as $context) remove_meta_box($box, 'post', $context);
    		}
    
    		if($hide[$user_role]['page']){
    		foreach ($hide[$user_role]['page'] as $box => $value)
    			foreach (array('normal', 'advanced', 'side') as $context) remove_meta_box($box, 'page', $context);
    		}

    Seems to fix the similar issues (this is on WordPress 3.0 btw).

    Will you be implementing options for custom post types? Just a thought - I manage them myself at the moment and create/hide the meta boxes when I actually create the custom post types, but others may find this handy! Thanks for a great plugin.

  6. intermedi8
    Member
    Posted 4 years ago #

    Nice! I will fix this tomorrow and rollout the update... thanks!

    But i dont understand what u mean with options for custom post types? i guess u mean the same like for additional plugins? so u can disable metaboxes on these custom write pages?

Topic Closed

This topic has been closed to new replies.

About this Topic