HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/school/wp-content/themes/blocksy/inc/helpers/cpt.php
<?php

function blocksy_get_taxonomies_for_cpt($post_type, $args = []) {
	$args = wp_parse_args($args, [
		'return_empty' => false
	]);

	if ($post_type === 'product') {
		return [
			'product_cat' => __('Category', 'blocksy'),
			'product_tag' => __('Tag', 'blocksy')
		];
	}

	$result = [];

	$taxonomies = array_values(array_diff(
		get_object_taxonomies($post_type),
		['post_format']
	));

	if (count($taxonomies) === 0) {
		if ($args['return_empty']) {
			return [];
		}

		return [
			'default' => __('Default', 'blocksy')
		];
	}

	foreach ($taxonomies as $single_taxonomy) {
		$taxonomy_object = get_taxonomy($single_taxonomy);
		$result[$single_taxonomy] = $taxonomy_object->label;
	}

	return $result;
}