PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
28.6 28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 All 130 releases
wordpress-seo / src / llms-txt / infrastructure / markdown-services / terms-collector.php

terms-collector.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/llms-txt/infrastructure/markdown-services/terms-collector.php

66 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
4 namespace Yoast\WP\SEO\Llms_Txt\Infrastructure\Markdown_Services;
5
6 use Yoast\WP\SEO\Helpers\Taxonomy_Helper;
7 use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Items\Link;
8 use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections\Link_List;
9
10 /**
11 * The collector of terms.
12 */
13 class Terms_Collector {
14
15 /**
16 * The taxonomy helper.
17 *
18 * @var Taxonomy_Helper
19 */
20 private $taxonomy_helper;
21
22 /**
23 * The constructor.
24 *
25 * @param Taxonomy_Helper $taxonomy_helper The taxonomy helper.
26 */
27 public function __construct( Taxonomy_Helper $taxonomy_helper ) {
28 $this->taxonomy_helper = $taxonomy_helper;
29 }
30
31 /**
32 * Returns the content types in a link list.
33 *
34 * @return Link_List[] The content types in a link list.
35 */
36 public function get_terms_lists(): array {
37 $taxonomies = $this->taxonomy_helper->get_indexable_taxonomy_objects();
38 $link_list = [];
39
40 foreach ( $taxonomies as $taxonomy ) {
41 if ( $this->taxonomy_helper->is_indexable( $taxonomy->name ) === false ) {
42 continue;
43 }
44
45 $terms = \get_categories(
46 [
47 'taxonomy' => $taxonomy->name,
48 'number' => 5,
49 'orderby' => 'count',
50 'order' => 'DESC',
51 ],
52 );
53
54 $term_links = new Link_List( $taxonomy->label, [] );
55 foreach ( $terms as $term ) {
56 $term_link = new Link( $term->name, \get_term_link( $term, $taxonomy->name ) );
57 $term_links->add_link( $term_link );
58 }
59
60 $link_list[] = $term_links;
61 }
62
63 return $link_list;
64 }
65 }
66