| 1 |
<?php |
| 2 |
/** |
| 3 |
* Helpers for the taxonomy selector on the XML sitemap settings page. |
| 4 |
* |
| 5 |
* @package Metasync |
| 6 |
*/ |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if (!function_exists('metasync_get_sitemap_taxonomy_picker_taxonomies')) { |
| 13 |
/** |
| 14 |
* Filter registered taxonomies to the ones suitable for the sitemap picker. |
| 15 |
* |
| 16 |
* @param array $taxonomies Public taxonomy objects returned by WordPress. |
| 17 |
* @return array Taxonomy objects that can be selected in sitemap settings. |
| 18 |
*/ |
| 19 |
function metasync_get_sitemap_taxonomy_picker_taxonomies($taxonomies) { |
| 20 |
$excluded_taxonomies = [ |
| 21 |
'product_shipping_class', |
| 22 |
'link_category', |
| 23 |
'nav_menu', |
| 24 |
'wp_pattern_category', |
| 25 |
'template_tag', |
| 26 |
'template_bundle', |
| 27 |
]; |
| 28 |
|
| 29 |
if (!current_theme_supports('post-formats')) { |
| 30 |
$excluded_taxonomies[] = 'post_format'; |
| 31 |
} |
| 32 |
|
| 33 |
$filtered_taxonomies = []; |
| 34 |
foreach ((array) $taxonomies as $taxonomy) { |
| 35 |
if (!is_object($taxonomy) || empty($taxonomy->name)) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
if (in_array($taxonomy->name, $excluded_taxonomies, true)) { |
| 40 |
continue; |
| 41 |
} |
| 42 |
|
| 43 |
if (!is_taxonomy_viewable($taxonomy)) { |
| 44 |
continue; |
| 45 |
} |
| 46 |
|
| 47 |
$filtered_taxonomies[] = $taxonomy; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Allow integrations to remove additional taxonomies from the picker. |
| 52 |
* |
| 53 |
* @param array $filtered_taxonomies Taxonomies that passed the defaults. |
| 54 |
* @param array $taxonomies Original public taxonomy objects. |
| 55 |
*/ |
| 56 |
return apply_filters( |
| 57 |
'metasync_sitemap_taxonomy_picker_taxonomies', |
| 58 |
$filtered_taxonomies, |
| 59 |
$taxonomies |
| 60 |
); |
| 61 |
} |
| 62 |
} |
| 63 |
|