﻿ÿØÿà JFIF      ÿÛ „ 	 ( %!1"%)+...383-7(-.+



-%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ               ÿÄ @       !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ             ÿÄ '        1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ï
-3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéß¦$$½—šÙÜCC¯¶è8Î²–Åkèwx
LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2Þ¿Ø¯­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÃ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’×©T]
ªb—ÊîKC^×M“xùäñz¬zJ×{4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi
[0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú	Ò˜Æ}2VE•Ð€p¡Ô3Úº …h³^Ç‡ºçì¥Ánó|˜ÖˆÎˆ+«¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<Ì‰Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈÀá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ
ƒÜÒ?	:õdsÀ–3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LÇÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl
Í›G¹ÀPá¼Nc¡šÒ…ÙWÍ³œ±vÊáÐ„×9‹P‰cEØ‘™›µŸP<×g1
º©Ø¬wiÁ^l5×I/';Ë+´Z‡ÓÄFÕp[Èð’
HÄ	ó
9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ
QãñQtIeórVB,ÏÂf‹4#Îœc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ
÷jsÏ‚Ò’KÈcø(é›;k(’#ôŒQ
™C>
õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~È¦—’-$fe«"FâUˆÊwµPÏu
w+"åÉoÌ¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ÉdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt
·K¢ÅÅ·¥RÄÊÉbKn
N­R2g$VµÕó
Qr#–ÓZUÏð0ÎtÙÀœz
ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Î”â‘ËØ´IˆÓ°Ë‰ÞM<J•›C=ìu*Ü§„Ã¤GËŠô;5ŒÁ£ñùä¬6Ì2¦‘žh¸Rº<Õš%÷ …Ç	‚g‡.
>3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z
à¾]
üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.Å¾„æ“I[ª+·zÐÒÚ,½Ð»¶€C›7jk$à¹–€Ž¾ÅÙpp¶ÍþéÎ¤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ä†f× æ¢Æ±qWÄ±[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGŽ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ Æˆæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„
g01¬„åEMè›‡Ã\6µE›‘fÙO	k÷CºnÓ1`iîÒ²áÂ!ÑLÄÿ 
³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#»
Ç\……ßïIœÉ$¸ÎñÍ®ÔHÃ‡	Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡	—JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ	5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*ç¦ŒÉù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnÝ³vðÖKE¼‚ »mà ÷f®:Ë™–4rð¡4` Ü¹çž~‹C=œ…¾Ïj|VDtK.ƒ"9	Ï
­–éXá³6WÒïIL-Ð‡
Ç
home/aaamarke/public_html/wp-includes/blocks/breadcrumbs.php                                        0000644                 00000045161 15265715611 0020271 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * Server-side rendering of the `core/breadcrumbs` block.
 *
 * @package WordPress
 */

/**
 * Renders the `core/breadcrumbs` block on the server.
 *
 * @since 7.0.0
 *
 * @param array    $attributes Block attributes.
 * @param string   $content    Block default content.
 * @param WP_Block $block      Block instance.
 *
 * @return string Returns the post breadcrumb for hierarchical post types.
 */
function render_block_core_breadcrumbs( $attributes, $content, $block ) {
	$is_front_page = is_front_page();

	if ( ! $attributes['showOnHomePage'] && $is_front_page ) {
		return '';
	}

	$is_home          = is_home();
	$page_for_posts   = get_option( 'page_for_posts' );
	$breadcrumb_items = array();

	if ( $attributes['showHomeItem'] ) {
		// We make `home` a link if not on front page, or if front page
		// is set to a custom page and is paged.
		if ( ! $is_front_page || ( 'page' === get_option( 'show_on_front' ) && (int) get_query_var( 'page' ) > 1 ) ) {
			$breadcrumb_items[] = array(
				'label' => __( 'Home' ),
				'url'   => home_url( '/' ),
			);
		} else {
			$breadcrumb_items[] = block_core_breadcrumbs_create_item( __( 'Home' ), block_core_breadcrumbs_is_paged() );
		}
	}

	// Handle home.
	if ( $is_home ) {
		// These checks are explicitly nested in order not to execute the `else` branch.
		if ( $page_for_posts ) {
			$breadcrumb_items[] = block_core_breadcrumbs_create_item( block_core_breadcrumbs_get_post_title( $page_for_posts ), block_core_breadcrumbs_is_paged() );
		}
		if ( block_core_breadcrumbs_is_paged() ) {
			$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
		}
	} elseif ( $is_front_page ) {
		// Handle front page.
		// This check is explicitly nested in order not to execute the `else` branch.
		// If front page is set to custom page and is paged, add the page number.
		if ( (int) get_query_var( 'page' ) > 1 ) {
			$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
		}
	} elseif ( is_search() ) {
		// Handle search results.
		$is_paged = block_core_breadcrumbs_is_paged();
		/* translators: %s: search query */
		$text               = sprintf( __( 'Search results for: "%s"' ), wp_trim_words( get_search_query(), 10 ) );
		$breadcrumb_items[] = block_core_breadcrumbs_create_item( $text, $is_paged );
		// Add the "Page X" as the current page if paginated.
		if ( $is_paged ) {
			$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
		}
	} elseif ( is_404() ) {
		// Handle 404 pages.
		$breadcrumb_items[] = array(
			'label' => __( 'Page not found' ),
		);
	} elseif ( is_archive() ) {
		// Handle archive pages (taxonomy, post type, date, author archives).
		$archive_breadcrumbs = block_core_breadcrumbs_get_archive_breadcrumbs();
		if ( ! empty( $archive_breadcrumbs ) ) {
			$breadcrumb_items = array_merge( $breadcrumb_items, $archive_breadcrumbs );
		}
	} else {
		// Handle single post/page breadcrumbs.
		if ( ! isset( $block->context['postId'] ) || ! isset( $block->context['postType'] ) ) {
			return '';
		}

		$post_id   = $block->context['postId'];
		$post_type = $block->context['postType'];

		$post = get_post( $post_id );
		if ( ! $post ) {
			return '';
		}

		// For non-hierarchical post types with parents (e.g., attachments), build trail for the parent.
		$post_parent = $post->post_parent;
		$parent_post = null;
		if ( ! is_post_type_hierarchical( $post_type ) && $post_parent ) {
			$parent_post = get_post( $post_parent );
			if ( $parent_post ) {
				$post_id     = $parent_post->ID;
				$post_type   = $parent_post->post_type;
				$post_parent = $parent_post->post_parent;
			}
		}

		// Determine breadcrumb type.
		// Some non-hierarchical post types (e.g., attachments) can have parents.
		// Use hierarchical breadcrumbs if a parent exists, otherwise use taxonomy breadcrumbs.
		$show_terms = false;
		if ( ! is_post_type_hierarchical( $post_type ) && ! $post_parent ) {
			$show_terms = true;
		} elseif ( empty( get_object_taxonomies( $post_type, 'objects' ) ) ) {
			$show_terms = false;
		} else {
			$show_terms = $attributes['prefersTaxonomy'];
		}

		// Add post type archive link if applicable.
		$post_type_object = get_post_type_object( $post_type );
		$archive_link     = get_post_type_archive_link( $post_type );
		if ( $archive_link && untrailingslashit( home_url() ) !== untrailingslashit( $archive_link ) ) {
			$label = $post_type_object->labels->archives;
			if ( 'post' === $post_type && $page_for_posts ) {
				$label = block_core_breadcrumbs_get_post_title( $page_for_posts );
			}
			$breadcrumb_items[] = array(
				'label' => $label,
				'url'   => $archive_link,
			);
		}
		// Build breadcrumb trail based on hierarchical structure or taxonomy terms.
		if ( ! $show_terms ) {
			$breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
		} else {
			$breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) );
		}

		// Add post title: linked when viewing a paginated page, plain text otherwise.
		$is_paged = (int) get_query_var( 'page' ) > 1 || (int) get_query_var( 'cpage' ) > 1;
		$title    = block_core_breadcrumbs_get_post_title( $post );

		if ( $is_paged ) {
			$breadcrumb_items[] = array(
				'label'      => $title,
				'url'        => get_permalink( $post ),
				'allow_html' => true,
			);
			$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( (int) get_query_var( 'cpage' ) > 1 ? 'cpage' : 'page' );
		} else {
			$breadcrumb_items[] = array(
				'label'      => $title,
				'allow_html' => true,
			);
		}
	}

	// Remove current item if disabled.
	if ( ! $attributes['showCurrentItem'] && ! empty( $breadcrumb_items ) ) {
		array_pop( $breadcrumb_items );
	}

	/**
	 * Filters the breadcrumb items array before rendering.
	 *
	 * Allows developers to modify, add, or remove breadcrumb items.
	 *
	 * @since 7.0.0
	 *
	 * @param array[] $breadcrumb_items {
	 *     Array of breadcrumb item data.
	 *
	 *     @type string $label      The breadcrumb text.
	 *     @type string $url        Optional. The breadcrumb link URL.
	 *     @type bool   $allow_html Optional. Whether to allow HTML in the label.
	 *                              When true, the label will be sanitized with wp_kses_post(),
	 *                              allowing only safe HTML tags. When false or omitted, all HTML
	 *                              will be escaped with esc_html(). Default false.
	 * }
	 */
	$breadcrumb_items = apply_filters( 'block_core_breadcrumbs_items', $breadcrumb_items );

	if ( empty( $breadcrumb_items ) ) {
		return '';
	}

	$wrapper_attributes = get_block_wrapper_attributes(
		array(
			'style'      => '--separator: "' . addcslashes( $attributes['separator'], '\\"' ) . '";',
			'aria-label' => __( 'Breadcrumbs' ),
		)
	);

	$breadcrumb_html = sprintf(
		'<nav %s><ol>%s</ol></nav>',
		$wrapper_attributes,
		implode(
			'',
			array_map(
				static function ( $item ) {
					$label = ! empty( $item['allow_html'] ) ? wp_kses_post( $item['label'] ) : esc_html( $item['label'] );
					if ( ! empty( $item['url'] ) ) {
						return '<li><a href="' . esc_url( $item['url'] ) . '">' . $label . '</a></li>';
					}
					return '<li><span aria-current="page">' . $label . '</span></li>';
				},
				$breadcrumb_items
			)
		)
	);

	return $breadcrumb_html;
}

/**
 * Checks if we're on a paginated view (page 2 or higher).
 *
 * @since 7.0.0
 *
 * @return bool True if paged > 1, false otherwise.
 */
function block_core_breadcrumbs_is_paged() {
	$paged = (int) get_query_var( 'paged' );
	return $paged > 1;
}

/**
 * Creates a "Page X" breadcrumb item for paginated views.
 *
 * @since 7.0.0
 * @param string $query_var Optional. Query variable to get current page number. Default 'paged'.
 * @return array The "Page X" breadcrumb item data.
 */
function block_core_breadcrumbs_create_page_number_item( $query_var = 'paged' ) {
	$paged = (int) get_query_var( $query_var );

	if ( 'cpage' === $query_var ) {
		return array(
			'label' => sprintf(
				/* translators: %s: comment page number */
				__( 'Comments Page %s' ),
				number_format_i18n( $paged )
			),
		);
	}

	return array(
		'label' => sprintf(
			/* translators: %s: page number */
			__( 'Page %s' ),
			number_format_i18n( $paged )
		),
	);
}


/**
 * Creates a breadcrumb item that's either a link or current page item.
 *
 * When paginated (is_paged is true), creates a link to page 1.
 * Otherwise, creates a span marked as the current page.
 *
 * @since 7.0.0
 *
 * @param string $text       The text content.
 * @param bool   $is_paged   Whether we're on a paginated view.
 *
 * @return array The breadcrumb item data.
 */
function block_core_breadcrumbs_create_item( $text, $is_paged = false ) {
	$item = array( 'label' => $text );
	if ( $is_paged ) {
		$item['url'] = get_pagenum_link( 1 );
	}
	return $item;
}

/**
 * Gets a post title with fallback for empty titles.
 *
 * @since 7.0.0
 *
 * @param int|WP_Post $post_id_or_object The post ID or post object.
 *
 * @return string The post title or fallback text.
 */
function block_core_breadcrumbs_get_post_title( $post_id_or_object ) {
	$title = get_the_title( $post_id_or_object );
	if ( strlen( $title ) === 0 ) {
		$title = __( '(no title)' );
	}
	return $title;
}

/**
 * Generates breadcrumb items from hierarchical post type ancestors.
 *
 * @since 7.0.0
 *
 * @param int    $post_id   The post ID.
 *
 * @return array Array of breadcrumb item data.
 */
function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) {
	$breadcrumb_items = array();
	$ancestors        = get_post_ancestors( $post_id );
	$ancestors        = array_reverse( $ancestors );

	foreach ( $ancestors as $ancestor_id ) {
		$breadcrumb_items[] = array(
			'label'      => block_core_breadcrumbs_get_post_title( $ancestor_id ),
			'url'        => get_permalink( $ancestor_id ),
			'allow_html' => true,
		);
	}
	return $breadcrumb_items;
}

/**
 * Generates breadcrumb items for hierarchical term ancestors.
 *
 * For hierarchical taxonomies, retrieves and formats ancestor terms as breadcrumb links.
 *
 * @since 7.0.0
 *
 * @param int    $term_id  The term ID.
 * @param string $taxonomy The taxonomy name.
 *
 * @return array Array of breadcrumb item data for ancestors.
 */
function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
	$breadcrumb_items = array();

	// Check if taxonomy is hierarchical and add ancestor term links.
	if ( is_taxonomy_hierarchical( $taxonomy ) ) {
		$term_ancestors = get_ancestors( $term_id, $taxonomy, 'taxonomy' );
		$term_ancestors = array_reverse( $term_ancestors );
		foreach ( $term_ancestors as $ancestor_id ) {
			$ancestor_term = get_term( $ancestor_id, $taxonomy );
			if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
				$breadcrumb_items[] = array(
					'label' => $ancestor_term->name,
					'url'   => get_term_link( $ancestor_term ),
				);
			}
		}
	}

	return $breadcrumb_items;
}

