Skip to content

Commit

Permalink
Who thought there'd be multiple language overrides
Browse files Browse the repository at this point in the history
Lists alternate hreflang cultures without duplicates
  • Loading branch information
oliveratgithub committed Aug 9, 2023
1 parent 793d335 commit 15ba8be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions language-locale-overwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ function get_posts_with_language_locale_overwrite( $type, $locale ) {
* This function retrieves all the language locales that have been set
* as custom values for the 'language_locale_overwrite' meta key.
*
* @param bool $no_duplicates If true, filters out any duplicates. Default: true
* @return array An array of language locales.
*/
function get_all_custom_language_locales( ) {
function get_all_custom_language_locales( $no_duplicates=true ) {

$query = new WP_Query([
'meta_key' => 'language_locale_overwrite'
Expand All @@ -251,7 +252,8 @@ function get_all_custom_language_locales( ) {
foreach( $query->posts as $post_id ) {
$defined_language_locales[] = get_post_meta( $post_id, 'language_locale_overwrite', true );
}
return $defined_language_locales;
$list_of_custom_locales = ( $no_duplicates ? array_unique($defined_language_locales) : $defined_language_locales);
return $list_of_custom_locales;

}

Expand Down

0 comments on commit 15ba8be

Please sign in to comment.