Example #1
0
function wpsight_listing_terms_shortcode($atts)
{
    $defaults = array('id' => get_the_ID(), 'link' => 'true', 'sep' => ' › ', 'term_before' => '', 'term_after' => '', 'before' => '', 'after' => '', 'taxonomy' => 'feature', 'wrap' => 'span');
    extract(shortcode_atts($defaults, $atts));
    // Set property-type
    if (WPSIGHT_DOMAIN == 'wpcasa' && $taxonomy == 'listing-type') {
        $taxonomy = 'property-type';
    }
    // Set property-category
    if (WPSIGHT_DOMAIN == 'wpcasa' && $taxonomy == 'listing-category') {
        $taxonomy = 'property-category';
    }
    // Get terms
    $terms = wpsight_get_the_term_list($id, $taxonomy, $sep, $term_before, $term_after, $link);
    // Stop if no terms
    if (is_wp_error($terms) || empty($terms)) {
        return false;
    }
    $output = sprintf('%1$s%3$s%2$s', $before, $after, $terms);
    // Optionally wrap shortcode in HTML tags
    if (!empty($wrap) && $wrap != 'false' && in_array($wrap, array_keys(wp_kses_allowed_html('post')))) {
        $output = sprintf('<%2$s class="listing-%3$s-terms-sc">%1$s</%2$s>', $output, $wrap, $taxonomy);
    }
    return apply_filters('wpsight_listing_terms_shortcode', $output, $terms, $atts);
}
Example #2
0
function wpsight_do_listing_details_title_actions($args = '', $instance = '')
{
    // Only on single listing page
    if (!is_listing_single()) {
        return;
    }
    // Get taxonomies
    $location = wpsight_get_the_term_list(get_the_ID(), 'location');
    $type = wpsight_get_the_term_list(get_the_ID(), 'listing-type', ', ');
    // Get correct instance settings
    if (isset($instance['listing_type'])) {
        $listing_type = $instance['listing_type'];
    } elseif (isset($instance['property_type'])) {
        $listing_type = $instance['property_type'];
    } else {
        $listing_type = false;
    }
    if (isset($instance['listing_location'])) {
        $listing_location = $instance['listing_location'];
    } elseif (isset($instance['property_location'])) {
        $listing_location = $instance['property_location'];
    } else {
        $listing_location = false;
    }
    // Display taxonomies in title
    $title_actions = '';
    if ($listing_type || $listing_location) {
        $title_actions .= '<div class="title-actions">' . "\n";
        if ($listing_location && !empty($location)) {
            $title_actions .= '<div class="title-listing-location">' . $location . '</div><!-- .title-listing-location -->' . "\n";
        }
        if ($listing_type && !empty($type)) {
            $title_actions .= '<div class="title-listing-type">' . $type . '</div><!-- .title-listing-type -->' . "\n";
        }
        $title_actions .= '</div><!-- .title-actions -->' . "\n";
    }
    echo $title_actions;
}