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

Yoast / wordpress-seo / ede6fd7c0b60c6046f5ca05162944c7a397d5d8b

20 Nov 2024 03:11PM UTC coverage: 54.21% (-2.9%) from 57.113%
ede6fd7c0b60c6046f5ca05162944c7a397d5d8b

Pull #21847

github

web-flow
Merge 428b097d7 into 74d330cc7
Pull Request #21847: Create API endpoints for SEO and readability scores

7593 of 13666 branches covered (55.56%)

Branch coverage included in aggregate %.

0 of 303 new or added lines in 24 files covered. (0.0%)

29764 of 55246 relevant lines covered (53.88%)

41542.83 hits per line

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

0.0
/src/dashboard/infrastructure/scores/score-link-collector.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
3
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
4
namespace Yoast\WP\SEO\Dashboard\Infrastructure\Scores;
5

6
use Yoast\WP\SEO\Dashboard\Domain\Content_Types\Content_Type;
7
use Yoast\WP\SEO\Dashboard\Domain\Scores\Scores_Interface;
8
use Yoast\WP\SEO\Dashboard\Domain\Taxonomies\Taxonomy;
9

10
/**
11
 * Getting links for scores.
12
 */
13
class Score_Link_Collector {
14

15
        /**
16
         * Builds the view link of the score.
17
         *
18
         * @param Scores_Interface $score_name   The name of the score.
19
         * @param Content_Type     $content_type The content type.
20
         * @param Taxonomy|null    $taxonomy     The taxonomy of the term we might be filtering.
21
         * @param int|null         $term_id      The ID of the term we might be filtering.
22
         *
23
         * @return string The view link of the score.
24
         */
NEW
25
        public function get_view_link( Scores_Interface $score_name, Content_Type $content_type, ?Taxonomy $taxonomy, ?int $term_id ): ?string {
×
NEW
26
                $posts_page = \admin_url( 'edit.php' );
×
27
                $args       = [
NEW
28
                        'post_status'                  => 'publish',
×
NEW
29
                        'post_type'                    => $content_type->get_name(),
×
NEW
30
                        $score_name->get_filter_key()  => $score_name->get_filter_value(),
×
31
                ];
32

NEW
33
                if ( $taxonomy === null || $term_id === null ) {
×
NEW
34
                        return \add_query_arg( $args, $posts_page );
×
35
                }
36

NEW
37
                $taxonomy_object = \get_taxonomy( $taxonomy->get_name() );
×
NEW
38
                $query_var       = $taxonomy_object->query_var;
×
39

NEW
40
                if ( $query_var === false ) {
×
NEW
41
                        return null;
×
42
                }
43

NEW
44
                $term               = \get_term( $term_id );
×
NEW
45
                $args[ $query_var ] = $term->slug;
×
46

NEW
47
                return \add_query_arg( $args, $posts_page );
×
48
        }
49
}
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