示例#1
0
/**
 * 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();
    }
}
示例#2
0
/**
 * 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();
    }
}