Skip to main content

benecaster_available_locales

Filter Free

Filters the list of locales available for selection in Settings. Each locale object must have: code (BCP 47 string), english_name (string), native_name (string). Add a locale to make it selectable in Settings and available for email template resolution.

Return the array. Cast with (array). Each row is { code: string, english_name: string, native_name: string } — all three keys are expected by the language settings UI, and a row missing one renders a blank cell rather than being skipped.

code must be a WordPress locale identifier (es_MX, not es-MX and not Spanish); an unrecognised code is offered in the picker and then fails to resolve a template at send time. Returning an empty array leaves the settings screen with no selectable locales.

Parameters

Name Type Default Description
$locales array Array of locale objects: {code: string, english_name: string, native_name: string}

Returns: array

Example

add_filter( 'benecaster_available_locales', function( $locales ) {
    // Add Brazilian Portuguese to the locale picker.
    $locales[] = [
        'code'         => 'pt_BR',
        'english_name' => 'Brazilian Portuguese',
        'native_name'  => 'Português (Brasil)',
    ];
    return $locales;
} );

Affects

  • Settings locale picker
  • Email template file resolution

Need this built rather than just documented? See our services →