@@ -83,37 +83,40 @@ private function _eval_links(array $link_nodes, string $page_url): array
83
83
break ;
84
84
}
85
85
}
86
- if ($ link_quality_eval ['is_redirect ' ] && !$ skip_redirect ) {
87
- $ errors [] = (object ) [
88
- 'type ' => 'redirect ' ,
89
- 'href ' => $ path ,
90
- 'text ' => $ text ,
91
- 'html ' => $ html ,
92
- 'recommendation ' => 'Use the final redirected link. ' ];
93
- }
94
86
if ($ link_quality_eval ['is_dead ' ]) {
95
87
$ errors [] = (object ) [
96
88
'type ' => 'dead ' ,
97
89
'href ' => $ path ,
98
90
'text ' => $ text ,
99
91
'html ' => $ html ,
100
92
'recommendation ' => 'Find an alternative working link. ' ];
101
- }
102
- if ($ link_quality_eval ['is_same_domain ' ]) {
103
- $ errors [] = (object ) [
104
- 'type ' => 'domain overlap ' ,
105
- 'href ' => $ path ,
106
- 'text ' => $ text ,
107
- 'html ' => $ html ,
108
- 'recommendation ' => 'Use relative URL. ' ];
109
- }
110
- if ($ link_quality_eval ['timed_out ' ]) {
111
- $ errors [] = (object ) [
112
- 'type ' => 'slow connection ' ,
113
- 'href ' => $ path ,
114
- 'text ' => $ text ,
115
- 'html ' => $ html ,
116
- 'recommendation ' => 'Troubleshoot why the page takes so long to load. ' ];
93
+ } else {
94
+ if ($ link_quality_eval ['timed_out ' ]) {
95
+ $ errors [] = (object ) [
96
+ 'type ' => 'slow connection ' ,
97
+ 'href ' => $ path ,
98
+ 'text ' => $ text ,
99
+ 'html ' => $ html ,
100
+ 'recommendation ' => 'Troubleshoot why the page takes so long to load. ' ];
101
+ } else {
102
+ if ($ link_quality_eval ['is_same_domain ' ]) {
103
+ $ errors [] = (object ) [
104
+ 'type ' => 'domain overlap ' ,
105
+ 'href ' => $ path ,
106
+ 'text ' => $ text ,
107
+ 'html ' => $ html ,
108
+ 'recommendation ' => 'Use relative URL. ' ];
109
+ } else {
110
+ if ($ link_quality_eval ['is_redirect ' ] && !$ skip_redirect ) {
111
+ $ errors [] = (object ) [
112
+ 'type ' => 'redirect ' ,
113
+ 'href ' => $ path ,
114
+ 'text ' => $ text ,
115
+ 'html ' => $ html ,
116
+ 'recommendation ' => 'Use the final redirected link. ' ];
117
+ }
118
+ }
119
+ }
117
120
}
118
121
119
122
// check link-text accessibility
@@ -125,41 +128,43 @@ private function _eval_links(array $link_nodes, string $page_url): array
125
128
'text ' => $ text ,
126
129
'html ' => $ html ,
127
130
'recommendation ' => 'Use more descriptive and specific wording. ' ];
128
- }
129
- if (!$ link_text_eval ['passed_text_not_url ' ]) {
130
- $ errors [] = (object ) [
131
- 'type ' => 'url link text ' ,
132
- 'href ' => $ path ,
133
- 'text ' => $ text ,
134
- 'html ' => $ html ,
135
- 'recommendation ' => 'Use real words that describe the link. ' ];
136
- }
137
- if (!$ link_text_eval ['passed_text_length ' ]) {
138
- $ errors [] = (object ) [
139
- 'type ' => 'bad text length ' ,
140
- 'href ' => $ path ,
141
- 'text ' => $ text ,
142
- 'html ' => $ html ,
143
- 'recommendation ' => 'Ideal link text should be between 1 to 100 characters. ' ];
144
- }
145
- if ($ link_text_eval ['url_is_pdf ' ]) {
146
- if (!$ link_text_eval ['text_has_pdf ' ]) {
147
- $ errors [] = (object ) [
148
- 'type ' => 'unclear pdf link ' ,
149
- 'href ' => $ path ,
150
- 'text ' => $ text ,
151
- 'html ' => $ html ,
152
- 'recommendation ' => 'Include the word "PDF" in the link. ' ];
153
- }
154
131
} else {
155
- if ($ link_text_eval ['url_is_download ' ] &&
156
- $ link_text_eval ['text_has_download ' ]) {
132
+ if (!$ link_text_eval ['passed_text_not_url ' ]) {
157
133
$ errors [] = (object ) [
158
- 'type ' => 'unclear download link ' ,
134
+ 'type ' => 'url link text ' ,
135
+ 'href ' => $ path ,
136
+ 'text ' => $ text ,
137
+ 'html ' => $ html ,
138
+ 'recommendation ' => 'Use real words that describe the link. ' ];
139
+ } else {
140
+ if (!$ link_text_eval ['passed_text_length ' ]) {
141
+ $ errors [] = (object ) [
142
+ 'type ' => 'bad text length ' ,
159
143
'href ' => $ path ,
160
144
'text ' => $ text ,
161
145
'html ' => $ html ,
162
- 'recommendation ' => 'Include the word "download" in the link. ' ];
146
+ 'recommendation ' => 'Ideal link text should be between 1 to 100 characters. ' ];
147
+ }
148
+ }
149
+ if ($ link_text_eval ['url_is_pdf ' ]) {
150
+ if (!$ link_text_eval ['text_has_pdf ' ]) {
151
+ $ errors [] = (object ) [
152
+ 'type ' => 'unclear pdf link ' ,
153
+ 'href ' => $ path ,
154
+ 'text ' => $ text ,
155
+ 'html ' => $ html ,
156
+ 'recommendation ' => 'Include the word "PDF" in the link. ' ];
157
+ }
158
+ } else {
159
+ if ($ link_text_eval ['url_is_download ' ] &&
160
+ $ link_text_eval ['text_has_download ' ]) {
161
+ $ errors [] = (object ) [
162
+ 'type ' => 'unclear download link ' ,
163
+ 'href ' => $ path ,
164
+ 'text ' => $ text ,
165
+ 'html ' => $ html ,
166
+ 'recommendation ' => 'Include the word "download" in the link. ' ];
167
+ }
163
168
}
164
169
}
165
170
}
0 commit comments