/** * 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(); } }
function test_filter_paypal_args() { global $woocommerce_wpml, $sitepress, $sitepress_settings, $wpml_post_translations; $sitepress->switch_lang('de'); $wpml_url_converter = load_wpml_url_converter($sitepress_settings, 3, $sitepress->get_default_language()); $wpml_url_filters = new WPML_URL_Filters($wpml_post_translations, $wpml_url_converter, $sitepress); $_SERVER['SERVER_NAME'] = $sitepress->convert_url(get_home_url()); $args['notify_url'] = WC()->api_request_url('WC_Gateway_Paypal'); $filtered_args = $woocommerce_wpml->filter_paypal_args($args); $this->assertEquals($sitepress->convert_url(get_home_url()) . '&wc-api=WC_Gateway_Paypal', $filtered_args['notify_url']); }
/** * 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(); } }
function init_settings($blog_id) { global $sitepress_settings; if (isset($this->loaded_blog_id) && $this->loaded_blog_id != $blog_id) { remove_action('switch_blog', array($this, 'init_settings')); wp_cache_add($this->loaded_blog_id . 'icl_sitepress_settings', $sitepress_settings, 'sitepress_ms'); add_action('switch_blog', array($this, 'init_settings'), 10, 1); $sitepress_settings = wp_cache_get($blog_id . 'icl_sitepress_settings', 'sitepress_ms'); $sitepress_settings = (bool) $sitepress_settings === true ? $sitepress_settings : get_option('icl_sitepress_settings'); $default_lang_code = isset($sitepress_settings['default_language']) ? $sitepress_settings['default_language'] : false; load_wpml_url_converter($sitepress_settings, false, $default_lang_code); } $this->loaded_blog_id = $blog_id; return $sitepress_settings; }