// 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
-

RSG (DHE2PC) 2″ EXTENSION ROD, POWDER COATED, CHROME
$12.35
Read more
-

RSG (DHE1PC) 1� EXTENSION ROD, POWDER COATED, CH
$14.03
Read more
-

RSG (DH24120SPC) DR HLDR,SURF MNT,CHRM
$101.30
Read more
-

RSG (DH24120FPC) SEMI-FLUSH, POWDER COATED CHROME
$185.40
Add to cart
-

RSG (DH1224SPC) 12/24 V, SURFACE MT, CHROME
$104.36
Read more
-

RESIDEO (VISTA-20P) Expand,8 Zone Plus Series (Panel Include
$89.22
Add to cart
-

RESIDEO (V250FBPT) Comm’L Fire/Burg Ctrl, Turbo
$1,247.71
Add to cart
-

RESIDEO (V128FBPT) Comm’L Fire/Burg Ctrl, Turbo
$938.07
Read more
-

RESIDEO (PROSIXCT) Six Door/Window Sensor
$21.31
Read more
-

RESIDEO (PROA7Dm) Desk Mnt Stnd For 7″Aio Panels
$22.67
Read more
-

RESIDEO (IS3050V) Is3050,Pir ,50Ft,G2, Us
$64.40
Add to cart
-

RESIDEO (958-2) Overhead Cnt Adj Mag Spdt
$37.67
Read more