3
3
4
4
use function BEA \Theme \Framework \Helpers \Formatting \Escape \escape_content_value ;
5
5
/**
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 );
7
7
*
8
- * @param int|\WP_Post $post Post ID or object.
9
- * @param string $taxonomy Taxonomy name
8
+ * @param \WP_Term[] $terms list of terms
10
9
*
11
10
* @return array Return an array with the terms name
12
11
*/
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 {
20
13
return wp_list_pluck ( $ terms , 'name ' );
21
14
}
22
15
23
16
/**
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>'] );
25
18
*
26
- * @param int|\WP_Post $post Post ID or object.
27
- * @param string $taxonomy Taxonomy name.
19
+ * @param \WP_Term[] $terms list of terms
28
20
*
29
21
* @param array $settings {
30
22
* Optional. Settings for the terms list markup.
@@ -39,9 +31,9 @@ function get_terms_name( $post_id, string $taxonomy ): array {
39
31
*
40
32
* @return string
41
33
*/
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 );
45
37
46
38
if ( empty ( $ terms ) ) {
47
39
return '' ;
@@ -78,10 +70,9 @@ function get_terms_list( $post, string $taxonomy, array $settings = [] ): string
78
70
}
79
71
80
72
/**
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>'] );
82
74
*
83
- * @param int|\WP_Post $post Post ID or object.
84
- * @param string $taxonomy Taxonomy name.
75
+ * @param \WP_Term[] $terms list of terms
85
76
*
86
77
* @param array $settings {
87
78
* Optional. Settings for the terms list markup.
@@ -94,6 +85,6 @@ function get_terms_list( $post, string $taxonomy, array $settings = [] ): string
94
85
*
95
86
* }
96
87
*/
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 );
99
90
}
0 commit comments