// 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
“SIEMENS (SL2SBB-R) Back box, wall, red, for SL2 series devi” has been added to your cart.
View cart
-

SIEMENS (SSD-C) Lcd Display Module (Part# 500-648733)
$1,175.76
Read more
-

SIEMENS (SL2SWW-F) Strobe Clear Lens/White Wall Fire
$86.98
Read more
-

SIEMENS (SL2SWR-F) Strobe Only, Wall, Red, Fire
$87.00
Read more
-

SIEMENS (SL2SPSWW-F) Speaker-Strobe Wall w/ Fire White
$212.44
Read more
-

SIEMENS (SL2SPSWR-F) Speaker-Strobe Wall Red w/Fire
$152.28
Read more
-

SIEMENS (SL2SPSCW-F) Speaker-Strobe Ceiling White w/Fire
$162.79
Read more
-

SIEMENS (SL2SCW-F) Strobe, Ceiling White Fire
$89.00
Read more
-

SIEMENS (SL2SCW-AL) Strobe, Ceiling Mount, White, Clear Lens
$134.16
Add to cart
-

SIEMENS (SL2SBB-R) Back box, wall, red, for SL2 series devi
$15.43
Add to cart
-

SIEMENS (SL2HSWW-F) Horn Strobe White Wall
$145.49
Read more
-

SIEMENS (SL2HSCW-F) Horn-Strobe, Ceiling, Clear, White, Fire
$114.38
Read more
-

SIEMENS (SL2HSCR-F) Horn-Strobe, Ceiling Mount, Red, “Fire
$114.39
Read more