diff --git a/includes/MslsOutput.php b/includes/MslsOutput.php index 90cc01c6..18b93a9a 100644 --- a/includes/MslsOutput.php +++ b/includes/MslsOutput.php @@ -103,6 +103,7 @@ public function get_alternate_links() { $arr = []; $default = ''; + $default_locale = apply_filters('mlsl_output_x_default_locale', null); foreach ( $blogs->get_objects() as $blog ) { $url = apply_filters( 'mlsl_output_get_alternate_links', $blog->get_url( $options ), $blog ); @@ -114,14 +115,14 @@ public function get_alternate_links() { $description = $blog->get_description(); $format = ''; - if ( '' === $default ) { - $default = sprintf( $format, 'x-default', $url, esc_attr( $description ) ); + if ( '' === $default || $blog->get_language() === $default_locale ) { + $default = sprintf( $format, 'x-default', $url, esc_attr( $description ) ); } $arr[] = sprintf( $format, $hreflang->get( $blog->get_language() ), $url, esc_attr( $description ) ); } - return 1 === count( $arr ) ? $default : implode( PHP_EOL, $arr ); + return 1 === count( $arr ) ? $default : implode( PHP_EOL, $arr ) . (is_null($default_locale) ? '' : $default); } /**