public function get_options(\WP_Post $post, array $box, \stdClass $taxonomy) { $preload = value($this->settings, 'preload'); $get_terms_args = ['hide_empty' => false]; if (is_array($preload)) { if (is_assoc($preload)) { $get_terms_args = $preload + $get_terms_args; } elseif (array_is_numeric($preload)) { $get_terms_args['include'] = $preload; } else { return $preload; } } elseif (is_integer($preload)) { $get_terms_args['number'] = $preload; } elseif (!$preload) { return []; } $get_terms_args = apply_filters('tf_preload_get_terms_args', $get_terms_args, $this->settings, $post, $box, $taxonomy); $get_terms_args = apply_filters(sprintf('tf_%s_preload_get_terms_args', $taxonomy->name), $get_terms_args, $this->settings, $post, $box, $taxonomy); return get_terms($taxonomy->name, $get_terms_args); }
/** * childNodesToArray * * @param array $children array containing SimpleXMLElements, most likely * derived from an xpath query * @param string $parentName local-name of the parent node * @access public * @return array */ public function childNodesToArray($children, $parentName = null, $nestedValues = false) { $result = array(); foreach ($children as $child) { if (!$this->isSimpleXMLElement($child)) { throw new InvalidArgumentException(sprintf('The input array must only contain SimpleXMLElements but contains %s', gettype($child))); } $localNamespaces = $child->getNamespaces(); $prefix = key($localNamespaces); $prefix = strlen($prefix) ? $prefix : null; $nsURL = current($localNamespaces); $name = $child->getName(); $oname = $name; $name = is_null($prefix) ? $name : $this->prefixKey($prefix, $name); if (count($children) < 2) { $result[$name] = $this->parseXML($child, $nestedValues); break; } if (isset($result[$name])) { if (is_array($result[$name]) && array_is_numeric($result[$name])) { $value = $this->parseXML($child, $nsURL, $prefix); if (is_array($value) && array_is_numeric($value)) { $result[$name] = array_merge($result[$name], $value); } else { $result[$name][] = $value; } } else { continue; } } else { $equals = $this->getEqualNodes($child, $prefix); if (count($equals) > 1) { if ($this->isEqualOrPluralOf($parentName, $oname)) { $result[] = $this->parseXML($child, $nestedValues); } else { $plural = $this->pluralize($oname); $plural = is_null($prefix) ? $plural : $this->prefixKey($prefix, $plural); if (isset($result[$plural]) && is_array($result[$plural])) { $result[$plural][] = $this->parseXML($child, $nestedValues); } elseif (count($children) !== count($equals)) { $result[$plural][] = $this->parseXML($child, $nestedValues); } else { $result[$name][] = $this->parseXML($child, $nestedValues); } } } else { $result[$name] = $this->parseXML($child, $nsURL, $nestedValues); } } } return $result; }