Partner snippet
array(
'id' => 'ptr_newlenox_plant',
'name' => 'Secure Document Solutions β Main Plant',
'city' => 'New Lenox, IL',
'region' => 'SUBURBS',
'address' => '12531 W. Horseshoe Drive, New Lenox, IL 60451',
'phone' => '(888) 487-7328',
'hours' => 'By Appointment Only β’ MonβFri 7amβ6pm β’ Sat 7amβ8pm β’ $5.00/Std Box (+$1 disp.)',
'badge' => 'π’ Main Shredding Plant ($5/Box)',
'lat' => 41.5178,
'lng' => -87.9815,
'is_plant' => true,
'active' => true,
),
'ptr_villapark' => array(
'id' => 'ptr_villapark',
'name' => 'All Tax Solutions Services, Inc.',
'city' => 'Villa Park, IL',
'region' => 'SUBURBS',
'address' => '212 W. St. Charles Rd, Villa Park, IL 60181',
'phone' => '(630) 359-3469',
'hours' => 'Independent Drop-Off Partner β Please call store directly for current hours & retail pricing.',
'badge' => 'π Villa Park, IL (West Suburbs)',
'lat' => 41.8897,
'lng' => -87.9839,
'active' => true,
),
'ptr_westmont' => array(
'id' => 'ptr_westmont',
'name' => 'Mail Boxes Etc.',
'city' => 'Westmont, IL',
'region' => 'SUBURBS',
'address' => '210A E. Chicago Ave, Westmont, IL 60559',
'phone' => '(630) 323-5868',
'hours' => 'Independent Drop-Off Partner β Please call store directly for current hours & retail pricing.',
'badge' => 'π Westmont, IL (West Suburbs)',
'lat' => 41.8056,
'lng' => -87.9706,
'active' => true,
),
'ptr_chicago_north' => array(
'id' => 'ptr_chicago_north',
'name' => 'Jackson Hewitt Tax Service',
'city' => 'Chicago, IL',
'region' => 'CHICAGO',
'address' => '3934 W. North Ave, Chicago, IL 60647',
'phone' => '(773) 634-2198',
'hours' => 'Independent Drop-Off Partner β Please call store directly for current hours & retail pricing.',
'badge' => 'π Chicago, IL (W. North Ave)',
'lat' => 41.9103,
'lng' => -87.7258,
'active' => true,
),
);
}
function sds_get_synced_dropoff_partners() {
$key = 'sds_dropoff_partners_sql_v1';
$list = get_option($key, array());
if (!is_array($list) || empty($list)) {
$list = sds_default_dropoff_partners_list();
update_option($key, $list, false);
}
$jobs = get_option('sds_master_tickets_sql_v6', array());
if (is_array($jobs)) {
foreach ($jobs as $tid => $j) {
if (!is_array($j) || strtoupper($j['job_status'] ?? '') === 'VOID_PENDING') continue;
$notes = (string)($j['notes'] ?? '');
if (stripos($notes, 'Drop-Off Partner') !== false) {
$pid = 'ptr_auto_' . strtolower(preg_replace('/\W+/', '', $tid));
$addr = trim((string)($j['address'] ?? ''));
$cust = trim((string)($j['customer_org'] ?? $j['cust'] ?? ''));
if ($cust !== '' && $addr !== '' && stripos($cust, 'Allstate') === false && !isset($list[$pid])) {
$list[$pid] = array(
'id' => $pid,
'name' => $cust,
'city' => 'Chicagoland Partner',
'region' => (stripos($addr, 'Chicago') !== false) ? 'CHICAGO' : 'SUBURBS',
'address' => $addr,
'phone' => trim((string)($j['phone'] ?? '(888) 487-7328')),
'hours' => 'Authorized Drop-Off Partner β Call store directly for hours & retail rates.',
'badge' => 'π Authorized Drop-Off Partner',
'active' => true,
);
}
}
}
}
return $list;
}
add_action('rest_api_init', function () {
register_rest_route('sds/v1', '/dropoff-partners', array(
'methods' => array('GET', 'POST', 'DELETE'),
'permission_callback' => '__return_true',
'callback' => function (WP_REST_Request $request) {
nocache_headers();
header("Access-Control-Allow-Origin: *");
$key = 'sds_dropoff_partners_sql_v1';
$list = sds_get_synced_dropoff_partners();
if ($request->get_method() === 'DELETE') {
$id = sanitize_text_field($request->get_param('id'));
if ($id && isset($list[$id])) {
unset($list[$id]);
update_option($key, $list, false);
}
return new WP_REST_Response(array_values($list), 200);
}
if ($request->get_method() === 'POST') {
$b = $request->get_json_params() ?: array();
if (!empty($b['reset_defaults'])) {
$list = sds_default_dropoff_partners_list();
update_option($key, $list, false);
return new WP_REST_Response(array_values($list), 200);
}
$name = sanitize_text_field($b['name'] ?? '');
$addr = sanitize_text_field($b['address'] ?? '');
if ($name !== '' && $addr !== '') {
$id = !empty($b['id']) ? sanitize_text_field($b['id']) : ('ptr_' . strtolower(preg_replace('/\W+/', '_', $name)));
$city = sanitize_text_field($b['city'] ?? 'Chicagoland, IL');
$reg = (stripos($city . ' ' . $addr, 'Chicago') !== false && stripos($addr, 'Chicago Ave') === false) ? 'CHICAGO' : sanitize_text_field($b['region'] ?? 'SUBURBS');
$list[$id] = array(
'id' => $id,
'name' => $name,
'city' => $city,
'region' => $reg,
'address' => $addr,
'phone' => sanitize_text_field($b['phone'] ?? ''),
'hours' => sanitize_text_field($b['hours'] ?? 'Independent Drop-Off Partner β Please call store directly for current hours & retail pricing.'),
'badge' => 'π ' . $city,
'active' => true,
);
update_option($key, $list, false);
}
}
return new WP_REST_Response(array_values($list), 200);
},
), true);
}, 999);
add_action('wp_footer', function () {
$req_path = strtolower(trim(parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH), '/'));
$is_office = (strpos($req_path, 'office-page') !== false || strpos($req_path, 'office_page') !== false);
$is_driver = (strpos($req_path, 'sds-driver') !== false || strpos($req_path, 'driver') !== false);
if (!$is_office && !$is_driver) return;
?>
