; $display = '
'; foreach ( $breadcrumbs as $breadcrumb ) { --$breadcrumbsCount; $breadcrumbDisplay = $this->breadcrumbToDisplay( $breadcrumb ); // Strip link from Last crumb. if ( 0 === $breadcrumbsCount && aioseo()->breadcrumbs->showCurrentItem() && ! $this->linkCurrentItem() && 'default' === $breadcrumbDisplay['templateType'] ) { $breadcrumbDisplay['template'] = $this->stripLink( $breadcrumbDisplay['template'] ); } $display .= $breadcrumbDisplay['template']; if ( 0 < $breadcrumbsCount ) { $display .= $this->getSeparator(); } } $display .= '
'; $display = wp_kses_post( $display ); if ( $echo ) { echo $display; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } return $display; } /** * Turns a crumb array into a rendered html crumb. * * @since 4.1.1 * * @param array $item The crumb array. * @return string|void The crumb html. */ protected function breadcrumbToDisplay( $item ) { $templateItem = $this->getCrumbTemplate( $item ); if ( empty( $templateItem['template'] ) ) { return; } // Do tags. $templateItem['template'] = aioseo()->breadcrumbs->tags->replaceTags( $templateItem['template'], $item ); // Restore html. $templateItem['template'] = aioseo()->helpers->decodeHtmlEntities( $templateItem['template'] ); // Remove html link if it comes back from the template but we passed no links to it. if ( empty( $item['link'] ) ) { $templateItem['template'] = $this->stripLink( $templateItem['template'] ); } // Allow shortcodes to run in the final html. $templateItem['template'] = do_shortcode( $templateItem['template'] ); // Final security cleaning. $templateItem['template'] = wp_kses_post( $templateItem['template'] ); return $templateItem; } /** * Helper function to get a crumb's template. * * @since 4.1.1 * * @param array $crumb The crumb array. * @return string The html template. */ protected function getTemplate( $crumb ) { return $this->getDefaultTemplate( $crumb ); } /** * Helper function to get a crumb's template. * * @since 4.1.1 * * @param array $crumb The crumb array. * @return array The template type and html. */ protected function getCrumbTemplate( $crumb ) { return [ 'templateType' => 'default', 'template' => $this->getTemplate( $crumb ) ]; } /** * Default html template. * * @since 4.1.1 * * @param string $type The crumb's type. * @param mixed $reference The crumb's reference. * @return string The default crumb template. */ public function getDefaultTemplate( $type = '', $reference = '' ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return <<