rep__listing_attributes_html()

This function, is used to generate HTML representation for listing attributes based on the provided data array and the post ID of the listing.

Namespace

REP_Malcolm

Parameters

$data

array

Key value pair of attributes to list

$post_id

int

Post ID of the listing

Return

string

Listing attributes

Source

File: \includes\rep-helper-functions.php

function rep__listing_attributes_html( $data, $post_id ){

    $attributes = [];

    $attr_classes = array(
        'bedrooms' => 'rep-bedroom',
        'bathrooms' => 'rep-bathroom',
        'living_areas' => 'rep-livingroom',
        'total_car_accom' => 'rep-carpark',
        'property_type' => 'rep-type',
        'landarea' => 'rep-landarea',
        'buildarea' => 'rep-buildarea'
    );

    if( is_array( $data ) ) foreach( $data as $key ){
        $value = lp__get_field_value( $key, $post_id );
        if( in_array( $key, ['buildarea', 'landarea'] ) && $value ){
            $value .= lp__get_field_value( "{$key}_unit", $post_id );
        }
        if( in_array( $key, ['property_type'] ) && $value ){
            $value = lp__serialize_to_str(lp__get_field_value( $key, $post_id ));
        }
        $attributes[ lp__array_key_value( $key, $attr_classes, $key ) ] = $value;
    }

    return lp__data_list_html( $attributes, array(
        'el' => 'div',
        'child_el' => 'div',
        'el_classes' => 'lp-attributes rep-property-attributes',
        'child_el_classes' => 'lp-attribute rep-property-attribute',
    ) );

}