/** * Loads global variables providing functionality that is used throughout the plugin. * * @global $wpml_language_resolution * @global $wpml_slug_filter * @global WPML_Term_Translation $wpml_term_translations */ function load_essential_globals() { global $wpml_language_resolution, $wpml_term_translations; $wpml_languages = array(); $settings = get_option('icl_sitepress_settings'); if ((bool) $settings === false) { icl_sitepress_activate(); } $active_language_codes = isset($settings['active_languages']) ? $settings['active_languages'] : array(); $active_language_codes = (bool) $active_language_codes === true ? $active_language_codes : wpml_reload_active_languages_setting(); $wpml_languages['active_languages'] = $active_language_codes; $default_lang_code = isset($settings['default_language']) ? $settings['default_language'] : false; $wpml_language_resolution = new WPML_Language_Resolution($active_language_codes, $default_lang_code); $admin = is_admin(); wpml_load_post_translation($admin, $settings, $active_language_codes, $default_lang_code); $wpml_term_translations = new WPML_Term_Translation(); $domain_validation = filter_input(INPUT_GET, '____icl_validate_domain') ? 1 : false; $domain_validation = filter_input(INPUT_GET, '____icl_validate_directory') ? 2 : $domain_validation; $url_converter = load_wpml_url_converter($settings, $domain_validation, $default_lang_code); if ($domain_validation) { echo wpml_validate_host($_SERVER['REQUEST_URI'], $url_converter, $domain_validation === 2); exit; } wpml_load_request_handler($admin, $active_language_codes, $default_lang_code); if ($admin) { wpml_load_admin_files(); } }
if (get_option('_wpml_inactive', false) && isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) { wpml_set_plugin_as_inactive(); return; } } if (!wp_next_scheduled('update_wpml_config_index')) { //Set cron job to update WPML config index file from CDN wp_schedule_event(time(), 'daily', 'update_wpml_config_index'); } /** @var WPML_Post_Translation $wpml_post_translations */ global $sitepress, $wpdb, $wpml_url_filters, $wpml_post_translations, $wpml_term_translations, $wpml_url_converter, $wpml_language_resolution, $wpml_slug_filter; $sitepress = new SitePress(); new WPML_Global_AJAX($sitepress); wpml_load_query_filter(icl_get_setting('setup_complete')); $wpml_url_filters = new WPML_URL_Filters($wpml_post_translations, $wpml_url_converter, $sitepress); wpml_load_request_handler(is_admin(), $wpml_language_resolution->get_active_language_codes(), $sitepress->get_default_language()); require ICL_PLUGIN_PATH . '/inc/url-handling/wpml-slug-filter.class.php'; $wpml_slug_filter = new WPML_Slug_Filter($wpdb, $sitepress, $wpml_post_translations); /** @var array $sitepress_settings */ $sitepress_settings = $sitepress->get_settings(); wpml_load_term_filters(); wpml_maybe_setup_post_edit(); require ICL_PLUGIN_PATH . '/modules/cache-plugins-integration/cache-plugins-integration.php'; require ICL_PLUGIN_PATH . '/inc/wp-login-filters.php'; require ICL_PLUGIN_PATH . '/inc/plugins-integration.php'; if (is_admin()) { activate_installer($sitepress); if ($sitepress->get_setting('setup_complete')) { setup_admin_menus(); } }