astra_get_dynamic_taxonomy( string $control_tax, int $loop_count, string $separator, string $badge_style = '', string $html_tag = 'p' )
Prepare markup for taxonomies.
Description
Parameters
- $control_tax
-
(string) (Required) Taxonomy subcontrol name.
- $loop_count
-
(int) (Required) Meta loop counter to decide separator appearance.
- $separator
-
(string) (Required) Separator.
- $badge_style
-
(string) (Optional) For taxonomies as badge styles.
Default value: ''
- $html_tag
-
(string) (Optional) HTML tag.
Default value: 'p'
Return
(string) $output Taxonomy output.
Source
File: inc/blog/blog-config.php
function astra_get_dynamic_taxonomy( $control_tax, $loop_count, $separator ) {
$tax_type = astra_get_option( $control_tax );
$post_id = get_the_ID();
if ( ! $post_id ) {
return '';
}
$terms = get_the_terms( $post_id, $tax_type );
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
if ( $terms && ! empty( $terms ) && ! is_wp_error( $terms ) ) {
/** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$term_links = array();
/** @psalm-suppress PossibleRawObjectIteration */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
foreach ( $terms as $term ) {
/** @psalm-suppress PossibleRawObjectIteration */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
/** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
$term_links[] = '<a href="' . esc_url( get_term_link( $term->slug, $tax_type ) ) . '">' . esc_attr( $term->name ) . '</a>';
/** @psalm-suppress PossiblyInvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort
}
$all_terms = join( ', ', $term_links );
$output_str = '<span class="ast-terms-link">' . $all_terms . '</span>';
return ( 1 != $loop_count ) ? ' ' . $separator . ' ' . $output_str : $output_str;
}
return '';
}
Expand full source code Collapse full source code View on Trac