The theme I am using has a function to embed videos from Facebook. The problem is that whenever I use it it loads the SDK in uk_UA
for whatever reasons (Ukrainian).
Nothing related to my Website or Facebook is using this language. After contacting the theme developers i was told it's not their fault and might be something related to the server configuration.
I tried an hacky solution I found here with adding to the funcitons.php the following script
add_filter( 'the_content', 'facebook_sdk_replace' );
function facebook_sdk_replace( $content ) { if ( is_single() ) { $content = str_replace("/uk_UA/", "/en_US/", $content); } return $content; }
As it had no effect, the developer suggested I should add to the _header_php the following
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
The problem I am facing is that by doing so, I am getting the following error:
Cannot modify header information - headers already sent by...
Therefore, I reverted back my header.php. Is there a way to fix this issue without altering the header?
Later edit: The only code snippet I found is the following:
/* $buffy = '
<div class="wpb_video_wrapper td-facebook-video">
<iframe src="' . td_global::$http_or_https . '://www.facebook.com/plugins/video.php?href=' . urlencode($videoUrl) . '&show_text=0" width="' . $width . '" height="' . $height . '" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true" ></iframe>
</div>
';
*/
/**
* cache & oembed implementation
*/
$cache_key = self::get_facebook_id($videoUrl);
$group = 'td_facebook_video';
if (td_remote_cache::is_expired($group, $cache_key) === true) {
// cache is expired - do a request
$facebook_api_json = td_remote_http::get_page('https://www.facebook.com/plugins/video/oembed.json/?url=' . urlencode($videoUrl) , __CLASS__);
if ($facebook_api_json !== false) {
$facebook_api = @json_decode($facebook_api_json);
//json data decode
if ($facebook_api === null and json_last_error() !== JSON_ERROR_NONE) {
td_log::log(__FILE__, __FUNCTION__, 'json decode failed for facebook video embed api', $videoUrl);
}
if (is_object($facebook_api) and !empty($facebook_api->html)) {
//add the html to the buffer
$buffy = '<div class="wpb_video_wrapper">' . $facebook_api->html . '</div>';
//set the cache
td_remote_cache::set($group, $cache_key, $facebook_api->html, self::$caching_time);
}
} else {
td_log::log(__FILE__, __FUNCTION__, 'facebook api html data cannot be retrieved/json request failed', $videoUrl);
}
} else {
// cache is valid
$api_html_embed_data = td_remote_cache::get($group, $cache_key);
$buffy = '<div class="wpb_video_wrapper">' . $api_html_embed_data . '</div>';
}
break;
connect.facebook
contains? We will try to suggest where you should make changes thenheader
function. Even a blank line or space will give this error.