Skip to content

Commit 54cb028

Browse files
authored
Merge pull request #382 from BeAPI/feature/get_terms_list
inject data into get_terms_list
2 parents d104472 + 3a3965b commit 54cb028

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

components/parts/common/breadcrumb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55
?>
66

7-
<nav class="breadcrumb" role="navigation" aria-label="<?php echo esc_attr( 'Breadcrumb', 'beapi-frontend-framework' ); ?>">
7+
<nav class="breadcrumb" role="navigation" aria-label="<?php esc_attr_e( 'Breadcrumb', 'beapi-frontend-framework' ); ?>">
88
<div class="container">
99
<?php yoast_breadcrumb( '<div class="breadcrumb__inner">', '</div>' ); ?>
1010
</div>

inc/Helpers/Formatting/Term.php

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,20 @@
33

44
use function BEA\Theme\Framework\Helpers\Formatting\Escape\escape_content_value;
55
/**
6-
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\get_terms_name( 0, 'news-type' );
6+
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\get_terms_name( $terms );
77
*
8-
* @param int|\WP_Post $post Post ID or object.
9-
* @param string $taxonomy Taxonomy name
8+
* @param \WP_Term[] $terms list of terms
109
*
1110
* @return array Return an array with the terms name
1211
*/
13-
function get_terms_name( $post_id, string $taxonomy ): array {
14-
$terms = get_the_terms( $post_id, $taxonomy );
15-
16-
if ( false === $terms || is_wp_error( $terms ) ) {
17-
return [];
18-
}
19-
12+
function get_terms_name( array $terms ): array {
2013
return wp_list_pluck( $terms, 'name' );
2114
}
2215

2316
/**
24-
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\get_terms_list( ['post_id' => 0,'taxonomy' => 'news-type'],['items' => '<span>%s</span>', 'separator' => ' ', 'wrapper' => '<p>%s</p>'] );
17+
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\get_terms_list( $terms ,['items' => '<span>%s</span>', 'separator' => ' ', 'wrapper' => '<p>%s</p>'] );
2518
*
26-
* @param int|\WP_Post $post Post ID or object.
27-
* @param string $taxonomy Taxonomy name.
19+
* @param \WP_Term[] $terms list of terms
2820
*
2921
* @param array $settings {
3022
* Optional. Settings for the terms list markup.
@@ -39,9 +31,9 @@ function get_terms_name( $post_id, string $taxonomy ): array {
3931
*
4032
* @return string
4133
*/
42-
function get_terms_list( $post, string $taxonomy, array $settings = [] ): string {
43-
$attributes = apply_filters( 'bea_theme_framework_term_list_attributes', $post, $taxonomy, $settings );
44-
$terms = get_terms_name( $post, $taxonomy );
34+
function get_terms_list( array $terms, array $settings = [] ): string {
35+
$attributes = apply_filters( 'bea_theme_framework_term_list_attributes', $terms, $settings );
36+
$terms = get_terms_name( $terms );
4537

4638
if ( empty( $terms ) ) {
4739
return '';
@@ -78,10 +70,9 @@ function get_terms_list( $post, string $taxonomy, array $settings = [] ): string
7870
}
7971

8072
/**
81-
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\the_terms_list( ['post_id' => 0,'taxonomy' => 'news-type'],['items' => '<span>%s</span>', 'separator' => ' ', 'wrapper' => '<p>%s</p>'] );
73+
* @usage BEA\Theme\Framework\Helpers\Formatting\Term\the_terms_list( $terms ,['items' => '<span>%s</span>', 'separator' => ' ', 'wrapper' => '<p>%s</p>'] );
8274
*
83-
* @param int|\WP_Post $post Post ID or object.
84-
* @param string $taxonomy Taxonomy name.
75+
* @param \WP_Term[] $terms list of terms
8576
*
8677
* @param array $settings {
8778
* Optional. Settings for the terms list markup.
@@ -94,6 +85,6 @@ function get_terms_list( $post, string $taxonomy, array $settings = [] ): string
9485
*
9586
* }
9687
*/
97-
function the_terms_list( $post, string $taxonomy, array $settings = [] ): void {
98-
echo get_terms_list( $post, $taxonomy, $settings );
88+
function the_terms_list( array $terms, array $settings = [] ): void {
89+
echo get_terms_list( $terms, $settings );
9990
}

0 commit comments

Comments
 (0)