: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace Yoast\WP\SEO\Generators;
use Yoast\WP\SEO\Context\Meta_Tags_Context;
* Class Open_Graph_Locale_Generator.
class Open_Graph_Locale_Generator implements Generator_Interface {
* Generates the OG Locale.
* @param Meta_Tags_Context $context The context.
* @return string The OG locale.
public function generate( Meta_Tags_Context $context ) {
* Filter: 'wpseo_locale' - Allow changing the locale output.
* Note that this filter is different from `wpseo_og_locale`, which is run _after_ the OG specific filtering.
* @param string $locale Locale string.
$locale = \apply_filters( 'wpseo_locale', \get_locale() );
// Catch some weird locales served out by WP that are not easily doubled up.
if ( isset( $fix_locales[ $locale ] ) ) {
return $fix_locales[ $locale ];
// Convert locales like "es" to "es_ES", in case that works for the given locale (sometimes it does).
if ( \strlen( $locale ) === 2 ) {
$locale = \strtolower( $locale ) . '_' . \strtoupper( $locale );
// These are the locales FB supports.
'cb_IQ', // Sorani Kurdish.
'en_GB', // English (UK).
'en_PI', // English (Pirate).
'en_UD', // English (Upside Down).
'en_US', // English (US).
'es_ES', // Spanish (Spain).
'es_MX', // Spanish (Mexico).
'fr_CA', // French (Canada).
'fr_FR', // French (France).
'gx_GR', // Classical Greek.
'ht_HT', // Haitian Creole.
'ja_KS', // Japanese (Kansai).
'ku_TR', // Kurdish (Kurmanji).
'nb_NO', // Norwegian (bokmal).
'nl_BE', // Dutch (Belgie).
'nn_NO', // Norwegian (nynorsk).
'nr_ZA', // Southern Ndebele.
'ns_ZA', // Northern Sotho.
'pt_BR', // Portuguese (Brazil).
'pt_PT', // Portuguese (Portugal).
'qz_MM', // Burmese (Zawgyi).
'se_NO', // Northern Sami.
'st_ZA', // Southern Sotho.
'zh_CN', // Simplified Chinese (China).
'zh_HK', // Traditional Chinese (Hong Kong).
'zh_TW', // Traditional Chinese (Taiwan).
// Check to see if the locale is a valid FB one, if not, use en_US as a fallback.
if ( \in_array( $locale, $fb_valid_fb_locales, true ) ) {
$locale = \strtolower( \substr( $locale, 0, 2 ) ) . '_' . \strtoupper( \substr( $locale, 0, 2 ) );
if ( ! \in_array( $locale, $fb_valid_fb_locales, true ) ) {