// TEMPORARY: Bulk keyphrase updater endpoint
add_action('rest_api_init', function() {
register_rest_route('lsc/v1', '/update-keyphrases', array(
'methods' => 'POST',
'callback' => 'lsc_bulk_update_keyphrases',
'permission_callback' => function() { return current_user_can('manage_options'); }
));
});
function lsc_bulk_update_keyphrases($request) {
$data = $request->get_json_params();
$items = isset($data['items']) ? $data['items'] : array();
$results = array('updated' => 0, 'errors' => array());
foreach ($items as $item) {
$post_id = intval(isset($item['id']) ? $item['id'] : 0);
$keyphrase = sanitize_text_field(isset($item['keyphrase']) ? $item['keyphrase'] : '');
if ($post_id > 0 && !empty($keyphrase)) {
update_post_meta($post_id, '_yoast_wpseo_focuskw', $keyphrase);
$results['updated']++;
} else {
array_push($results['errors'], 'Invalid: ' . strval($post_id));
}
}
return new WP_REST_Response($results, 200);
}
// END TEMPORARY
Commercial Fire Alarms, Smoke Sensors & Bases | Life Safety Consultants
“Bosch (FMM-100SAT2CKEX) Explosion Proof, Single Action Pull Station – Die Cast Metal (SGX-32SK2)” has been added to your cart.
View cart