v1.3.1
This commit is contained in:
parent
e3bfd7b6f2
commit
a2d1320030
5 changed files with 62 additions and 7 deletions
|
|
@ -210,7 +210,7 @@ class Robotstxt_Manager_Updater {
|
|||
'requires_php' => $this->str( $row, 'requires_php', '' ),
|
||||
'tested_up_to' => $this->str( $row, 'tested_up_to', '' ),
|
||||
'page_url' => $this->str( $row, 'page_url', '' ),
|
||||
'description' => $this->str( $row, 'description', '' ),
|
||||
'description' => $this->localized_description( $row ),
|
||||
'icon_url' => $this->str( $row, 'icon_url', '' ),
|
||||
'banner_url' => $this->str( $row, 'banner_url', '' ),
|
||||
);
|
||||
|
|
@ -340,6 +340,27 @@ class Robotstxt_Manager_Updater {
|
|||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks the description for the current admin user's locale, falling
|
||||
* back to the default (English) description.
|
||||
*
|
||||
* @param array<string, mixed> $row Catalog row.
|
||||
*
|
||||
* @return string The localized (or default) description.
|
||||
*/
|
||||
private function localized_description( array $row ): string {
|
||||
$raw_translations = $row['description_translations'] ?? '';
|
||||
$translations = is_array( $raw_translations ) ? $raw_translations : array();
|
||||
$user_locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
|
||||
$locale_text = $translations[ $user_locale ] ?? '';
|
||||
|
||||
if ( is_string( $locale_text ) && '' !== trim( $locale_text ) ) {
|
||||
return trim( $locale_text );
|
||||
}
|
||||
|
||||
return $this->str( $row, 'description', '' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a string value from a mixed-value row.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue