/** * Section Install Type * * @since ... * * @param $available string * * @return string */ function section_install_type($available) { if (isset($available['custom'][$this->class_name])) { return 'custom'; } elseif (isset($available['child'][$this->class_name])) { return 'child'; } elseif (isset($available['parent'][$this->class_name])) { return 'parent'; } else { /** * We dont know the type, could be a 3rd party plugin. */ $results = array_search_ext($available, $this->class_name, true); if (is_array($results) && isset($results[0]['keys'])) { return $results[0]['keys'][0]; } } }
/** * Search in an array, return full info. */ function array_search_ext($arr, $search, $exact = true, $trav_keys = null) { if (!is_array($arr) || !$search || $trav_keys && !is_array($trav_keys)) { return false; } $res_arr = array(); foreach ($arr as $key => $val) { $used_keys = $trav_keys ? array_merge($trav_keys, array($key)) : array($key); if ($key === $search || !$exact && strpos(strtolower($key), strtolower($search)) !== false) { $res_arr[] = array('type' => "key", 'hit' => $key, 'keys' => $used_keys, 'val' => $val); } if (is_array($val) && ($children_res = array_search_ext($val, $search, $exact, $used_keys))) { $res_arr = array_merge($res_arr, $children_res); } else { if ($val === $search || !$exact && strpos(strtolower($val), strtolower($search)) !== false) { $res_arr[] = array('type' => "val", 'hit' => $val, 'keys' => $used_keys, 'val' => $val); } } } return $res_arr ? $res_arr : false; }