Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/helpers/cpt.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + function blocksy_get_taxonomies_for_cpt($post_type, $args = []) {
4 + $args = wp_parse_args($args, [
5 + 'return_empty' => false
6 + ]);
7 +
8 + if ($post_type === 'product') {
9 + return [
10 + 'product_cat' => __('Category', 'blocksy'),
11 + 'product_tag' => __('Tag', 'blocksy')
12 + ];
13 + }
14 +
15 + $result = [];
16 +
17 + $taxonomies = array_values(array_diff(
18 + get_object_taxonomies($post_type),
19 + ['post_format']
20 + ));
21 +
22 + if (count($taxonomies) === 0) {
23 + if ($args['return_empty']) {
24 + return [];
25 + }
26 +
27 + return [
28 + 'default' => __('Default', 'blocksy')
29 + ];
30 + }
31 +
32 + foreach ($taxonomies as $single_taxonomy) {
33 + $taxonomy_object = get_taxonomy($single_taxonomy);
34 + $result[$single_taxonomy] = $taxonomy_object->label;
35 + }
36 +
37 + return $result;
38 + }
39 +