// 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
“DITEK (DTK-120/240HD) 120/240 VAC Split Phase, 3W(+G), 50kA, S” has been added to your cart.
View cart
-

DITEK (DTK-120HW) 120VAC, 20A Parallel Protector UL1449 Li
$68.80
Add to cart
-

DITEK (DTK-120/240HD) 120/240 VAC Split Phase, 3W(+G), 50kA, S
$222.32
Add to cart
-

DITEK (DTK-120/240CM+) 120/240 VAC, Parallel Protector, 2W(+G),
$68.14
Add to cart
-

DITEK (D200-277/4803Y) 277/480 VAC 3 Phase WYE, 4W(+G), 200kA,
$1,310.58
Add to cart
-

DITEK (D200-120/2083Y) 120/208 VAC 3 Phase WYE, 4W(+G), 200kA,
$1,310.58
Read more
-

DITEK (D100-120/2083Y) 120/208 VAC 3 Phase WYE, 4W(+G), 100kA,
$562.95
Add to cart
-

DET-TRONICS (30-3013A1N13A) Explosion-Proof Smoke Detector for..smol
$11,136.61
Read more
-

BOSCH (VG4-A-PSU2) Bosch 230Vac 100W Ip66 Psu..White
$249.05
Read more
-

BOSCH (LVF-5005C-S0940) Bosch1/2.5″,Csmount,9-40Mm,..Ir,5Mp,Srir
$406.18
Read more
-

BOSCH (LSN) LSN 1500 A LSNi Module
$1,006.33
Add to cart
-

BOSCH (FAH-440) Analog Heat Detector
$61.85
Read more
-

BOSCH (D9127T) 1Zn Popit With Tamper Null
$37.04
Read more