: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// USAGE: replace references to the blog home url such as:
// with wpml_get_home_url()
// * IMPORTANT: Most themes also add a trailing slash (/) to the URL. This function already includes it, so don't add the slash when using it.
function wpml_get_home_url(){
if(function_exists('icl_get_home_url')){
return icl_get_home_url();
return rtrim(get_bloginfo('url') , '/') . '/';
// USAGE place this on the single.php, page.php, index.php etc... - inside the loop
// function wpml_content_languages($args)
// args: skip_missing, before, after
// defaults: skip_missing = 1, before = __('This post is also available in: '), after = ''
function wpml_content_languages( $args = '' ) {
$languages_items = array();
parse_str( $args, $params );
if(array_key_exists( 'before', $params)) {
$before = $params['before'];
if(array_key_exists( 'after', $params)) {
$after = $params['after'];
if ( function_exists( 'icl_get_languages' ) ) {
$languages = icl_get_languages( $args );
if ( 1 < count( $languages ) ) {
echo isset( $before ) ? esc_html( $before ) : esc_html__( 'This post is also available in: ', 'sitepress' );
foreach ( $languages as $l ) {
$languages_items[] = '<a href="' . $l['url'] . '">' . $l['translated_name'] . '</a>';
echo join( ', ', $languages_items );
echo isset( $after ) ? esc_html( $after ) : '';
// LINKS TO SPECIFIC ELEMENTS
// args: $element_id, $element_type='post', $link_text='', $optional_parameters=array(), $anchor='', $echoit = true
function wpml_link_to_element($element_id, $element_type='post', $link_text='', $optional_parameters=array(), $anchor='', $echoit = true){
if(!function_exists('icl_link_to_element')){
$ret = '<a href="'. esc_url( get_permalink($element_id) ) .'">';
$ret .= esc_html( $anchor );
$ret .= esc_html( get_the_title($element_id) );
$tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
$ret = '<a href="'.esc_url( get_tag_link($element_id) ) .'">' . esc_html( $tag->name ) . '</a>';
$ret = '<a href="'.esc_url( get_tag_link($element_id) ) .'">' . esc_html( get_the_category_by_ID($element_id) ) . '</a>';
return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
// Languages links to display in the footer
function wpml_languages_list($skip_missing=0, $div_id = "footer_language_list"){
if(function_exists('icl_get_languages')){
$languages = icl_get_languages('skip_missing='.intval($skip_missing));
echo '<div id="'. esc_attr( $div_id ) .'"><ul>';
foreach($languages as $l){
if(!$l['active']) echo '<a href="'. esc_url( $l['url'] ) .'">';
echo '<img src="'. esc_url( $l['country_flag_url'] ) .'" alt="'. esc_attr( $l['language_code'] ) .'" />';
if(!$l['active']) echo '</a>';
if(!$l['active']) echo '<a href="'. esc_url( $l['url'] ) .'">';
if(!$l['active']) echo ' ('. esc_attr( $l['translated_name'] ) .')';
if(!$l['active']) echo '</a>';
function wpml_languages_selector(){
do_action('icl_language_selector');
function wpml_t($context, $name, $original_value){
if(function_exists('icl_t')){
return icl_t($context, $name, $original_value);
function wpml_register_string($context, $name, $value){
if(function_exists('icl_register_string') && trim($value)){
icl_register_string($context, $name, $value);
function wpml_get_object_id($element_id, $element_type='post', $return_original_if_missing=false, $ulanguage_code=null){
if(function_exists('icl_object_id')){
return icl_object_id($element_id, $element_type, $return_original_if_missing, $ulanguage_code);
function wpml_default_link($anchor){
$qv = 'p=' . get_the_ID();
$qv = 'page_id=' . get_the_ID();
$tag = &get_term(intval( get_query_var('tag_id') ), 'post_tag', OBJECT, 'display');
$qv = 'tag=' . $tag->slug;
$qv = 'cat=' . get_query_var('cat');
$qv = 'year=' . get_query_var('year');
$qv = 'm=' . get_query_var('year') . sprintf('%02d', get_query_var('monthnum'));
$qv = 'm=' . get_query_var('year') . sprintf('%02d', get_query_var('monthnum')) . sprintf('%02d', get_query_var('day'));
$qv = 's=' . get_query_var('s');
$qv = get_query_var('taxonomy') . '=' . get_query_var('term');
if(false !== strpos(wpml_get_home_url(),'?')){
$link = '<a href="' . $sitepress->language_url($sitepress->get_default_language()) . $url_glue . $qv . '" rel="nofollow">' . esc_html($anchor) . '</a>';