Skip to content

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

@theperfectwill

Description

@theperfectwill

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

Metadata

Metadata

Labels

📃 Code ReviewAll Discussion Related To WPonion's Code Review.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions