astra_get_selected_breadcrumb( bool $echo = true )
Get selected breadcrumb.
Description
Returns or echo the breadcrumb depending upon the argument.
Parameters
- $echo
-
(bool) (Optional) Whether to echo or not.
Default value: true
Return
(string) Selected Breadcrumb.
Source
File: inc/addons/breadcrumbs/class-astra-breadcrumb-trail.php
function astra_get_selected_breadcrumb( $echo = true ) {
$breadcrumb_source = astra_get_option( 'select-breadcrumb-source' );
$breadcrumb_enable = is_callable( 'WPSEO_Options::get' ) ? WPSEO_Options::get( 'breadcrumbs-enable' ) : false;
$wpseo_option = get_option( 'wpseo_internallinks' ) ? get_option( 'wpseo_internallinks' ) : $breadcrumb_enable;
if ( ! is_array( $wpseo_option ) ) {
unset( $wpseo_option );
$wpseo_option = array(
'breadcrumbs-enable' => $breadcrumb_enable
);
}
if ( function_exists( 'yoast_breadcrumb' ) && true === $wpseo_option['breadcrumbs-enable'] && $breadcrumb_source && 'yoast-seo-breadcrumbs' == $breadcrumb_source ) {
// Check if breadcrumb is turned on from WPSEO option.
return yoast_breadcrumb( '<div id="ast-breadcrumbs-yoast" >', '</div>', $echo );
} elseif ( function_exists( 'bcn_display' ) && $breadcrumb_source && 'breadcrumb-navxt' == $breadcrumb_source ) {
if( true === $echo ) {
?>
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php bcn_display() ?>
</div>
<?php
return;
}
// Check if breadcrumb is turned on from Breadcrumb NavXT plugin.
return '<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . bcn_display( ! $echo ) . '</div>';
} elseif ( function_exists( 'rank_math_the_breadcrumbs' ) && $breadcrumb_source && 'rank-math' == $breadcrumb_source ) {
// Check if breadcrumb is turned on from Rank Math plugin.
if ( ! $echo ) {
ob_start();
rank_math_the_breadcrumbs();
return ob_get_clean();
}
rank_math_the_breadcrumbs();
} else {
// Load default Astra breadcrumb if none selected.
return astra_get_breadcrumb_trail( $echo );
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.8.1 | Introduced. |