: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class SitePress extends WPML_WPDB_User implements
const AFTER_ST_PLUGIN_LOADED_HOOK = - PHP_INT_MAX + 1;
/** @var WPML_Taxonomy_Translation */
private $taxonomy_translation;
private $template_real_path;
/** @var WPML_Post_Translation $post_translation */
private $post_translation;
/** @var WPML_Terms_Translations $term_translation */
private $term_translation;
/** @var WPML_Post_Duplication $post_duplication */
private $post_duplication;
/** @var WPML_Term_Actions $term_actions */
/** @var WPML_Admin_Scripts_Setup $scripts_handler */
private $scripts_handler;
/** @var WPML_Set_Language $language_setter */
private $language_setter;
/** @var WPML_Term_Query_Filter $term_query_filter */
private $term_query_filter;
/** @var array $settings */
private $active_languages = array();
private $_admin_notices = array();
private $user_preferences = array();
/** @var WPML_WP_API $wp_api */
/** @var WPML_Records $records */
/** @var @var int $loaded_blog_id */
* @var string $original_language caches the initial language when calling
* \SitePress::switch_lang() for the first time.
private $original_language;
* @var string $original_language_cookie caches the initial language value
* in the user's cookie when calling \SitePress::switch_lang() for the
private $original_language_cookie;
/** @var WPML_Locale $locale_utils */
public $footer_preview = false;
public $icl_translations_cache;
public $icl_language_name_cache;
public $icl_term_taxonomy_cache;
/** @var WPML_Term_Adjust_Id */
private $wpml_term_adjust_id = null;
* @var array $current_request_data - Use to store temporary information during the current request
private $current_request_data = array();
do_action( 'wpml_before_startup' );
/** @var array $sitepress_settings */
global $pagenow, $sitepress_settings, $wpdb, $wpml_post_translations, $locale, $wpml_term_translations;
$this->wpml_helper = new WPML_Helper( $wpdb );
parent::__construct( $wpdb );
$this->locale_utils = new WPML_Locale( $wpdb, $this, $locale );
$sitepress_settings = get_option( 'icl_sitepress_settings' );
$this->settings = &$sitepress_settings;
$this->post_translation = &$wpml_post_translations;
$this->term_translation = &$wpml_term_translations;
if ( is_admin() && ! $this->get_setting( 'icl_capabilities_verified' ) ) {
wpml_enable_capabilities();
if ( null === $pagenow && is_multisite() ) {
include WPML_PLUGIN_PATH . '/inc/hacks/vars-php-multisite.php';
$this->verify_settings();
if ( isset( $_GET['page'], $_GET['debug_action'] ) && WPML_PLUGIN_FOLDER . '/menu/troubleshooting.php' === $_GET['page'] ) {
if ( isset( $_REQUEST['icl_ajx_action'] ) ) {
* It is very common to register a CPT on admin_init, thus
* the init hook is too early in this case. This causes
* malformed post guid as well as empty post content
* when saving the post a second time. E.g.: Avada.
if ( 'make_duplicates' === $_REQUEST['icl_ajx_action'] ) {
add_action( 'admin_init', array( $this, 'ajax_setup' ), PHP_INT_MAX );
add_action( 'init', array( $this, 'ajax_setup' ), 15 );
if ( ! empty( $_POST ) ) {
add_action( 'init', array( $this, 'process_forms' ) );
$this->initialize_cache();
$flags_factory = new WPML_Flags_Factory( $wpdb );
$this->flags = $flags_factory->create();
add_action( 'plugins_loaded', array( $this, 'plugin_localization' ), self::AFTER_ST_PLUGIN_LOADED_HOOK );
add_action( 'plugins_loaded', array( $this, 'init' ), 1 );
add_action( 'wp_loaded', array( $this, 'maybe_set_this_lang' ) );
add_action( 'switch_blog', array( $this, 'init_settings' ), 10, 1 );
add_action( 'admin_menu', array( $this, 'administration_menu' ) );
if ( $this->get_setting( 'existing_content_language_verified' ) && ( $this->get_setting( 'setup_complete' ) || ( ! empty( $_GET['page'] ) && $this->get_setting( 'setup_wizard_step' ) > 1 && $_GET['page'] == WPML_PLUGIN_FOLDER . '/menu/languages.php' ) ) ) {
// Post/page language box
add_filter( 'comment_feed_join', array( $this, 'comment_feed_join' ) );
add_filter( 'comments_clauses', array( $this, 'comments_clauses' ), 10, 2 );
// Allow us to filter the Query vars before the posts query is being built and executed
add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
if ( $pagenow === 'edit.php' ) {
add_action( 'quick_edit_custom_box', array( 'WPML_Terms_Translations', 'quick_edit_terms_removal' ), 10, 2 );
add_filter( 'get_pages', array( $this, 'exclude_other_language_pages2' ), 10, 2 );
add_filter( 'wp_dropdown_pages', array( $this, 'wp_dropdown_pages' ) );
add_filter( 'get_comment_link', array( $this, 'get_comment_link_filter' ) );
$this->set_term_filters_and_hooks();
add_action( 'parse_query', array( $this, 'parse_query' ) );
// AJAX Actions for the post edit screen
add_action( 'wp_ajax_wpml_save_term', array( 'WPML_Post_Edit_Ajax', 'wpml_save_term_action' ) );
add_action( 'wp_ajax_wpml_switch_post_language', array( 'WPML_Post_Edit_Ajax', 'wpml_switch_post_language' ) );
add_action( 'wp_ajax_wpml_get_default_lang', array( 'WPML_Post_Edit_Ajax', 'wpml_get_default_lang' ) );
// AJAX Actions for the taxonomy translation screen
add_action( 'wp_ajax_wpml_get_terms_and_labels_for_taxonomy_table', array( 'WPML_Taxonomy_Translation_Table_Display', 'wpml_get_terms_and_labels_for_taxonomy_table' ) );
// Ajax Action for the updating of term names on the troubleshooting page
add_action( 'wp_ajax_wpml_update_term_names_troubleshoot', array( 'WPML_Troubleshooting_Terms_Menu', 'wpml_update_term_names_troubleshoot' ) );
add_action( 'wp_ajax_wpml_generate_term_slug', array( $this->get_term_actions_helper(), 'generate_unique_term_slug_ajax_handler' ) );
// short circuit get default category
add_filter( 'pre_option_default_category', array( $this, 'pre_option_default_category' ) );
add_filter( 'update_option_default_category', array( $this, 'update_option_default_category' ), 1, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'backend_js' ) );
add_action( 'wp_head', array( $this, 'rtl_fix' ) );
add_action( 'admin_print_styles', array( $this, 'rtl_fix' ) );
add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ) );
add_filter( 'feed_link', array( $this, 'feed_link' ) );
add_filter( 'post_comments_feed_link', array( $this, 'post_comments_feed_link' ) );
add_filter( 'trackback_url', array( $this, 'trackback_url' ) );
add_filter( 'user_trailingslashit', array( $this, 'user_trailingslashit' ), 1, 2 );
add_filter( 'pre_option_home', array( $this, 'pre_option_home' ) );
add_filter( 'attachment_link', array( $this, 'attachment_link_filter' ), 10, 2 );
// Filter custom type archive link (since WP 3.1)
add_filter( 'post_type_archive_link', array( $this, 'post_type_archive_link_filter' ), 10, 2 );
add_filter( 'author_link', array( $this, 'author_link' ) );
add_action( 'query_vars', array( $this, 'query_vars' ) );
add_filter( 'language_attributes', array( $this, 'language_attributes' ) );
add_filter( 'locale', array( $this, 'locale_filter' ), 10, 1 );
add_filter( 'pre_option_page_on_front', array( $this, 'pre_option_page_on_front' ) );
add_filter( 'pre_option_page_for_posts', array( $this, 'pre_option_page_for_posts' ) );
$sticky_posts_loader = new WPML_Sticky_Posts_Loader( $this );
$sticky_posts_loader->add_hooks();
add_filter( 'trashed_post', array( $this, 'fix_trashed_front_or_posts_page_settings' ) );
add_filter( 'delete_post', array( $this, 'fix_trashed_front_or_posts_page_settings' ) );
add_action( 'wp', array( $this, 'set_wp_query' ) );
add_action( 'personal_options_update', array( $this, 'save_user_options' ) );
add_action( 'edit_user_profile_update', array( $this, 'save_user_options' ) );
add_action( 'wp_head', array( $this, 'meta_generator_tag' ) );
if ( $this->is_setup_complete() ) {
$icl_nav_menu = new WPML_Nav_Menu( $this, $wpdb, $wpml_post_translations, $wpml_term_translations );
$icl_nav_menu->init_hooks();
add_action( 'wp_login', array( $this, 'reset_admin_language_cookie' ) );
$this->handle_head_hreflang();
* add extra debug information
add_filter( 'icl_get_extra_debug_info', array( $this, 'add_extra_debug_info' ) );
add_action( 'admin_enqueue_scripts', function () {
$this->backend_js( false );
} //end if the initial language is set - existing_content_language_verified
add_filter( 'core_version_check_locale', array( $this, 'wp_upgrade_locale' ) );
if ( $pagenow === 'post.php' && isset( $_REQUEST['action'], $_GET['post'] ) && $_REQUEST['action'] === 'edit' ) {
add_action( 'init', '_icl_trash_restore_prompt' );
add_action( 'init', array( $this, 'register_assets' ), 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'js_load' ), 2 ); // enqueue scripts - higher priority
add_action( 'wp_enqueue_scripts', array( $this, 'js_load' ), 2 ); // enqueue scripts - higher priority
add_filter( 'url_to_postid', array( $this, 'url_to_postid' ) );
// cron job to update WPML config index file from CDN
$xml_config_log_factory = new WPML_XML_Config_Log_Factory();
$log = $xml_config_log_factory->create_log();
if ( $this->is_setup_complete() ) {
$xml_config_log_notice = $xml_config_log_factory->create_notice();
$xml_config_log_notice->add_hooks();
$wpml_config_update_integrator = new WPML_Config_Update_Integrator( $log );
$wpml_config_update_integrator->add_hooks();
add_action( 'core_upgrade_preamble', array( $this, 'update_index_screen' ) );
add_filter( 'get_search_form', array( $this, 'get_search_form_filter' ) );
add_action( 'wpml_loaded', array( $this, 'load_dependencies' ), 10000 );
do_action( 'wpml_after_startup' );
public function api_hooks() {
* @deprecated in favour of lowercased namespaces
add_filter( 'WPML_get_setting', array( $this, 'filter_get_setting' ), 10, 2 );
* @deprecated in favour of lowercased namespaces
add_filter( 'WPML_get_current_language', array( $this, 'get_current_language' ), 10, 0 );
* @deprecated in favour of lowercased namespaces
add_filter( 'WPML_get_user_admin_language', array( $this, 'get_user_admin_language_filter' ), 10, 2 );
* @deprecated in favour of lowercased namespaces
add_filter( 'WPML_is_admin_action_from_referer', array( $this, 'check_if_admin_action_from_referer' ), 10, 0 );
* @deprecated in favour of lowercased namespaces
add_filter( 'WPML_current_user', array( $this, 'get_current_user' ), 10, 0 );
add_filter( 'wpml_get_setting', array( $this, 'filter_get_setting' ), 10, 2 );
add_action( 'wpml_set_setting', array( $this, 'action_set_setting' ), 10, 3 );
add_filter( 'wpml_get_language_cookie', array( $this, 'get_language_cookie' ), 10, 0 );
add_filter( 'wpml_current_language', array( $this, 'get_current_language' ), 10, 0 );
add_filter( 'wpml_get_user_admin_language', array( $this, 'get_user_admin_language_filter' ), 10, 2 );
add_filter( 'wpml_is_admin_action_from_referer', array( $this, 'check_if_admin_action_from_referer' ), 10, 0 );
add_filter( 'wpml_current_user', array( $this, 'get_current_user' ), 10, 0 );
add_filter( 'wpml_new_post_source_id', array( $this, 'get_new_post_source_id' ), 10, 1 );
* @use \SitePress::get_translatable_documents_filter
add_filter( 'wpml_translatable_documents', array( $this, 'get_translatable_documents_filter' ), 10, 2 );
add_filter( 'wpml_is_translated_post_type', array( $this, 'is_translated_post_type_filter' ), 10, 2 );
add_filter( 'wpml_is_display_as_translated_post_type', array( $this, 'is_display_as_translated_post_type_filter' ), 10, 2 );
add_filter( 'wpml_is_translated_taxonomy', array( $this, 'is_translated_taxonomy_filter' ), 10, 2 );
* @deprecated it has a wrong hook tag
add_filter( 'wpml_get_element_translations_filter', array( $this, 'get_element_translations_filter' ), 10, 6 );
* @deprecated it has a wrong hook tag
add_filter( 'wpml_get_element_translations', array( $this, 'get_element_translations_filter' ), 10, 6 );
add_filter( 'wpml_is_original_content', array( $this, 'is_original_content_filter' ), 10, 3 );
add_filter( 'wpml_original_element_id', array( $this, 'get_original_element_id_filter' ), 10, 3 );
add_filter( 'wpml_element_trid', array( $this, 'get_element_trid_filter' ), 10, 3 );
add_filter( 'wpml_is_rtl', array( $this, 'is_rtl' ) );
add_filter( 'wpml_home_url', 'wpml_get_home_url_filter', 10 );
add_filter( 'wpml_active_languages', 'wpml_get_active_languages_filter', 10, 2 );
add_filter( 'wpml_display_language_names', 'wpml_display_language_names_filter', 10, 5 );
add_filter( 'wpml_display_single_language_name', array( $this, 'get_display_single_language_name_filter' ), 10, 2 );
add_filter( 'wpml_element_link', 'wpml_link_to_element_filter', 10, 7 );
add_filter( 'wpml_object_id', 'wpml_object_id_filter', 10, 4 );
add_filter( 'wpml_translated_language_name', 'wpml_translated_language_name_filter', 10, 3 );
add_filter( 'wpml_default_language', 'wpml_get_default_language_filter', 10, 1 );
add_filter( 'wpml_post_language_details', 'wpml_get_language_information', 10, 2 );
add_action( 'wpml_add_language_form_field', 'wpml_add_language_form_field_action' );
add_shortcode( 'wpml_language_form_field', 'wpml_language_form_field_shortcode' );
add_filter( 'wpml_element_translation_type', 'wpml_get_element_translation_type_filter', 10, 3 );
add_filter( 'wpml_element_has_translations', 'wpml_element_has_translations_filter', 10, 3 );
add_filter( 'wpml_content_translations', 'wpml_get_content_translations_filter', 10, 3 );
add_filter( 'wpml_master_post_from_duplicate', 'wpml_get_master_post_from_duplicate_filter' );
add_filter( 'wpml_post_duplicates', 'wpml_get_post_duplicates_filter' );
add_filter( 'wpml_element_type', 'wpml_element_type_filter' );
add_filter( 'wpml_setting', 'wpml_get_setting_filter', 10, 3 );
add_filter( 'wpml_sub_setting', 'wpml_get_sub_setting_filter', 10, 4 );
add_filter( 'wpml_language_is_active', 'wpml_language_is_active_filter', 10, 2 );
add_action( 'wpml_admin_make_post_duplicates', 'wpml_admin_make_post_duplicates_action', 10, 1 );
* @deprecated This actions will be removed in future releases.
add_action( 'wpml_make_post_duplicates', 'wpml_make_post_duplicates_action', 10, 1 );
add_filter( 'wpml_element_language_details', 'wpml_element_language_details_filter', 10, 2 );
add_action( 'wpml_set_element_language_details', array( $this, 'set_element_language_details_action' ), 10, 1 );
add_filter( 'wpml_element_language_code', 'wpml_element_language_code_filter', 10, 2 );
add_filter( 'wpml_elements_without_translations', 'wpml_elements_without_translations_filter', 10, 2 );
add_action( 'wpml_switch_language', 'wpml_switch_language_action', 10, 1 );
do_action( 'wpml_before_init' );
$this->locale_utils->init();
$this->maybe_set_this_lang();
if ( function_exists( 'w3tc_add_action' ) ) {
w3tc_add_action( 'w3tc_object_cache_key', 'w3tc_translate_cache_key_filter' );
$this->get_user_preferences();
$this->set_admin_language();
// Run only if existing content language has been verified, and is front-end or settings are not corrupted
if ( $this->get_setting( 'existing_content_language_verified' ) ) {
'wpml_verify_post_translations', array(
'verify_post_translations_action',
if ( 2 === (int) $this->get_setting( 'language_negotiation_type' ) ) {
add_filter( 'allowed_redirect_hosts', array( $this, 'allowed_redirect_hosts' ) );
$this->move_current_language_to_the_top();
add_filter( 'mod_rewrite_rules', array( $this, 'rewrite_rules_filter' ), 10, 1 );
is_admin() && $this->get_setting( 'setup_complete' )
->is_translation_queue_page() && ! $this->get_wp_api()
->is_string_translation_page()
// Admin language switcher goes to the WP admin bar
if ( apply_filters( 'wpml_show_admin_language_switcher', true ) ) {
add_action( 'wp_before_admin_bar_render', array( $this, 'admin_language_switcher' ) );
$this->set_this_lang( 'all' );
$GLOBALS['text_direction'] = 'rtl';
if ( ! wpml_is_ajax() && is_admin() && ! $this->get_setting( 'dont_show_help_admin_notice' ) ) {
WPML_Troubleshooting_Terms_Menu::display_terms_with_suffix_admin_notice();
if ( ! $this->get_setting( 'setup_wizard_step' )
&& strpos( filter_input( INPUT_GET, 'page', FILTER_SANITIZE_URL ), 'menu/languages.php' ) === false
&& current_user_can( 'manage_options' )
add_action( 'admin_notices', array( $this, 'help_admin_notice' ) );
$short_v = implode( '.', array_slice( explode( '.', ICL_SITEPRESS_VERSION ), 0, 3 ) );
if ( is_admin() && ( ! isset( $this->settings['hide_upgrade_notice'] ) || $this->get_setting( 'hide_upgrade_notice' ) !== $short_v ) ) {
add_action( 'admin_notices', array( $this, 'upgrade_notice' ) );
require_once WPML_PLUGIN_PATH . '/inc/template-constants.php';
if ( defined( 'WPML_LOAD_API_SUPPORT' ) ) {
require_once WPML_PLUGIN_PATH . '/inc/wpml-api.php';
add_action( 'wp_footer', array( $this, 'display_wpml_footer' ), 20 );
if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
add_action( 'xmlrpc_call', array( $this, 'xmlrpc_call_actions' ) );
add_filter( 'xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
// set language to default and remove language switcher when in Taxonomy Translation page
// If the page uses AJAX and the language must be forced to default, please use the
// if ( $pagenow == 'admin-ajax.php' )above
&& ( $this->is_taxonomy_related_page()
|| $this->is_saving_taxonomy_labels() )
$this->switch_to_admin_language();
add_action( 'init', array( $this, 'remove_admin_language_switcher' ) );
Posts and new inline created terms, can only be saved in an active language.
* Also the content of the post-new.php should always be filtered for one specific
* active language, so to display the correct taxonomy terms for selection.
if ( $pagenow === 'post-new.php' ) {
if ( ! $this->is_active_language( $this->get_current_language() ) ) {
$this->switch_to_admin_language();
// Code to run when reactivating the plugin
$recently_activated = $this->get_setting( 'just_reactivated' );
if ( $recently_activated ) {
add_action( 'init', array( $this, 'rebuild_language_information' ), 1000 );
$mo_file_search = new WPML_MO_File_Search( $this );
add_action( 'after_switch_theme', array( $mo_file_search, 'reload_theme_dirs' ) );
do_action( 'wpml_after_init' );
do_action( 'wpml_loaded', $this );
if ( isset( $_GET['page'] )
&& WPML_PLUGIN_FOLDER . '/menu/taxonomy-translation.php' === $_GET['page']