הרשמת עורך דין

term_id, $taxonomy, 'taxonomy'));

foreach ($ancestors as $ancestor_id) {
$ancestor = get_term((int) $ancestor_id, $taxonomy);

if ($ancestor && !is_wp_error($ancestor)) {
$name = pablo_basic_clean_text($ancestor->name);

if ($name !== ") {
$parts[] = $name;
}
}
}

$term_name = pablo_basic_clean_text($term->name);

if ($term_name !== ") {
$parts[] = $term_name;
}

return implode(' › ', array_filter($parts));
}
}

/**
* Author: pablo rotem
*/
if (!function_exists('pablo_basic_selected_term_names')) {
function pablo_basic_selected_term_names(string $taxonomy, array $ids): array
{
if ($taxonomy === " || !taxonomy_exists($taxonomy) || empty($ids)) {
return [];
}

$names = [];

foreach ($ids as $id) {
$term = get_term((int) $id, $taxonomy);

if ($term && !is_wp_error($term)) {
$name = pablo_basic_clean_text($term->name);

if ($name !== ") {
$names[] = $name;
}
}
}

return array_values(array_unique($names));
}
}

/**
* Author: pablo rotem
*/
if (!function_exists('pablo_basic_get_location_items')) {
function pablo_basic_get_location_items(string $taxonomy): array
{
if ($taxonomy === " || !taxonomy_exists($taxonomy)) {
return [];
}

$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
]);

if (is_wp_error($terms) || empty($terms)) {
return [];
}

$by_parent = [];
$printed = [];
$items = [];

foreach ($terms as $term) {
if ($term instanceof WP_Term) {
$by_parent[(int) $term->parent][] = $term;
}
}

/**
* Author: pablo rotem
* אם יש root כללי כמו ישראל / כל האזורים, מציגים את הילדים שלו כתחילת הרשימה.
*/
$start_parents = [0];

if (!empty($by_parent[0])) {
foreach ($by_parent[0] as $root_term) {
if (!$root_term instanceof WP_Term) {
continue;
}

$root_name = pablo_basic_clean_text($root_term->name);

if (
count($by_parent[0]) === 1 ||
in_array($root_name, ['כל האזורים', 'כל הארץ', 'ישראל', 'ארץ ישראל'], true)
) {
if (!empty($by_parent[(int) $root_term->term_id])) {
$start_parents = [(int) $root_term->term_id];
break;
}
}
}
}

$add_item = static function (WP_Term $term, int $level) use (&$items, &$printed, $taxonomy): void {
$term_id = (int) $term->term_id;

if (isset($printed[$term_id])) {
return;
}

$printed[$term_id] = true;

$name = pablo_basic_clean_text($term->name);
$path = pablo_basic_term_path($term, $taxonomy);

if ($name === ") {
return;
}

$items[] = [
'id' => $term_id,
'name' => $name,
'path' => $path,
'level' => max(0, $level),
];
};

$walk = static function (int $parent_id, int $level) use (&$walk, $by_parent, $add_item): void {
if (empty($by_parent[$parent_id])) {
return;
}

foreach ($by_parent[$parent_id] as $term) {
if (!$term instanceof WP_Term) {
continue;
}

$add_item($term, $level);
$walk((int) $term->term_id, $level + 1);
}
};

foreach ($start_parents as $parent_id) {
$walk((int) $parent_id, 0);
}

/**
* Author: pablo rotem
* fallback: אם term לא הודפס בגלל parent שבור, עדיין מציגים אותו.
*/
foreach ($terms as $term) {
if (!$term instanceof WP_Term) {
continue;
}

if (!isset($printed[(int) $term->term_id])) {
$level = count(get_ancestors((int) $term->term_id, $taxonomy, 'taxonomy'));
$add_item($term, $level);
}
}

return $items;
}
}

/**
* Author: pablo rotem
*/

/**
* Author: pablo rotem
*/
if (!function_exists('pablo_basic_get_specialty_items')) {
function pablo_basic_get_specialty_items(string $taxonomy): array
{
if ($taxonomy === " || !taxonomy_exists($taxonomy)) {
return [];
}

$terms = get_terms([
'taxonomy' => $taxonomy,
'hide_empty' => false,
'orderby' => 'name',
'order' => 'ASC',
]);

if (is_wp_error($terms) || empty($terms)) {
return [];
}

$by_parent = [];
$printed = [];
$items = [];

foreach ($terms as $term) {
if ($term instanceof WP_Term) {
$by_parent[(int) $term->parent][] = $term;
}
}

$add_item = static function (WP_Term $term, int $level) use (&$items, &$printed, $taxonomy): void {
$term_id = (int) $term->term_id;

if (isset($printed[$term_id])) {
return;
}

$printed[$term_id] = true;

$name = pablo_basic_clean_text($term->name);
$path = pablo_basic_term_path($term, $taxonomy);

if ($name === ") {
return;
}

$items[] = [
'id' => $term_id,
'name' => $name,
'path' => $path,
'level' => max(0, $level),
];
};

$walk = static function (int $parent_id, int $level) use (&$walk, $by_parent, $add_item): void {
if (empty($by_parent[$parent_id])) {
return;
}

foreach ($by_parent[$parent_id] as $term) {
if (!$term instanceof WP_Term) {
continue;
}

$add_item($term, $level);
$walk((int) $term->term_id, $level + 1);
}
};

$walk(0, 0);

/**
* Author: pablo rotem
* fallback: אם term לא הודפס בגלל parent שבור, עדיין מציגים אותו.
*/
foreach ($terms as $term) {
if (!$term instanceof WP_Term) {
continue;
}

if (!isset($printed[(int) $term->term_id])) {
$level = count(get_ancestors((int) $term->term_id, $taxonomy, 'taxonomy'));
$add_item($term, $level);
}
}

return $items;
}
}

/**
* Author: pablo rotem
*/
if (!function_exists('pablo_basic_render_specialty_dropdown')) {
function pablo_basic_render_specialty_dropdown(string $taxonomy, array $selected = []): void
{
$items = pablo_basic_get_specialty_items($taxonomy);
$selected = array_map('strval', $selected);

?>

טקסונומיית ההתמחויות לא נמצאה. נבדוק את זה לפני שממשיכים לשלב הבא.

לא נמצאו התמחויות בטקסונומיה.