• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 481faf637ba3a7c1e5f2bfef59b582ac39523de6

21 May 2025 09:11AM UTC coverage: 46.174%. First build
481faf637ba3a7c1e5f2bfef59b582ac39523de6

Pull #22291

github

web-flow
Merge pull request #22278 from Yoast/577-sanitize-and-deal-with-special-markdown-characters-before-writing-to-file

577 sanitize and deal with special markdown characters before writing to file
Pull Request #22291: Introduce the llms.txt feature

52 of 403 new or added lines in 30 files covered. (12.9%)

15586 of 33755 relevant lines covered (46.17%)

3.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/llms-txt/infrastructure/markdown-services/terms-collector.php
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
         */
NEW
27
        public function __construct( Taxonomy_Helper $taxonomy_helper ) {
×
NEW
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
         */
NEW
36
        public function get_terms_lists(): array {
×
NEW
37
                $taxonomies = $this->taxonomy_helper->get_indexable_taxonomy_objects();
×
NEW
38
                $link_list  = [];
×
39

NEW
40
                foreach ( $taxonomies as $taxonomy ) {
×
NEW
41
                        if ( $this->taxonomy_helper->is_indexable( $taxonomy->name ) === false ) {
×
NEW
42
                                continue;
×
43
                        }
44

NEW
45
                        $terms = \get_categories(
×
NEW
46
                                [
×
NEW
47
                                        'taxonomy' => $taxonomy->name,
×
NEW
48
                                        'number'   => 5,
×
NEW
49
                                        'orderby'  => 'count',
×
NEW
50
                                        'order'    => 'DESC',
×
NEW
51
                                ]
×
NEW
52
                        );
×
53

NEW
54
                        $term_links = new Link_List( $taxonomy->label, [] );
×
NEW
55
                        foreach ( $terms as $term ) {
×
NEW
56
                                $term_link = new Link( $term->name, \get_term_link( $term, $taxonomy->name ) );
×
NEW
57
                                $term_links->add_link( $term_link );
×
58
                        }
59

NEW
60
                        $link_list[] = $term_links;
×
61
                }
62

NEW
63
                return $link_list;
×
64
        }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc