'GET','permission_callback'=>fn()=>MPSEO_Access::can(MPSEO_Access::CAP_SETTINGS),'callback'=>fn()=>['version'=>MPSEO_VERSION,'site'=>home_url()]]);}
/** Shared trail for a post (without the home page), used by the visible breadcrumbs and the BreadcrumbList schema. */
static function trail_for_post($p){
$out=[];
$term_chain=function($term)use(&$out){foreach(array_reverse(get_ancestors($term->term_id,$term->taxonomy,'taxonomy')) as $a){$t=get_term($a,$term->taxonomy);if($t&&!is_wp_error($t)){$l=get_term_link($t);if(!is_wp_error($l))$out[]=[$l,$t->name];}}};
if($p->post_type==='post'||$p->post_type==='product'){
$page_for_posts=(int)get_option('page_for_posts');
if($p->post_type==='post'&&$page_for_posts)$out[]=[get_permalink($page_for_posts),get_the_title($page_for_posts)];
if($p->post_type==='product'&&function_exists('wc_get_page_id')&&wc_get_page_id('shop')>0)$out[]=[get_permalink(wc_get_page_id('shop')),get_the_title(wc_get_page_id('shop'))];
$terms=get_the_terms($p,$p->post_type==='product'?'product_cat':'category');
if($terms&&!is_wp_error($terms)){
usort($terms,function($a,$b){return count(get_ancestors($b->term_id,$b->taxonomy,'taxonomy'))<=>count(get_ancestors($a->term_id,$a->taxonomy,'taxonomy'));});
$main=apply_filters('mpseo_primary_term',$terms[0],$p,$terms);$term_chain($main);$l=get_term_link($main);if(!is_wp_error($l))$out[]=[$l,$main->name];
}
}
foreach(array_reverse(get_post_ancestors($p)) as $a)$out[]=[get_permalink($a),get_the_title($a)];
$out[]=[get_permalink($p),get_the_title($p)];
return $out;
}
/** Breadcrumb trail: full page hierarchy, main category for posts and products, term ancestors on archives. */
static function breadcrumbs(...$args){return wp_kses_post((string)self::breadcrumbs_html(...$args));}
static function breadcrumbs_html(){
if(is_front_page())return '';
$opt=function($k,$d){return (string)MPSEO_Core::setting($k,$d);};
if($opt('bc_enabled','1')!=='1')return '';
$home_label=$opt('bc_home_label','')!==''?$opt('bc_home_label',''):__('Home', 'multipify-seo-boost');
$crumbs=[[home_url('/'),$home_label]];
$term_chain=function($term)use(&$crumbs){foreach(array_reverse(get_ancestors($term->term_id,$term->taxonomy,'taxonomy')) as $a){$t=get_term($a,$term->taxonomy);if($t&&!is_wp_error($t)){$l=get_term_link($t);if(!is_wp_error($l))$crumbs[]=[$l,$t->name];}}};
if(is_singular()){
$p=get_queried_object();
if($p instanceof WP_Post){foreach(self::trail_for_post($p) as $c)$crumbs[]=$c;$crumbs[count($crumbs)-1][0]='';}
}elseif(is_category()||is_tag()||is_tax()){
$t=get_queried_object();if($t instanceof WP_Term){$term_chain($t);$crumbs[]=['',$t->name];}
}elseif(is_search()){$crumbs[]=['',(__('Search:', 'multipify-seo-boost') . ' ').get_search_query()];}
elseif(is_404()){$crumbs[]=['',__('Page not found', 'multipify-seo-boost')];}
elseif(is_archive()){$crumbs[]=['',wp_strip_all_tags(get_the_archive_title())];}
elseif(is_home()){$crumbs[]=['',get_the_title((int)get_option('page_for_posts'))];}
if($opt('bc_show_home','1')!=='1'&&count($crumbs)>1)array_shift($crumbs);
if($opt('bc_show_current','1')!=='1'&&count($crumbs)>1){$lastc=end($crumbs);if($lastc[0]==='')array_pop($crumbs);}
$bold=$opt('bc_bold_current','1')==='1';$sep=$opt('bc_separator','›');$prefix=$opt('bc_prefix','');
$parts=[];$last=count($crumbs)-1;
foreach($crumbs as $i=>$c){$parts[]=($c[0]!==''&&$i<$last)?''.esc_html($c[1]).'':''.esc_html($c[1]).'';}
return ('';
}
}