/**
 * Generates breadcrumb items for archive pages.
 *
 * Handles taxonomy archives, post type archives, date archives, and author archives.
 * For hierarchical taxonomies, includes ancestor terms in the breadcrumb trail.
 *
 * @since 7.0.0
 *
 * @return array Array of breadcrumb item data.
 */
function block_core_breadcrumbs_get_archive_breadcrumbs() {
	$breadcrumb_items = array();

	// Date archive (check first since it doesn't have a queried object).
	if ( is_date() ) {
		$year  = get_query_var( 'year' );
		$month = get_query_var( 'monthnum' );
		$day   = get_query_var( 'day' );

		// Fallback to 'm' query var for plain permalinks.
		// Plain permalinks use ?m=YYYYMMDD format instead of separate query vars.
		if ( ! $year ) {
			$m = get_query_var( 'm' );
			if ( $m ) {
				$year  = substr( $m, 0, 4 );
				$month = substr( $m, 4, 2 );
				$day   = (int) substr( $m, 6, 2 );
			}
		}

		$is_paged = block_core_breadcrumbs_is_paged();

		if ( $year ) {
			if ( $month ) {
				// Year is linked if we have month.
				$breadcrumb_items[] = array(
					'label' => $year,
					'url'   => get_year_link( $year ),
				);

				if ( $day ) {
					// Month is linked if we have day.
					$breadcrumb_items[] = array(
						'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
						'url'   => get_month_link( $year, $month ),
					);
					// Add day (current if not paginated, link if paginated).
					$breadcrumb_items[] = block_core_breadcrumbs_create_item(
						$day,
						$is_paged
					);
				} else {
					// Add month (current if not paginated, link if paginated).
					$breadcrumb_items[] = block_core_breadcrumbs_create_item(
						date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
						$is_paged
					);
				}
			} else {
				// Add year (current if not paginated, link if paginated).
				$breadcrumb_items[] = block_core_breadcrumbs_create_item(
					$year,
					$is_paged
				);
			}
		}

		// Add pagination breadcrumb if on a paged date archive.
		if ( $is_paged ) {
			$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
		}

		return $breadcrumb_items;
	}

	// For other archive types, we need a queried object.
	$queried_object = get_queried_object();

	if ( ! $queried_object ) {
		return array();
	}

	$is_paged = block_core_breadcrumbs_is_paged();

	// Taxonomy archive (category, tag, custom taxonomy).
	if ( $queried_object instanceof WP_Term ) {
		$term     = $queried_object;
		$taxonomy = $term->taxonomy;

		// Add hierarchical term ancestors if applicable.
		$breadcrumb_items = array_merge(
			$breadcrumb_items,
			block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy )
		);

		// Add current term (current if not paginated, link if paginated).
		$breadcrumb_items[] = block_core_breadcrumbs_create_item(
			$term->name,
			$is_paged
		);
	} elseif ( is_post_type_archive() ) {
		// Post type archive.
		$post_type = get_query_var( 'post_type' );
		if ( is_array( $post_type ) ) {
			$post_type = reset( $post_type );
		}
		$post_type_object = get_post_type_object( $post_type );

		/** This filter is documented in wp-includes/general-template.php */
		$title = apply_filters( 'post_type_archive_title', $post_type_object->labels->archives, $post_type ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound

		if ( $post_type_object ) {
			// Add post type (current if not paginated, link if paginated).
			$breadcrumb_items[] = block_core_breadcrumbs_create_item(
				$title ? $title : $post_type_object->labels->archives,
				$is_paged
			);
		}
	} elseif ( is_author() ) {
		// Author archive.
		$author = $queried_object;
		// Add author (current if not paginated, link if paginated).
		$breadcrumb_items[] = block_core_breadcrumbs_create_item(
			$author->display_name,
			$is_paged
		);
	}

	// Add pagination breadcrumb if on a paged archive.
	if ( $is_paged ) {
		$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
	}

	return $breadcrumb_items;
}

