Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code Review] wponion_is_array Check Needed for Admin Pages with No Underlying Code Yet #422

Open
theperfectwill opened this issue Dec 15, 2022 · 0 comments
Assignees
Labels
📃 Code Review All Discussion Related To WPonion's Code Review.

Comments

@theperfectwill
Copy link
Member

theperfectwill commented Dec 15, 2022

Review

At line: https://github.com/wponion/wponion/blob/master/includes/builder/helper/container/class-functions.php#L49

We need to add is_array or wponion_is_array check.

This is to avoid:

Warning: foreach() argument must be of type array|object, bool given in /plugins/wponion/includes/builder/helper/container/class-functions.php

Which happens when generating an admin page with no coded options code yet.

Screenshot

image

Fix

/**
  * Returns First Container Instance.
  *
  * @return false|\WPO\Container
*/
public function first_container() {
  /* @var \WPO\Container $container */
  if ( wponion_is_array( $this->containers() ) ) {
	  foreach ( $this->containers() as $key => $container ) {
		  if ( wpo_is_container( $container ) && false === $container->is_disabled() ) {
			  return $container;
		  }
	  }
	  return false;
  }
  return false;
}

Result

image

@theperfectwill theperfectwill added the 📃 Code Review All Discussion Related To WPonion's Code Review. label Dec 15, 2022
@theperfectwill theperfectwill changed the title [Code Review] Module / File Name Is Array Check Needed for Admin Pages with No Underlying Code Yet Dec 15, 2022
@theperfectwill theperfectwill changed the title Is Array Check Needed for Admin Pages with No Underlying Code Yet wponion_is_array Check Needed for Admin Pages with No Underlying Code Yet Dec 15, 2022
@theperfectwill theperfectwill changed the title wponion_is_array Check Needed for Admin Pages with No Underlying Code Yet [Code Review] wponion_is_array Check Needed for Admin Pages with No Underlying Code Yet Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📃 Code Review All Discussion Related To WPonion's Code Review.
Projects
None yet
Development

No branches or pull requests

2 participants