// TEMP: Replace existing related links
add_action('rest_api_init', function() {
register_rest_route('custom/v1', '/replace-related-links', array(
'methods'=>'POST','callback'=>'custom_replace_rel_links',
'permission_callback'=>function(){return current_user_can('edit_posts');}
));
});
function custom_replace_rel_links($request) {
$items = $request->get_param('items') ?: array();
$res = array('success'=>0,'failed'=>0,'errors'=>array());
foreach ($items as $item) {
$pid = intval($item['post_id'] ?? 0);
$html = wp_kses_post($item['html'] ?? '');
if (!$pid || !$html) { $res['failed']++; continue; }
$post = get_post($pid);
if (!$post) { $res['failed']++; continue; }
// Remove old related-products-links block and add new one
$content = $post->post_content;
// Remove any existing related-products-links paragraph
$content = preg_replace('/
]*class="related-products-links"[^>]*>.*?<\/p>/s', '', $content);
$content = rtrim($content) . $html;
$r = wp_update_post(array('ID'=>$pid,'post_content'=>$content), true);
if (is_wp_error($r)) { $res['failed']++; $res['errors'][] = $pid; } else { $res['success']++; }
}
return $res;
}
Commercial Fire Alarms, Smoke Sensors & Bases | Life Safety Consultants
-

STI (EF080804-O) Fiberglass Enclosure, 8 x 8 x 4, Opaque
$165.99
Read more
-

STI (EF080604-W) Fiberglass Enclosure, 8 x 6 x 4, with Window
$209.00
Read more
-

STI (EF080604-O) Fiberglass Enclosure, 8 x 6 x 4, Opaque
$151.99
Read more
-

STI (EF060604-W) Fiberglass Enclosure, 6 x 6 x 4, with Window
$225.00
Read more
-

STI (EF060604-O) Fiberglass Enclosure, 6 x 6 x 4, Opaque
$149.99
Read more
-

STI (EFAPBKT) Stationary Panel Bracket Kit
$38.75
Read more
-

STI (EFSPBKT) Swing Panel Bracket Kit
$38.75
Read more
-

STI (EF10POST) Corner Post Kit
$38.75
Read more
-

STI (EF8POST) Corner Post Kit
$36.00
Read more
-

STI (EF6POST) Corner Post Kit
$18.50
Read more
-

STI (EF4POST) Corner Post Kit
$27.00
Read more
-

STI (BPA4836) Aluminum Back Panel 48 x 36
$475.00
Read more