: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* SitePress Template functions
* @deprecated Use 'wpml_get_capabilities' instead.
function icl_sitepress_get_capabilities() {
return wpml_get_capabilities_names();
function wpml_get_capabilities_names() {
$capabilities = wpml_get_capabilities();
return array_keys( $capabilities );
function wpml_get_capabilities_labels() {
$capabilities = wpml_get_capabilities();
return array_values( $capabilities );
function wpml_get_capabilities() {
'wpml_manage_translation_management' => __( 'Manage Translation Management', 'sitepress' ),
'wpml_manage_languages' => __( 'Manage Languages', 'sitepress' ),
'wpml_manage_theme_and_plugin_localization' => __( 'Manage Theme and Plugin localization', 'sitepress' ),
'wpml_manage_support' => __( 'Manage Support', 'sitepress' ),
'wpml_manage_woocommerce_multilingual' => __( 'Manage WooCommerce Multilingual', 'sitepress' ),
'wpml_operate_woocommerce_multilingual' => __( 'Operate WooCommerce Multilingual. Everything on WCML except the settings tab.', 'sitepress' ),
'wpml_manage_media_translation' => __( 'Manage Media translation', 'sitepress' ),
'wpml_manage_navigation' => __( 'Manage Navigation', 'sitepress' ),
'wpml_manage_sticky_links' => __( 'Manage Sticky Links', 'sitepress' ),
'wpml_manage_string_translation' => __( 'Manage String Translation', 'sitepress' ),
'wpml_manage_translation_analytics' => __( 'Manage Translation Analytics', 'sitepress' ),
'wpml_manage_wp_menus_sync' => __( 'Manage WPML Menus Sync', 'sitepress' ),
'wpml_manage_taxonomy_translation' => __( 'Manage Taxonomy Translation', 'sitepress' ),
'wpml_manage_troubleshooting' => __( 'Manage Troubleshooting', 'sitepress' ),
'wpml_manage_translation_options' => __( 'Translation options', 'sitepress' )
return apply_filters( 'wpml_capabilities', $capabilities );
function wpml_get_read_only_capabilities_filter( $empty ) {
return wpml_get_capabilities();
add_filter( 'wpml_capabilities_read_only', 'wpml_get_read_only_capabilities_filter', 10, 1 );
function wpml_get_roles() {
$wp_roles[ 'label' ] = __( 'WPML capabilities', 'sitepress' );
$wp_roles[ 'capabilities' ] = wpml_get_capabilities();
return apply_filters( 'wpml_roles', $wp_roles );
function wpml_roles_read_only_filter( $empty ) {
add_filter( 'wpml_roles_read_only', 'wpml_roles_read_only_filter', 10, 1 );
* @deprecated 3.2 use 'wpml_home_url' filter instead.
function icl_get_home_url() {
$current_language = $sitepress->get_current_language();
return $sitepress->language_url( $current_language );
* Get the home url in the current language
* To be used in place of get_option('home')
* Note: Good code will make use of get_home_url() or home_url() which apply filters natively.
* In this case there is no need to replace anything.
* @use \SitePress::api_hooks
function wpml_get_home_url_filter() {
$current_language = $sitepress->get_current_language();
return $sitepress->language_url( $current_language );
* @deprecated 3.2 use 'wpml_active_languages' filter instead.
function icl_get_languages( $a = '' ) {
$langs = $sitepress->get_ls_languages( $args );
* Get a list of the active languages
* Usually used to create custom language switchers
* @param mixed $empty_value This is normally the value the filter will be modifying.
* We are not filtering anything here therefore the NULL value
* This for the filter function to actually receive the full argument list:
* apply_filters( 'wpml_active_languages', '', $args)
* @param array|string $args {
* Optional A string of arguments to filter the language output
* @type bool $skip_missing How to treat languages with no translations. 0 | Skip language or 1 | Link to home of language for missing translations.
* @type string $link_empty_to Works in conjunction with skip_missing = 0 and allows using custom links for the languages that do not have translations
* for the current element. {%lang} can be used as placeholder for the language code. Empty by default.
* @type string $orderby Accepts id|code|name Defaults to custom.
* The custom order can be defined in the WordPress admin under WPML > Languages > Language Switcher Options
* @type string $order Accepts asc|desc
* @use \SitePress::api_hooks
function wpml_get_active_languages_filter( $empty_value, $args = '' ) {
$args = wp_parse_args( $args );
return $sitepress->get_ls_languages( $args );
* @deprecated 3.2 use 'wpml_display_language_names' filter instead.
* @param bool $translated_name
* @param bool $lang_native_hidden
* @param bool $lang_translated_hidden
function icl_disp_language( $native_name, $translated_name = false, $lang_native_hidden = false, $lang_translated_hidden = false ) {
$language_switcher = new SitePressLanguageSwitcher();
return $language_switcher->language_display( $native_name, $translated_name, ! $lang_native_hidden, ! $lang_translated_hidden );
* @deprecated since 3.6.0 / See new Language Switcher API with use of Twig templates
* Get the native or translated language name or both
* Checks if native_language_name and translated_language_name are different.
* If so, it returns them both, otherwise, it returns only one.
* Usually used in custom language switchers
* @param mixed $empty_value
* @see \wpml_get_active_languages_filter
* @param string $native_name Required The language native name
* @param string|bool $translated_name Required The language translated name Defaults to FALSE
* @param bool $lang_native_hidden Optional, default is FALSE 0|false or 1|true Whether to hide the language native name or not.
* @param bool $lang_translated_hidden Optional, default is FALSE 0|false or 1|true Whether to hide the language translated name or not.
* @return string HTML content
* @use \SitePress::api_hooks
function wpml_display_language_names_filter( $empty_value, $native_name, $translated_name = false, $lang_native_hidden = false, $lang_translated_hidden = false ) {
$language_switcher = new SitePressLanguageSwitcher();
return $language_switcher->language_display( $native_name, $translated_name, ! $lang_native_hidden, ! $lang_translated_hidden );
* @deprecated 3.2 use 'wpml_element_link' filter instead.
* @param string $element_type
* @param string $link_text
* @param array $optional_parameters
* @param bool $return_original_if_missing
function icl_link_to_element(
$optional_parameters = array(),
$return_original_if_missing = true
return wpml_link_to_element_filter( $element_id,
$return_original_if_missing );
* Get the link to an element in the current language
* Produces localized links for WordPress elements (post types and taxonomy terms)
* @param int $element_id Required The ID of the post type (post, page) or taxonomy term (tag or category) to link to.
* @param string $element_type Optional The type of element to link to. Can be 'post', 'page', 'tag' or 'category'. Defaults to 'post'
* @param string $link_text Optional The link text. Defaults to the element's name.
* @param array $optional_parameters Optional Arguments for the link.
* @param string $anchor Optional Anchor for the link.
* @param bool $echo Optional 0|false to return or 1|true to echo the localized link. Defaults to true.
* @param bool $return_original_if_missing Optional, default is TRUE If set to true it will always return a value (the original value, if translation is missing)
* @return string HTML content
* @use \SitePress::api_hooks
function wpml_link_to_element_filter(
$element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echo = true, $return_original_if_missing = true
global $sitepress, $wpdb, $wp_post_types, $wp_taxonomies;
if ( $element_type == 'tag' ) {
$element_type = 'post_tag';
if ( $element_type == 'page' ) {
$post_types = array_keys( (array) $wp_post_types );
$taxonomies = array_keys( (array) $wp_taxonomies );
if ( in_array( $element_type, $taxonomies ) ) {
$element_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id= %d AND taxonomy=%s", $element_id, $element_type ) );
} elseif ( in_array( $element_type, $post_types ) ) {
if ( in_array( $element_type, $taxonomies ) ) {
$icl_element_type = 'tax_' . $element_type;
} elseif ( in_array( $element_type, $post_types ) ) {
$icl_element_type = 'post_' . $wpdb->get_var( $wpdb->prepare( "SELECT post_type
WHERE ID = %d", $element_id ) );
$trid = $sitepress->get_element_trid( $element_id, $icl_element_type );
$translations = $sitepress->get_element_translations( $trid, $icl_element_type );
// current language is ICL_LANGUAGE_CODE
if ( isset( $translations[ ICL_LANGUAGE_CODE ] ) ) {
if ( $element_type == 'post' ) {
$url = get_permalink( $translations[ ICL_LANGUAGE_CODE ]->element_id );
$title = $translations[ ICL_LANGUAGE_CODE ]->post_title;
} elseif ( $element_type == 'post_tag' ) {
list( $term_id, $title ) = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, t.name FROM {$wpdb->term_taxonomy} tx JOIN {$wpdb->terms} t ON t.term_id = tx.term_id WHERE tx.term_taxonomy_id = %d AND tx.taxonomy='post_tag'", $translations[ ICL_LANGUAGE_CODE ]->element_id ), ARRAY_N );
$url = get_tag_link( $term_id );
$title = apply_filters( 'single_cat_title', $title );
} elseif ( $element_type == 'category' ) {
list( $term_id, $title ) = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, t.name FROM {$wpdb->term_taxonomy} tx JOIN {$wpdb->terms} t ON t.term_id = tx.term_id WHERE tx.term_taxonomy_id = %d AND tx.taxonomy='category'", $translations[ ICL_LANGUAGE_CODE ]->element_id ), ARRAY_N );
$url = get_category_link( $term_id );
$title = apply_filters( 'single_cat_title', $title );
list( $term_id, $title ) = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, t.name FROM {$wpdb->term_taxonomy} tx JOIN {$wpdb->terms} t ON t.term_id = tx.term_id WHERE tx.term_taxonomy_id = %d AND tx.taxonomy=%s", $translations[ ICL_LANGUAGE_CODE ]->element_id, $element_type ), ARRAY_N );
$url = get_term_link( $term_id, $element_type );
$title = apply_filters( 'single_cat_title', $title );
if ( ! $return_original_if_missing ) {
if ( $element_type == 'post' ) {
$url = get_permalink( $element_id );
$title = get_the_title( $element_id );
} elseif ( $element_type == 'post_tag' ) {
$url = get_tag_link( $element_id );
$my_tag = &get_term( $element_id, 'post_tag', OBJECT, 'display' );
$title = apply_filters( 'single_tag_title', $my_tag->name );
} elseif ( $element_type == 'category' ) {
$url = get_category_link( $element_id );
$my_cat = &get_term( $element_id, 'category', OBJECT, 'display' );
$title = apply_filters( 'single_cat_title', $my_cat->name );
$url = get_term_link( (int) $element_id, $element_type );
$my_cat = &get_term( $element_id, $element_type, OBJECT, 'display' );
$title = apply_filters( 'single_cat_title', $my_cat->name );
if ( ! $url || is_wp_error( $url ) ) {
if ( ! empty( $optional_parameters ) ) {
$url_glue = false === strpos( $url, '?' ) ? '?' : '&';
$url .= $url_glue . http_build_query( $optional_parameters );
if ( isset( $anchor ) && $anchor ) {
$link = '<a href="' . esc_url( $url ) . '">';
if ( isset( $link_text ) && $link_text ) {
$link .= esc_html( $link_text );
$link .= esc_html( $title );
* @deprecated 3.2 use 'wpml_object_id' filter instead.
* @param string $element_type
* @param bool $return_original_if_missing
* @param null|string $ulanguage_code
function icl_object_id( $element_id, $element_type = 'post', $return_original_if_missing = false, $ulanguage_code = null ) {
return wpml_object_id_filter($element_id, $element_type, $return_original_if_missing, $ulanguage_code);
* @deprecated @since 3.2: use 'wpml_object_id' with the same arguments
* @use \SitePress::api_hooks
add_filter( 'translate_object_id', 'icl_object_id', 10, 4 );
* Get the element in the current language
* @param int $element_id Use term_id for taxonomies, post_id for posts
* @param string $element_type Use post, page, {custom post type name}, nav_menu, nav_menu_item, category, tag, etc.
* You can also pass 'any', to let WPML guess the type, but this will only work for posts.
* @param bool $return_original_if_missing Optional, default is FALSE. If set to true it will always return a value (the original value, if translation is missing).
* @param string|NULL $language_code Optional, default is NULL. If missing, it will use the current language.
* If set to a language code, it will return a translation for that language code or
* the original if the translation is missing and $return_original_if_missing is set to TRUE.
* @use \SitePress::api_hooks
function wpml_object_id_filter( $element_id, $element_type = 'post', $return_original_if_missing = false, $language_code = null ) {
return $sitepress->get_object_id( $element_id, $element_type, $return_original_if_missing, $language_code );
* @deprecated 3.2 use 'wpml_translated_language_name' filter instead
* @param bool $display_code
function icl_get_display_language_name( $lang_code, $display_code = false ) {
return $sitepress->get_display_language_name( $lang_code, $display_code );
* Returns the translated name of a language in another language.
* The languages involved do not need to be active.
* @param mixed $empty_value
* @see \wpml_get_active_languages_filter
* @param string $lang_code The language name will be for this language. Accepts a 2-letter code e.g. en
* @param string|bool $display_code The language name will display translated in this language. Accepts a 2-letter code e.g. de.
* If set to false it will return the translated name in the current language. Default is FALSE.
* @return string The language translated name
* @use \SitePress::api_hooks
function wpml_translated_language_name_filter( $empty_value, $lang_code, $display_code = false ) {
return $sitepress->get_display_language_name( $lang_code, $display_code );
* @deprecated 3.2 use 'wpml_current_language' filter instead.
function icl_get_current_language() {
return apply_filters( 'wpml_current_language', '' );
* Get the current language
* @deprecated Use apply_filters('wpml_current_language', '');
* Example: $my_current_lang = apply_filters('wpml_current_language', '');
function wpml_get_current_language_filter() {
return wpml_get_current_language();
* @deprecated 3.2 use 'wpml_default_language' filter instead
function icl_get_default_language() {
return $sitepress->get_default_language();
* Get the default language
* @param mixed $empty_value
* @see \wpml_get_active_languages_filter
* @use \SitePress::api_hooks
function wpml_get_default_language_filter( $empty_value) {
return wpml_get_default_language();
* Returns the default language
function wpml_get_default_language() {
return $sitepress->get_default_language();
function wpml_get_current_language() {
return apply_filters( 'wpml_current_language', '' );
function icl_tf_determine_mo_folder( $folder ) {
$mo_file_search = new WPML_MO_File_Search( $sitepress );
return $mo_file_search->determine_mo_folder( $folder );