function breadcrumb_ajax_handler()
{
    // Handle the ajax request
    $collection = drstk_get_pid();
    check_ajax_referer('breadcrumb_drs');
    $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
    if ($_POST['pid']) {
        $url .= 'f["id"][]=' . $_POST['pid'];
    }
    $data = get_response($url);
    $data = json_decode($data, true);
    $data['site_url'] = site_url();
    wp_send_json(json_encode($data));
}
function browse_ajax_handler()
{
    // Handle the ajax request
    global $errors;
    check_ajax_referer('browse_drs');
    $collection = drstk_get_pid();
    if ($collection == '' || $collection == NULL) {
        $data = array('error' => $errors['search']['missing_collection']);
        $data = json_encode($data);
        wp_send_json($data);
        wp_die();
    } elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") {
        $data = array('error' => $errors['search']['missing_collection']);
        $data = json_encode($data);
        wp_send_json($data);
        wp_die();
    } else {
        if (isset($_POST['params']['collection'])) {
            $url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?";
        } else {
            $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
        }
        if (isset($_POST['params']['q'])) {
            $url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q']));
        }
        if (isset($_GET['q'])) {
            $url .= "q=" . urlencode(sanitize_text_field($_GET['q']));
        }
        if (isset($_POST['params']['per_page'])) {
            $url .= "&per_page=" . $_POST['params']['per_page'];
        }
        if (isset($_POST['params']['page'])) {
            $url .= "&page=" . $_POST['params']['page'];
        }
        if (isset($_POST['params']['f'])) {
            foreach ($_POST['params']['f'] as $facet => $facet_val) {
                $url .= "&f[" . $facet . "][]=" . urlencode($facet_val);
            }
        }
        if (isset($_POST['params']['sort'])) {
            $url .= "&sort=" . $_POST['params']['sort'];
        }
        $data = get_response($url);
        wp_send_json($data);
        wp_die();
    }
}
function drstk_add_tile_gallery()
{
    check_ajax_referer('tile_ajax_nonce');
    $col_pid = drstk_get_pid();
    $url = "https://repository.library.northeastern.edu/api/v1/search/" . $col_pid . "?per_page=20";
    if ($_POST['params']['q']) {
        $url .= "&q=" . urlencode(sanitize_text_field($_POST['params']['q']));
    }
    if ($_POST['params']['page']) {
        $url .= "&page=" . $_POST['params']['page'];
    }
    $data = get_response($url);
    $json = json_decode($data);
    if ($json->error) {
        wp_send_json(json_encode("There was an error: " . $json->error));
        return;
    }
    wp_send_json($data);
}
function browse_ajax_handler()
{
    // Handle the ajax request
    check_ajax_referer('browse_drs');
    $collection = drstk_get_pid();
    if ($collection == '' || $collection == NULL) {
        $data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id');
        $data = json_encode($data);
        wp_send_json($data);
    } elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") {
        $data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id');
        $data = json_encode($data);
        wp_send_json($data);
    } else {
        if ($_POST['params']['collection']) {
            $url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?";
        } else {
            $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?";
        }
        if ($_POST['params']['q']) {
            $url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q']));
        }
        if ($_GET['q']) {
            $url .= "q=" . urlencode(sanitize_text_field($_GET['q']));
        }
        if ($_POST['params']['per_page']) {
            $url .= "&per_page=" . $_POST['params']['per_page'];
        }
        if ($_POST['params']['page']) {
            $url .= "&page=" . $_POST['params']['page'];
        }
        if ($_POST['params']['f']) {
            foreach ($_POST['params']['f'] as $facet => $facet_val) {
                $url .= "&f[" . $facet . "][]=" . urlencode($facet_val);
            }
        }
        if ($_POST['params']['sort']) {
            $url .= "&sort=" . $_POST['params']['sort'];
        }
        $data = get_response($url);
        wp_send_json($data);
    }
}
<?php

global $item_pid, $data, $collection;
$item_pid = get_query_var('pid');
$collection = drstk_get_pid();
$url = "https://repository.library.northeastern.edu/api/v1/files/" . $item_pid;
$data = get_response($url);
$data = json_decode($data);
function get_item_details()
{
    global $item_pid, $data;
    foreach ($data->mods as $key => $value) {
        echo "<div><b>" . $key . "</b></div><div>";
        if (count($value) > 1) {
            foreach ($value as $val) {
                echo $val . "<br/>";
            }
        } else {
            echo $value[0];
        }
        echo "</div>";
    }
}
function get_item_title()
{
    global $item_pid, $data;
    echo $data->mods->Title[0];
}
function get_item_breadcrumbs()
{
    global $item_pid, $data, $breadcrumb_html, $collection;
function drstk_breadcrumb_script()
{
    global $wp_query;
    global $VERSION;
    global $SITE_URL;
    global $sub_collection_pid;
    global $item_pid;
    wp_register_script('drstk_breadcrumb', plugins_url('/assets/js/breadcrumb.js', __FILE__), array('jquery'));
    wp_enqueue_script('drstk_breadcrumb');
    $breadcrumb_nonce = wp_create_nonce('breadcrumb_drs');
    wp_localize_script('drstk_breadcrumb', 'breadcrumb_obj', array('ajax_url' => admin_url('admin-ajax.php'), 'nonce' => $breadcrumb_nonce, 'template' => $wp_query->query_vars['drstk_template_type'], 'item_pid' => $item_pid, 'sub_collection_pid' => $sub_collection_pid, 'collection_pid' => drstk_get_pid()));
}