/** * 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(); } }
/** * 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, $wpdb; $wpml_languages = array(); $settings = get_option('icl_sitepress_settings'); if ((bool) $settings === false) { icl_sitepress_activate(); } else { if (isset($settings['setup_complete']) && $settings['setup_complete']) { $active_plugins = get_option('active_plugins'); $wpmu_sitewide_plugins = (array) maybe_unserialize(get_site_option('active_sitewide_plugins')); if (in_array(trailingslashit(ICL_PLUGIN_FOLDER) . 'sitepress.php', $active_plugins, true) === false && in_array(trailingslashit(ICL_PLUGIN_FOLDER) . 'sitepress.php', array_keys($wpmu_sitewide_plugins), true) === false) { // The plugin has just be reactivated. // reset ajx_health_flag // set the just_reactivated flag so any posts created while // WPML was not activate will get the default language // https://onthegosystems.myjetbrains.com/youtrack/issue/wpmlcore-1924 $settings['ajx_health_checked'] = 0; $settings['just_reactivated'] = 1; update_option('icl_sitepress_settings', $settings); } } } $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); $wpml_term_translations = new WPML_Term_Translation($wpdb); $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; } if ($admin) { wpml_load_admin_files(); } }
$default_accepted_language_codes = explode(',', $default_accepted_language); wp_send_json_success($default_accepted_language_codes); } $request = wpml_get_authenticated_action(); $iclsettings = $this->get_settings(); $default_language = $this->get_default_language(); switch ($request) { case 'set_active_languages': $resp = array(); $old_active_languages_count = count($this->get_active_languages()); $lang_codes = filter_input(INPUT_POST, 'langs', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE); $lang_codes = explode(',', $lang_codes); $setup_instance = wpml_get_setup_instance(); if ($setup_instance->set_active_languages($lang_codes)) { $resp[0] = 1; $iclsettings['active_languages'] = wpml_reload_active_languages_setting(); $active_langs = $this->get_active_languages(); $iclresponse = ''; $default_categories = $sitepress->get_setting('default_categories', array()); $default_category_main = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->terms} t\n JOIN {$wpdb->term_taxonomy} tx ON t.term_id=tx.term_id\n WHERE term_taxonomy_id = %d\n AND taxonomy='category'", $default_categories[$default_language])); $default_category_trid = $wpdb->get_var($wpdb->prepare("SELECT trid FROM {$wpdb->prefix}icl_translations\n WHERE element_id = %d\n AND element_type='tax_category'", $default_categories[$default_language])); foreach ($active_langs as $lang) { $is_default = $default_language == $lang['code']; $iclresponse .= '<li '; if ($is_default) { $iclresponse .= 'class="default_language"'; } $iclresponse .= '><label><input type="radio" name="default_language" value="' . $lang['code'] . '" '; if ($is_default) { $iclresponse .= 'checked="checked"'; }
private function updated_active_languages() { global $sitepress; wp_cache_init(); icl_cache_clear(); $this->refresh_active_lang_cache(wpml_get_setting_filter(false, 'default_language')); wpml_reload_active_languages_setting(true); $active_langs = $sitepress->get_active_languages(true); $this->maybe_move_setup(3); if (count($active_langs) > 1) { icl_set_setting('dont_show_help_admin_notice', true); } }
private function maybe_reload() { $this->default_lang = $this->default_lang ? $this->default_lang : wpml_get_setting_filter(false, 'default_language'); $this->active_language_codes = (bool) $this->active_language_codes === true ? $this->active_language_codes : array_fill_keys(wpml_reload_active_languages_setting(true), 1); }