Jake Vanderwerf
2026-04-15 c4aa5cdb5e90ad4b420e22772797d16980232a2b
inc/managers/SEO/render/Traits/_Helpers/arrayHelper.php
@@ -1,13 +1,20 @@
<?php
namespace JVBase\managers\SEO\render\Traits\_Helpers;
use JVBase\base\SchemaHelper;
if (!defined('ABSPATH')) {
   exit;
}
trait arrayHelper {
   protected function classArray(string $property, array $array, string $className):array
   {
      return array_filter($array, function ($item) use ($property, $className) {
      return array_filter(array_map(function ($item) {
         if (is_array($item) && array_key_exists('type', $item)) {
            $item = SchemaHelper::classFromConfig($item);
         }
         return $item;
      },$array), function ($item) use ($property, $className) {
         $test = class_exists($className) && is_a($item, $className);
         if (!$test) {
            error_log('[SEO]Item property '.$property.' is not an instance of '.$className);
@@ -17,7 +24,14 @@
   }
   protected function mixedArray(string $property, array $array, array $allowedTypes):array
   {
      return array_filter($array, function($item) use ($property, $allowedTypes) {
      return array_filter(array_map(function($item) {
         if (is_array($item) && array_key_exists('type', $item)) {
            return JVB()->schemaHelper()::classFromConfig($item);
         } else {
            return $item;
         }
      },$array), function($item) use ($property, $allowedTypes) {
         $test = in_array(gettype($item), $allowedTypes) || $this->testClasses($item, $allowedTypes);
         if (!$test) {
            error_log('[SEO]Item property '.$property.' is not an allowed type: '.print_r($item, true));