/** * WPML_ST_Admin_Option constructor. * * @param SitePress $sitepress * @param WPML_String_Translation $st_instance * @param string $option_name * @param string $language */ public function __construct(&$sitepress, &$st_instance, $option_name, $language = '') { if (!$option_name || !is_scalar($option_name)) { throw new InvalidArgumentException('Not a valid option name, received: ' . serialize($option_name)); } parent::__construct($sitepress); $this->st_instance =& $st_instance; $this->option_name = $option_name; $this->language = $language ? $language : $this->st_instance->get_current_string_language($option_name); }
public function pre_update_option_settings_filter($old_value, $new_value) { // This is special handling for Blog Title and Tagline. global $switched; if (!$switched || $switched && wpml_get_setting_filter(false, 'setup_complete')) { $current_language = $this->st_instance->get_current_string_language($this->option_name); WPML_Config::load_config_run(); $result = $this->update_translation($this->option_name, $current_language, $new_value, ICL_TM_COMPLETE); if ($result) { return $old_value; } } return $new_value; }
function icl_st_translate_admin_string($option_value, $key = "", $name = "", $rec_level = 0) { $lang = $this->st_instance->get_current_string_language($name); $option_name = substr(current_filter(), 7); $name = $name === '' ? $option_name : $name; if (isset($this->icl_st_cache[$lang][$name])) { return $this->icl_st_cache[$lang][$name]; } $serialized = is_serialized($option_value); $option_value = $serialized ? unserialize($option_value) : $option_value; if (is_array($option_value) || is_object($option_value)) { foreach ($option_value as $k => &$value) { $value = $this->icl_st_translate_admin_string($value, $key . '[' . $name . ']', $k, $rec_level + 1); } } else { if ($this->is_admin_text($key, $name)) { $tr = icl_t('admin_texts_' . $option_name, $key . $name, $option_value, $hast, true); $option_value = $hast ? $tr : $option_value; } } $option_value = $serialized ? serialize($option_value) : $option_value; /* * if sticky links plugin is enabled and set to change links into sticky * in strings, change those links back into permalinks when displayed */ if (is_string($option_value) && $this->sticky_links_exist) { $option_value = apply_filters('wpml_sticky_link_string', $option_value); } if ($rec_level === 0) { $this->icl_st_cache[$lang][$name] = $option_value; } return $option_value; }
function icl_st_translate_admin_string($option_value, $key = "", $name = "", $rec_level = 0) { $lang = $this->st_instance->get_current_string_language($name); $option_name = substr(current_filter(), 7); $name = $name === '' ? $option_name : $name; if (isset($this->icl_st_cache[$lang][$name])) { return $this->icl_st_cache[$lang][$name]; } $serialized = is_serialized($option_value); $option_value = $serialized ? unserialize($option_value) : $option_value; if (is_array($option_value) || is_object($option_value)) { foreach ($option_value as $k => &$value) { $value = $this->icl_st_translate_admin_string($value, $key . '[' . $name . ']', $k, $rec_level + 1); } } else { if ($this->is_admin_text($key, $name)) { $tr = icl_t('admin_texts_' . $option_name, $key . $name, $option_value, $hast, true); $option_value = $hast ? $tr : $option_value; } } $option_value = $serialized ? serialize($option_value) : $option_value; if ($rec_level === 0) { $this->icl_st_cache[$lang][$name] = $option_value; } return $option_value; }
function icl_st_translate_admin_string($option_value, $key = "", $name = "", $rec_level = 0) { if (!defined('ICL_SITEPRESS_VERSION') || ICL_PLUGIN_INACTIVE) { return $option_value; } $lang = $this->st_instance->get_current_string_language($name); $option_name = substr(current_filter(), 7); $name = $name === '' ? $option_name : $name; if (isset($this->icl_st_cache[$lang][$name])) { return $this->icl_st_cache[$lang][$name]; } $serialized = is_serialized($option_value); $option_value = $serialized ? unserialize($option_value) : $option_value; if (is_array($option_value) || is_object($option_value)) { foreach ($option_value as $k => &$value) { $value = $this->icl_st_translate_admin_string($value, $key . '[' . $name . ']', $k, $rec_level + 1); } } else { if ($this->is_admin_text($key, $name)) { $tr = icl_t('admin_texts_' . $option_name, $key . $name, $option_value, $hast, true); $option_value = $hast ? $tr : $option_value; } } $option_value = $serialized ? serialize($option_value) : $option_value; /* * if sticky links plugin is enabled and set to change links into sticky * in strings, change those links back into permalinks when displayed */ if (is_string($option_value) and class_exists("WPML_Sticky_links")) { global $WPML_Sticky_Links; if (isset($WPML_Sticky_Links) && $WPML_Sticky_Links->settings['sticky_links_strings']) { $option_value = $WPML_Sticky_Links->show_permalinks($option_value); } } if ($rec_level === 0) { $this->icl_st_cache[$lang][$name] = $option_value; } return $option_value; }