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

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

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

0.0
/src/presentations/indexable-date-archive-presentation.php
1
<?php
2

3
namespace Yoast\WP\SEO\Presentations;
4

5
use Yoast\WP\SEO\Helpers\Pagination_Helper;
6

7
/**
8
 * Class Indexable_Date_Archive_Presentation.
9
 *
10
 * Presentation object for indexables.
11
 */
12
class Indexable_Date_Archive_Presentation extends Indexable_Presentation {
13

14
        /**
15
         * Holds the Pagination_Helper instance.
16
         *
17
         * @var Pagination_Helper
18
         */
19
        protected $pagination;
20

21
        /**
22
         * Indexable_Date_Archive_Presentation constructor.
23
         *
24
         * @param Pagination_Helper $pagination The pagination helper.
25
         */
26
        public function __construct( Pagination_Helper $pagination ) {
27
                $this->pagination = $pagination;
×
28
        }
29

30
        /**
31
         * Generates the canonical.
32
         *
33
         * @return string The canonical.
34
         */
35
        public function generate_canonical() {
36
                $canonical = $this->current_page->get_date_archive_permalink();
×
37

38
                $current_page = $this->pagination->get_current_archive_page_number();
×
39
                if ( $current_page > 1 ) {
×
40
                        return $this->pagination->get_paginated_url( $canonical, $current_page );
×
41
                }
42

43
                return $canonical;
×
44
        }
45

46
        /**
47
         * Generates the robots value.
48
         *
49
         * @return array The robots value.
50
         */
51
        public function generate_robots() {
52
                $robots = $this->get_base_robots();
×
53

54
                if ( $this->options->get( 'noindex-archive-wpseo', false ) ) {
×
55
                        $robots['index'] = 'noindex';
×
56
                }
57

58
                return $this->filter_robots( $robots );
×
59
        }
60

61
        /**
62
         * Generates the title.
63
         *
64
         * @return string The title.
65
         */
66
        public function generate_title() {
67
                if ( $this->model->title ) {
×
68
                        return $this->model->title;
×
69
                }
70

71
                return $this->options->get_title_default( 'title-archive-wpseo' );
×
72
        }
73

74
        /**
75
         * Generates the rel prev.
76
         *
77
         * @return string The rel prev value.
78
         */
79
        public function generate_rel_prev() {
80
                if ( $this->pagination->is_rel_adjacent_disabled() ) {
×
81
                        return '';
×
82
                }
83

84
                $current_page = \max( 1, $this->pagination->get_current_archive_page_number() );
×
85
                // Check if there is a previous page.
86
                if ( $current_page === 1 ) {
×
87
                        return '';
×
88
                }
89
                // Check if the previous page is the first page.
90
                if ( $current_page === 2 ) {
×
91
                        return $this->current_page->get_date_archive_permalink();
×
92
                }
93

94
                return $this->pagination->get_paginated_url( $this->current_page->get_date_archive_permalink(), ( $current_page - 1 ) );
×
95
        }
96

97
        /**
98
         * Generates the rel next.
99
         *
100
         * @return string The rel prev next.
101
         */
102
        public function generate_rel_next() {
103
                if ( $this->pagination->is_rel_adjacent_disabled() ) {
×
104
                        return '';
×
105
                }
106

107
                $current_page = \max( 1, $this->pagination->get_current_archive_page_number() );
×
108
                if ( $this->pagination->get_number_of_archive_pages() <= $current_page ) {
×
109
                        return '';
×
110
                }
111

112
                return $this->pagination->get_paginated_url( $this->current_page->get_date_archive_permalink(), ( $current_page + 1 ) );
×
113
        }
114

115
        /**
116
         * Generates the open graph url.
117
         *
118
         * @return string The open graph url.
119
         */
120
        public function generate_open_graph_url() {
121
                return $this->current_page->get_date_archive_permalink();
×
122
        }
123
}
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

© 2026 Coveralls, Inc