Skip to content

Commit bb1212c

Browse files
authored
Print alternate links without title (#420)
1 parent 6a4d3de commit bb1212c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

includes/MslsOutput.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,23 @@ public function get_alternate_links() {
9898
$blogs = msls_blog_collection();
9999
$hlObj = new HrefLang( $blogs );
100100
$options = MslsOptions::create();
101-
102101
$arr = array();
103102
$default = '';
104103

105104
foreach ( $blogs->get_objects() as $blog ) {
106105
$url = apply_filters( 'mlsl_output_get_alternate_links', $blog->get_url( $options ), $blog );
107-
108106
if ( is_null( $url ) ) {
109107
continue;
110108
}
111109

112-
$description = $blog->get_description();
113-
$hreflang = $hlObj->get( $blog->get_language() );
110+
$hreflang = $hlObj->get( $blog->get_language() );
111+
$format = '<link rel="alternate" href="%1$s" hreflang="%2$s" />';
114112

115-
$format = '<link rel="alternate" hreflang="%s" href="%s" title="%s" />';
116113
if ( '' === $default ) {
117-
$default = sprintf( $format, 'x-default', esc_url( $url ), esc_attr( $description ) );
114+
$default = sprintf( $format, esc_url( $url ), 'x-default' );
118115
}
119116

120-
$arr[] = sprintf( $format, esc_attr( $hreflang ), esc_url( $url ), esc_attr( $description ) );
117+
$arr[] = sprintf( $format, esc_url( $url ), esc_attr( $hreflang ) );
121118
}
122119

123120
if ( 1 === count( $arr ) ) {

tests/phpunit/TestMslsOutput.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function test_get_alternate_links_two_url(): void {
6868
Filters\expectApplied( 'mlsl_output_get_alternate_links_arr' )->once();
6969

7070
$expected =
71-
'<link rel="alternate" hreflang="de" href="https://example.de/" title="Deutsch" />' . PHP_EOL .
72-
'<link rel="alternate" hreflang="it" href="https://example.it/" title="Italiano" />';
71+
'<link rel="alternate" href="https://example.de/" hreflang="de" />' . PHP_EOL .
72+
'<link rel="alternate" href="https://example.it/" hreflang="it" />';
7373

7474
$test = $this->MslsOutputFactory();
7575

@@ -138,7 +138,7 @@ public function test_get_alternate_links_one_url(): void {
138138

139139
Filters\expectApplied( 'mlsl_output_get_alternate_links_default' )->once();
140140

141-
$expected = '<link rel="alternate" hreflang="x-default" href="https://example.de/" title="Deutsch" />';
141+
$expected = '<link rel="alternate" href="https://example.de/" hreflang="x-default" />';
142142

143143
$test = $this->MslsOutputFactory();
144144

0 commit comments

Comments
 (0)