: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->taxonomy_translation = new WPML_Taxonomy_Translation( '', array(), new WPML_UI_Screen_Options_Factory( $this ) );
if ( WPML_LANGUAGE_NEGOTIATION_TYPE_DOMAIN === (int) $this->get_setting( 'language_negotiation_type' )
&& $this->get_setting( 'language_per_domain_sso_enabled', false )
$sso = new WPML_Language_Per_Domain_SSO( $this, new WPML_PHP_Functions() );
* Sets the current language in \SitePress::$this_lang, redirects if
* frontend requests point to incomplete or incorrect urls, un-sets the
* $_GET['lang'] and $_GET['admin_bar'] values so that upload.php is able to
* enqueue 'media-grid' correctly without url parameters breaking its
public function maybe_set_this_lang() {
/** @var WPML_Request $wpml_request_handler */
global $wpml_request_handler, $pagenow, $wpml_language_resolution, $mode;
if ( ! defined( 'WP_ADMIN' ) && isset( $_SERVER['HTTP_HOST'] ) && did_action( 'init' ) ) {
require_once WPML_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-frontend-redirection.php';
/** @var WPML_Frontend_Request $wpml_request_handler */
$redirect_helper = _wpml_get_redirect_helper();
$redirection = new WPML_Frontend_Redirection(
$wpml_request_handler, $redirect_helper,
$wpml_language_resolution
$this->set_this_lang( $redirection->maybe_redirect() );
$this->set_this_lang( $wpml_request_handler->get_requested_lang() );
$wpml_request_handler->set_language_cookie( $this->this_lang );
if ( $pagenow === 'upload.php' && isset( $mode ) && 'grid' === $mode ) {
$_GET['admin_bar'] = null;
function load_dependencies() {
do_action( 'wpml_load_dependencies' );
* Sets up all term/taxonomy actions for use outside Translations Management or the Post Edit screen
function set_term_filters_and_hooks() {
// The delete filter only ensures the synchronizing of delete actions between translations of a term.
add_action( 'delete_term', array( $this, 'delete_term' ), 1, 3 );
add_action( 'set_object_terms', array( 'WPML_Terms_Translations', 'set_object_terms_action' ), 10, 6 );
add_action( 'created_term_translation', array( 'WPML_Terms_Translations', 'sync_ttid_action' ), 10, 3 );
// filters terms by language for the term/tag-box autoselect
if ( ( isset( $_GET['action'] ) && 'ajax-tag-search' === $_GET['action'] ) || ( isset( $_POST['action'] ) && 'get-tagcloud' === $_POST['action'] ) ) {
add_filter( 'get_terms', array( 'WPML_Terms_Translations', 'get_terms_filter' ), 10, 2 );
add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
add_action( 'create_term', array( $this, 'create_term' ), 1, 3 );
add_action( 'edit_term', array( $this, 'create_term' ), 1, 3 );
add_filter( 'get_terms_args', array( $this, 'get_terms_args_filter' ), 10, 2 );
add_filter( 'get_edit_term_link', array( $this, 'get_edit_term_link' ), 1, 4 );
add_action( 'deleted_term_relationships', array( $this, 'deleted_term_relationships' ), 10, 2 );
add_action( 'wp_ajax_icl_repair_broken_type_and_language_assignments', 'icl_repair_broken_type_and_language_assignments' );
// adjust queried categories and tags ids according to the language
if ( (bool) $this->get_setting( 'auto_adjust_ids' ) ) {
add_action( 'wp_list_pages_excludes', array( $this, 'adjust_wp_list_pages_excludes' ) );
if ( ! $this->get_wp_api()
->constant( 'DOING_AJAX' )
add_filter( 'get_term', array( $this, 'get_term_adjust_id' ), 1, 1 );
add_action( 'edited_term', array( $this, 'edited_term_action' ) );
add_filter( 'get_pages', array( $this, 'get_pages_adjust_ids' ), 1, 2 );
add_action( 'clean_term_cache', array( $this, 'clear_elements_cache' ), 10, 2 );
function remove_admin_language_switcher() {
remove_action( 'wp_before_admin_bar_render', array( $this, 'admin_language_switcher' ) );
function rebuild_language_information() {
$this->set_setting( 'just_reactivated', 0 );
/** @var TranslationManagement $iclTranslationManagement */
global $iclTranslationManagement;
if ( $iclTranslationManagement ) {
$iclTranslationManagement->add_missing_language_information();
$setup_complete = $this->get_setting( 'setup_complete' );
if ( ! $setup_complete ) {
$this->set_setting( 'setup_complete', false );
public function user_lang_by_authcookie() {
if ( ! isset( $current_user ) ) {
if ( function_exists( 'wp_parse_auth_cookie' ) ) {
$cookie_data = wp_parse_auth_cookie();
$username = isset( $cookie_data['username'] ) ? $cookie_data['username'] : null;
$user_obj = new WP_User( null, $username );
$user_obj = $current_user;
$user_id = isset( $user_obj->ID ) ? $user_obj->ID : 0;
$user_lang = $this->get_user_admin_language( $user_id );
$user_lang = $user_lang ? $user_lang : $this->get_current_language();
function get_current_user() {
return $current_user !== null ? $current_user : new WP_User();
require_once WPML_PLUGIN_PATH . '/ajax.php';
function check_if_admin_action_from_referer() {
$referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
return strpos( $referer, strtolower( admin_url() ) ) === 0;
* Check translation mangement column screen option.
* @param string $post_type Current post type.
public function show_management_column_content( $post_type ) {
$custom_columns = new WPML_Custom_Columns( $this );
return $custom_columns->show_management_column_content( $post_type );
function initialize_cache() {
require_once WPML_PLUGIN_PATH . '/inc/cache.php';
function get_translations_cache() {
if ( ! isset( $this->icl_translations_cache ) ) {
$this->icl_translations_cache = new icl_cache();
return $this->icl_translations_cache;
function get_language_name_cache() {
if ( ! $this->icl_language_name_cache ) {
$this->icl_language_name_cache = new icl_cache( 'language_name', true );
return $this->icl_language_name_cache;
public function set_admin_language( $admin_language = false ) {
$default_language = $this->get_default_language();
$this->admin_language = $admin_language ? $admin_language : $this->user_lang_by_authcookie();
$lang_codes = array_keys( $this->get_languages() );
if ( (bool) $this->admin_language === true && ! in_array( $this->admin_language, $lang_codes, true ) ) {
delete_user_meta( $this->get_current_user()->ID, 'icl_admin_language' );
if ( empty( $this->settings['admin_default_language'] ) || ! in_array(
$this->settings['admin_default_language'], array_merge( $lang_codes, array( '_default_' ) ), true
$this->settings['admin_default_language'] = '_default_';
if ( ! $this->admin_language ) {
$this->admin_language = $this->settings['admin_default_language'];
if ( $this->admin_language === '_default_' && $default_language ) {
$this->admin_language = $default_language;
function get_admin_language() {
$current_user = $this->get_current_user();
( ! empty( $current_user->ID ) && $this->get_wp_api()
'icl_admin_language_for_edit',
) && $this->is_post_edit_screen() )
|| $this->is_wpml_switch_language_triggered()
$admin_language = $this->get_current_language();
$admin_language = $this->user_lang_by_authcookie();
public function is_wpml_switch_language_triggered() {
return isset( $GLOBALS['icl_language_switched'] ) ? true : false;
function is_post_edit_screen() {
$action = isset( $_GET['action'] ) ? $_GET['action'] : '';
return $pagenow === 'post-new.php' || ( $pagenow === 'post.php' && ( 0 === strcmp( $action, 'edit' ) ) );
function get_user_admin_language_filter( $value, $user_id ) {
return $this->get_user_admin_language( $user_id );
function get_user_admin_language( $user_id, $reload = false ) {
$user_admin_language = new WPML_User_Admin_Language( $this );
return $user_admin_language->get( $user_id, $reload );
* @todo rename this method, has it has nothing to do with the menus
function administration_menu() {
if ( ! $this->is_setup_complete() ) {
$this->check_and_display_missing_records_notice();
private function check_and_display_missing_records_notice() {
if ( ! $this->is_troubleshooting_page() && ! SitePress_Setup::languages_table_is_complete() ) {
$troubleshooting_url = admin_url( 'admin.php?page=' . WPML_PLUGIN_FOLDER . '/menu/troubleshooting.php' );
$troubleshooting_link = '<a href="'
. __( 'Troubleshooting', 'sitepress' )
'WPML is missing some records in the languages tables and it cannot fully work until this issue is fixed.',
'Please go to the %1$s page and click on "%2$s" to fix this problem.',
'Clear language information and repopulate languages',
$message .= __( 'This warning will disappear once this issue is fixed.', 'sitepress' );
ICL_AdminNotifier::removeMessage( 'setup-incomplete' );
ICL_AdminNotifier::addMessage( 'setup-incomplete', $message, 'error', false, false, false, 'setup', true );
ICL_AdminNotifier::displayMessages( 'setup' );
function taxonomy_translation_page() {
$this->taxonomy_translation->render();
* @param int|string $blog_id
function init_settings( $blog_id ) {
$blog_id = (int) $blog_id;
if ( ! isset( $this->loaded_blog_id ) || $this->loaded_blog_id != $blog_id ) {
$this->loaded_blog_id = $blog_id;
$this->settings = get_option( 'icl_sitepress_settings' );
$default_lang_code = isset( $this->settings['default_language'] ) ? $this->settings['default_language'] : false;
load_wpml_url_converter( $this->settings, false, $default_lang_code );
* @param array|null $settings
function save_settings( $settings = null ) {
if ( null !== $settings ) {
foreach ( $settings as $k => $v ) {
foreach ( $v as $k2 => $v2 ) {
$this->settings[ $k ][ $k2 ] = $v2;
$this->settings[ $k ] = $v;
if ( ! empty( $this->settings ) ) {
update_option( 'icl_sitepress_settings', $this->settings );
do_action( 'icl_save_settings', $settings );
function get_settings() {
function filter_get_setting( $value, $key ) {
return $this->get_setting( $key, $value );
* @param mixed|bool $default
function get_setting( $key, $default = false ) {
return wpml_get_setting_filter( $default, $key );
function action_set_setting( $key, $value, $save_now ) {
$this->set_setting( $key, $value, $save_now );
* @param bool $save_now Immediately update the settings record in the DB
* @return bool Always True. If `$save_now === true`, it returns the result of `update_option`
function set_setting( $key, $value, $save_now = false ) {
return icl_set_setting( $key, $value, $save_now );
function get_user_preferences() {
if ( ! isset( $this->user_preferences ) || ! $this->user_preferences ) {
$this->user_preferences = get_user_meta( $this->get_current_user()->ID, '_icl_preferences', true );
if ( ( is_array( $this->user_preferences ) && $this->user_preferences == array( 0 => false ) ) || ! $this->user_preferences ) {
$this->user_preferences = array();
if ( ! is_array( $this->user_preferences ) ) {
$this->user_preferences = (array) $this->user_preferences;
return $this->user_preferences;
function set_user_preferences( $value ) {
$this->user_preferences = $value;
function save_user_preferences() {
update_user_meta( $this->get_current_user()->ID, '_icl_preferences', $this->user_preferences );
* @deprecated Use \SitePress::get_setting instead
public function get_option( $option_name ) {
return $this->get_setting( $option_name, null );
function verify_settings() {
$verify_settings = new WPML_Verify_SitePress_Settings( $this->get_wp_api() );
list( $this->settings, $update_settings ) = $verify_settings->verify( $this->settings );
if ( $update_settings ) {
* @param bool $major_first
* @param string $order_by
function get_active_languages( $refresh = false, $major_first = false, $order_by = 'english_name' ) {
/** @var WPML_Request $wpml_request_handler */
global $wpml_request_handler;
$in_language = defined( 'WP_ADMIN' ) && $this->admin_language ? $this->admin_language : null;
$in_language = $in_language === null ? $this->get_current_language() : $in_language;
$in_language = $in_language ? $in_language : $this->get_default_language();
$active_languages = $this->get_languages( $in_language, true, $refresh, $major_first, $order_by );
$active_languages = isset( $active_languages[ $in_language ] ) ? $active_languages : $this->get_languages( $in_language, true, true, $major_first, $order_by );
$active_languages = $active_languages ? $active_languages : array();
$this->active_languages = $wpml_request_handler->show_hidden() ? $active_languages : array_diff_key( $active_languages, array_fill_keys( $this->get_setting( 'hidden_languages', array() ), 1 ) );
return $this->active_languages;
* Returns an input array of languages, that are in the form of associative arrays,
* ordered by the user-chosen language order
* @param array[] $languages
function order_languages( $languages ) {
$ordered_languages = array();
if ( isset( $this->settings['languages_order'] ) && is_array( $this->settings['languages_order'] ) ) {
foreach ( $this->settings['languages_order'] as $code ) {
if ( isset( $languages[ $code ] ) ) {
$ordered_languages[ $code ] = $languages[ $code ];
unset( $languages[ $code ] );
$iclsettings['languages_order'] = array_keys( $languages );
$this->save_settings( $iclsettings );
if ( ! empty( $languages ) ) {
foreach ( $languages as $code => $lang ) {
$ordered_languages[ $code ] = $lang;
return $ordered_languages;
* Checks if a given language code belongs to a currently active language.
function is_active_language( $lang_code ) {
$active_languages = $this->get_active_languages();
foreach ( $active_languages as $lang ) {
if ( $lang_code == $lang['code'] ) {