rep__agency_details_html()

This function, is designed to generate HTML for displaying employee details based on the provided employee post ID and content to display options.

Namespace

REP_Malcolm

Parameters

$post_id

int

Post ID of the listing.

$args

array

Key value pair of employee details.

Return

string

Agency details

Source

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

function rep__agency_details_html( $post_id, $content_to_display = ['name', 'rating'] ){

    $title = lp__get_field_value( 'display_name', $post_id );
    $link = get_the_permalink( $post_id );
    $hidden = lp__get_field_value( 'hide_post', $post_id );
    $is_single_enabled = lp__get_field_value( REP__PREFIX.'_agency_single_page', 'option' );
    $is_single_enabled = ( $is_single_enabled === false ? true : $is_single_enabled );

    ob_start();

    if( is_array( $content_to_display ) && ! empty( $content_to_display ) ) : ?>

        <div class="rep-agency-details"><?php

            foreach ($content_to_display as $content) {
                
                switch( $content ) {

                    case "name" : ?>

                        <div class="rep-agency-name"><?php
                            if( $link && $is_single_enabled && ! $hidden ) : 
                                echo lp__link_html( $link, $title );  
                            else : 
                                _e( $title );
                            endif; ?>
                        </div><?php                            

                    break;

                    case "rating" :
                        echo rep__agency_rating_details_html( $post_id );
                    break;

                }

            } ?>

        </div><?php

    endif;

    return ob_get_clean();

}