Beispiel #1
0
/**  
 *	Replicate compare function of the theme since I can't implement it in my own template
 */
function build_compare_table($atts)
{
    $defaults = array('id' => get_the_ID(), 'before' => '', 'after' => '', 'empty' => 'true', 'wrap' => 'div');
    extract(shortcode_atts($defaults, $atts));
    // Open table
    $details = '<table class="table table-striped table-compare">';
    // Add listing ID first
    $details .= '<tr class="listing-details-sc-detail table-compare-id">';
    $details .= '<td class="table-compare-label">' . __('ID', 'wpsight') . ':</td>';
    $details .= '<td class="table-compare-value">' . wpsight_get_listing_id() . '</td>';
    $details .= '</tr><!-- .table-compare-id -->';
    // Loop through standard details
    foreach (wpsight_standard_details() as $detail => $v) {
        // Don't show detail if label is emtpy in options
        $standard_details_option = wpsight_get_option($detail);
        if (empty($standard_details_option['label'])) {
            continue;
        }
        // Apply filter to optionally deactivate single detail
        if (apply_filters('wpsight_listing_details_table_' . $detail, true) != true) {
            continue;
        }
        $detail_meta = get_post_meta($id, '_' . $detail, true);
        if (!$detail_meta && $empty != 'true') {
            continue;
        }
        $detail_value = $detail_meta ? $detail_meta . ' ' . wpsight_get_measurement_units($v['unit']) : __('n/d', 'wpsight');
        $details .= '<tr class="listing-details-sc-detail ' . $detail . '">';
        $details .= '<td class="table-compare-label">' . $v['label'] . ':</td>';
        $details .= '<td class="table-compare-value">' . $detail_value . '</td>';
        $details .= '</tr><!-- .listing-details-sc-' . $detail . ' -->';
    }
    // Add listing price at the end
    $details .= '<tr class="listing-details-sc-detail table-compare-price">';
    $details .= '<td class="table-compare-value" colspan="2">' . wpsight_get_price() . '</td>';
    $details .= '</tr><!-- .table-compare-price -->';
    // Close table
    $details .= '</table><!-- .table-compare -->';
    // $output = sprintf( '%1$s%3$s%2$s', $before, $after, $details );
    // // 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-details-table-sc">%1$s</%2$s>', $output, $wrap );
    // return apply_filters( 'wpsight_listing_details_table_shortcode', $output, $atts );
    return $details;
}
Beispiel #2
0
function wpsight_listings_custom_columns($column)
{
    $post_id = get_the_ID();
    switch ($column) {
        case 'listing_details':
            echo '<strong>ID: </strong>' . wpsight_get_listing_id($post_id) . '<br />';
            echo __('Location', 'wpsight') . ': ' . get_the_term_list($post_id, 'location', '', ', ', '') . '<br />';
            if (taxonomy_exists('property-type')) {
                echo __('Type', 'wpsight') . ': ' . get_the_term_list($post_id, 'property-type', '', ', ', '') . '<br />';
            }
            if (has_term('', 'listing-category', $post_id)) {
                echo __('Category', 'wpsight') . ': ' . get_the_term_list($post_id, 'listing-category', '', ', ', '');
            }
            if (has_term('', 'property-category', $post_id)) {
                echo __('Category', 'wpsight') . ': ' . get_the_term_list($post_id, 'property-category', '', ', ', '');
            }
            break;
        case 'listing_price':
            echo wpsight_get_price();
            break;
        case 'listing_agent':
            echo get_the_author();
            if (current_user_can('edit_users')) {
                echo '<br /><a href="' . admin_url('user-edit.php?user_id=' . get_the_author_meta('ID'), 'http') . '">' . __('See profile', 'wpsight') . '</a>';
            }
            break;
        case 'listing_features':
            echo get_the_term_list($post_id, 'feature', '', ', ', '') . '<br />';
            break;
        case 'listing_image':
            echo get_the_post_thumbnail($post_id, 'thumbnail');
            break;
    }
}
Beispiel #3
0
/**
 * Echo formatted listing price
 *
 * @since 1.0
 */
function wpsight_price($post_id = '')
{
    echo wpsight_get_price($post_id);
}