add_action('rest_api_init', function() { register_rest_route('tamam-seo/v1', '/term-meta', ['methods' => 'POST', 'callback' => function($r) { $tax=sanitize_text_field($r->get_param('taxonomy')); $tid=intval($r->get_param('term_id')); $t=$r->get_param('title'); $d=$r->get_param('desc'); $kw=$r->get_param('focuskw'); if(!$tax||!$tid) return new WP_Error('e','Missing',['status'=>400]); $m=get_option('wpseo_taxonomy_meta',[]); if(!$m) $m=[]; if(!isset($m[$tax])) $m[$tax]=[]; if(!isset($m[$tax][$tid])) $m[$tax][$tid]=[]; if($t!==null) $m[$tax][$tid]['wpseo_title']=$t; if($d!==null) $m[$tax][$tid]['wpseo_desc']=$d; if($kw!==null) $m[$tax][$tid]['wpseo_focuskw']=$kw; update_option('wpseo_taxonomy_meta',$m); return ['success'=>true,'data'=>$m[$tax][$tid]]; }, 'permission_callback' => function() { return current_user_can('manage_options'); }]); });