Function Reference: geodir_action_details_taxonomies

Summary

Output link to the posts categories and tags.

Global Values

$preview
(bool) (required) True of on a preview page. False if not.

Default: None
$post
(object) (required) The current post object.

Default: None

Package

GeoDirectory

Change Log

Since: 1.0.0

1.5.7 Modified to add parent categories if only sub category selected.

Filters

‘geodir_action_details_post_tags’ [Line: 1160]

‘geodir_details_taxonomies_tag_link’ [Line: 1203]

‘geodir_details_taxonomies_cat_link’ [Line: 1254]

‘geodir_details_taxonomies_output’ [Line: 1285]

Source File

geodir_action_details_taxonomies() is located in geodirectory_template_actions.php [Line: 1122]

Source Code

function geodir_action_details_taxonomies()
{
    global $preview, $post;?>
    

listing_type; $post_taxonomy = $post_type . 'category'; $post->{$post_taxonomy} = $post->post_category[$post_taxonomy]; } else { $post_type = $post->post_type; $post_taxonomy = $post_type . 'category'; } //{ $post_type_info = get_post_type_object($post_type); $listing_label = __($post_type_info->labels->singular_name, 'geodirectory'); if (!empty($post->post_tags)) { if (taxonomy_exists($post_type . '_tags')): $links = array(); $terms = array(); // to limit post tags $post_tags = trim($post->post_tags, ","); $post_id = isset($post->ID) ? $post->ID : ''; /** * Filter the post tags. * * Allows you to filter the post tags output on the details page of a post. * * @since 1.0.0 * @param string $post_tags A comma seperated list of tags. * @param int $post_id The current post id. */ $post_tags = apply_filters('geodir_action_details_post_tags', $post_tags, $post_id); $post->post_tags = $post_tags; $post_tags = explode(",", trim($post->post_tags, ",")); foreach ($post_tags as $post_term) { // fix slug creation order for tags & location $post_term = trim($post_term); $priority_location = false; if ($insert_term = term_exists($post_term, $post_type . '_tags')) { $term = get_term_by('id', $insert_term['term_id'], $post_type . '_tags'); } else { $post_country = isset($_REQUEST['post_country']) && $_REQUEST['post_country'] != '' ? sanitize_text_field($_REQUEST['post_country']) : NULL; $post_region = isset($_REQUEST['post_region']) && $_REQUEST['post_region'] != '' ? sanitize_text_field($_REQUEST['post_region']) : NULL; $post_city = isset($_REQUEST['post_city']) && $_REQUEST['post_city'] != '' ? sanitize_text_field($_REQUEST['post_city']) : NULL; $match_country = $post_country && sanitize_title($post_term) == sanitize_title($post_country) ? true : false; $match_region = $post_region && sanitize_title($post_term) == sanitize_title($post_region) ? true : false; $match_city = $post_city && sanitize_title($post_term) == sanitize_title($post_city) ? true : false; if ($match_country || $match_region || $match_city) { $priority_location = true; $term = get_term_by('name', $post_term, $post_type . '_tags'); } else { $insert_term = wp_insert_term($post_term, $post_type . '_tags'); $term = get_term_by('name', $post_term, $post_type . '_tags'); } } if (!is_wp_error($term) && is_object($term)) { // fix tag link on detail page if ($priority_location) { $tag_link = "$post_term"; /** * Filter the tag name on the details page. * * @since 1.5.6 * @param string $tag_link The tag link html. * @param object $term The tag term object. */ $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term); $links[] = $tag_link; } else { $tag_link = "$term->name"; /** This action is documented in geodirectory-template_actions.php */ $tag_link = apply_filters('geodir_details_taxonomies_tag_link',$tag_link,$term); $links[] = $tag_link; } $terms[] = $term; } // } if (!isset($listing_label)) { $listing_label = ''; } $taxonomies[$post_type . '_tags'] = wp_sprintf(__('%s Tags: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms); endif; } if (!empty($post->{$post_taxonomy})) { $links = array(); $terms = array(); $termsOrdered = array(); if (!is_array($post->{$post_taxonomy})) { $post_term = explode(",", trim($post->{$post_taxonomy}, ",")); } else { $post_term = $post->{$post_taxonomy}; if ($preview && !$is_backend_preview) { $post_term = geodir_add_parent_terms($post_term, $post_taxonomy); } } $post_term = array_unique($post_term); if (!empty($post_term)) { foreach ($post_term as $post_term) { $post_term = trim($post_term); if ($post_term != ''): $term = get_term_by('id', $post_term, $post_taxonomy); if (is_object($term)) { $term_link = "$term->name"; /** * Filter the category name on the details page. * * @since 1.5.6 * @param string $term_link The link html to the category. * @param object $term The category term object. */ $term_link = apply_filters('geodir_details_taxonomies_cat_link',$term_link,$term); $links[] = $term_link; $terms[] = $term; } endif; } // order alphabetically asort($links); foreach (array_keys($links) as $key) { $termsOrdered[$key] = $terms[$key]; } $terms = $termsOrdered; } if (!isset($listing_label)) { $listing_label = ''; } $taxonomies[$post_taxonomy] = wp_sprintf(__('%s Category: %l', 'geodirectory'), geodir_ucwords($listing_label), $links, (object)$terms); } /** * Filter the taxonomies array before output. * * @since 1.5.9 * @param array $taxonomies The array of cats and tags. * @param string $post_type The post type being output. * @param string $listing_label The post type label. * @param string $listing_label The post type label with ucwords function. */ $taxonomies = apply_filters('geodir_details_taxonomies_output',$taxonomies,$post_type,$listing_label,geodir_ucwords($listing_label)); if (isset($taxonomies[$post_taxonomy])) { echo '' . $taxonomies[$post_taxonomy] . ''; } if (isset($taxonomies[$post_type . '_tags'])) echo '' . $taxonomies[$post_type . '_tags'] . ''; ?>