rep__agency_exp_url_params( $url, $post_id = null )

The rep__get_breadcrumb_url_params() function is used to retrieve the agency experience parameters to attached on post permalinks

Namespace

Launchpad

Return

array

URL parameters

Source

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

function rep__agency_exp_url_params( $url, $post_id = null ){

    $params = [];
    
    if( lp__get_field_value( REP__PREFIX.'_agency_experience', 'option' ) ){
        $request_value = "";
        $archive_id = "";
        $post_type = "";

        $agency_id = isset( $_REQUEST['agency_id'] ) ? sanitize_text_field( $_REQUEST['agency_id'] ) : '';
        $agency_lid = isset( $_REQUEST['agency_lid'] ) ? sanitize_text_field( $_REQUEST['agency_lid'] ) : '';
        $agent_id = isset( $_REQUEST['agent_id'] ) ? sanitize_text_field( $_REQUEST['agent_id'] ) : '';

        

        if( $post_id ){ 
            $post_type = get_post_type( $post_id );
        }

        $single_post_id = get_the_ID();
        if( is_singular( 'rep_agency' ) ){
            if( ! $agency_lid ){
                $agency_lid = lp__get_field_value( 'agency_lid', $single_post_id );
            } 

            if( ! $agency_id ){
                $agency_id = lp__get_field_value( 'agency_id', $single_post_id );
            }
        }

        if( is_singular( 'rep_employee' ) && ! $agent_id ){
            $agent_id = lp__get_field_value( 'employee_id', $single_post_id );
        }

        if( $agency_lid ){
            $params[] = "agency_lid={$agency_lid}";
        } elseif( $agency_id ){
            $params[] = "agency_id={$agency_id}";
        }

        if( $agent_id ){
            $can_have_agent_id = true;
            if( $post_id ){
                $can_have_agent_id = $post_type != 'rep_employee';
            }

            if( $can_have_agent_id ){
                $params[] = "agent_id={$agent_id}";
            }
        }

        $url_query = explode( "&", lp__array_key_value( "query", parse_url( $url ), "" ) );
        $params = array_diff( $params, $url_query );
    }

    return $params;
    
}