| | |
| | | } |
| | | |
| | | /** |
| | | * Clear taxonomy list caches when terms are saved |
| | | * @param int $term_id |
| | | * @param int $tt_id |
| | | * @param string $taxonomy |
| | | * |
| | | * @return void |
| | | */ |
| | | add_action('edited_term', 'jvbClearTermListCache', 10, 3); |
| | | add_action('created_term', 'jvbClearTermListCache', 10, 3); |
| | | add_action('delete_term', 'jvbClearTermListCache', 10, 3); |
| | | |
| | | function jvbClearTermListCache(int $term_id, int $tt_id, string $taxonomy):void |
| | | { |
| | | // Check if this taxonomy has a corresponding list |
| | | $types = jvbGlobalDirectoryInfo(); |
| | | foreach ($types as $type) { |
| | | if ($type['slug'] === $taxonomy) { |
| | | // Delete the option to force regeneration |
| | | delete_option(BASE . $type['slug'] . '_list'); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // If this is a city and it's linked to other taxonomies, clear those too |
| | | if ($taxonomy === BASE.'city') { |
| | | foreach ($types as $type) { |
| | | if (!empty($type['links']) && in_array(BASE.'_city', $type['links'])) { |
| | | delete_option(BASE . $type['slug'] . '_list'); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Clear list caches when post types are saved |
| | | */ |
| | | add_action('save_post', 'jvbClearListCache', 10, 2); |
| | | function jvbClearListCache(int $post_id, \WP_Post $post):void |
| | | { |
| | | if (jvbNoSaveIt($post_id, $post)) { |
| | | return; |
| | | } |
| | | |
| | | // Get post type |
| | | $post_type = get_post_type($post_id); |
| | | |
| | | // Check if this post type has a corresponding list |
| | | $types = jvbGlobalDirectoryInfo(); |
| | | foreach ($types as $type) { |
| | | if ($type['slug'] === $post_type) { |
| | | // Delete the option to force regeneration |
| | | delete_option(BASE . $type['slug'] . '_list'); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param int $artistID |
| | | * @param string $taxonomy |
| | | * |