/**
 * Generates breadcrumb items from taxonomy terms.
 *
 * Finds the first publicly queryable taxonomy with terms assigned to the post
 * and generates breadcrumb links, including hierarchical term ancestors if applicable.
 *
 * @since 7.0.0
 *
 * @param int    $post_id   The post ID.
 * @param string $post_type The post type name.
 *
 * @return array Array of breadcrumb item data.
 */
function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
	$breadcrumb_items = array();

	// Get public taxonomies for this post type.
	$taxonomies = wp_filter_object_list(
		get_object_taxonomies( $post_type, 'objects' ),
		array(
			'publicly_queryable' => true,
			'show_in_rest'       => true,
		)
	);

	if ( empty( $taxonomies ) ) {
		return $breadcrumb_items;
	}

	/**
	 * Filters breadcrumb settings (taxonomy and term selection) for a post or post type.
	 *
	 * Allows developers to specify which taxonomy and term should be used in the
	 * breadcrumb trail when a post type has multiple taxonomies or when a post is
	 * assigned to multiple terms within a taxonomy.
	 *
	 * @since 7.0.0
	 *
	 * @param array  $settings {
	 *     Array of breadcrumb settings. Default empty array.
	 *
	 *     @type string $taxonomy Optional. Taxonomy slug to use for breadcrumbs.
	 *                            The taxonomy must be registered for the post type and have
	 *                            terms assigned to the post. If not found or has no terms,
	 *                            fall back to the first available taxonomy with terms.
	 *     @type string $term     Optional. Term slug to use when the post has multiple terms
	 *                            in the selected taxonomy. If the term is not found or not
	 *                            assigned to the post, fall back to the first term. If the
	 *                            post has only one term, that term is used regardless.
	 * }
	 * @param string $post_type The post type slug.
	 * @param int    $post_id   The post ID.
	 */
	$settings = apply_filters( 'block_core_breadcrumbs_post_type_settings', array(), $post_type, $post_id );

	$taxonomy_name = null;
	$terms         = array();

	// Try preferred taxonomy first if specified.
	if ( ! empty( $settings['taxonomy'] ) ) {
		foreach ( $taxonomies as $taxonomy ) {
			if ( $taxonomy->name === $settings['taxonomy'] ) {
				$post_terms = get_the_terms( $post_id, $taxonomy->name );
				if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
					$taxonomy_name = $taxonomy->name;
					$terms         = $post_terms;
				}
				break;
			}
		}
	}

	// If no preferred taxonomy or it didn't have terms, find the first taxonomy with terms.
	if ( empty( $terms ) ) {
		foreach ( $taxonomies as $taxonomy ) {
			$post_terms = get_the_terms( $post_id, $taxonomy->name );
			if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
				$taxonomy_name = $taxonomy->name;
				$terms         = $post_terms;
				break;
			}
		}
	}

	if ( ! empty( $terms ) ) {
		// Select which term to use.
		$term = reset( $terms );

		// Try preferred term if specified and post has multiple terms.
		if ( ! empty( $settings['term'] ) && count( $terms ) > 1 ) {
			foreach ( $terms as $candidate_term ) {
				if ( $candidate_term->slug === $settings['term'] ) {
					$term = $candidate_term;
					break;
				}
			}
		}

		// Add hierarchical term ancestors if applicable.
		$breadcrumb_items   = array_merge(
			$breadcrumb_items,
			block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
		);
		$breadcrumb_items[] = array(
			'label' => $term->name,
			'url'   => get_term_link( $term ),
		);
	}
	return $breadcrumb_items;
}

/**
 * Registers the `core/breadcrumbs` block on the server.
 *
 * @since 7.0.0
 */
function register_block_core_breadcrumbs() {
	register_block_type_from_metadata(
		__DIR__ . '/breadcrumbs',
		array(
			'render_callback' => 'render_block_core_breadcrumbs',
		)
	);
}
add_action( 'init', 'register_block_core_breadcrumbs' );
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               