reload(); $wpml_post_translations->reload(); if ( $key === false ) { delete_option( '_icl_cache' ); } else { $icl_cache = get_option( '_icl_cache' ); if ( is_array( $icl_cache ) ) { if ( isset( $icl_cache[ $key ] ) ) { unset( $icl_cache[ $key ] ); } if ( $key_as_prefix ) { $cache_keys = array_keys( $icl_cache ); foreach ( $cache_keys as $cache_key ) { if ( strpos( $cache_key, $key ) === 0 ) { unset( $icl_cache[ $key ] ); } } } // special cache of 'per language' - clear different statuses if ( false !== strpos( $key, '_per_language' ) ) { foreach ( $icl_cache as $k => $v ) { if ( false !== strpos( $k, $key . '#' ) ) { unset( $icl_cache[ $k ] ); } } } update_option( '_icl_cache', $icl_cache ); } } } do_action( 'wpml_cache_clear' ); } class icl_cache{ private $data; function __construct($name = "", $cache_to_option = false){ $this->data = array(); $this->name = $name; $this->cache_to_option = $cache_to_option; $this->cache_needs_saving = false; if ($cache_to_option) { $this->data = icl_cache_get($name.'_cache_class'); if ($this->data == false){ $this->data = array(); } add_action( 'shutdown', array( $this, 'save_cache_if_requred' ) ); } } function save_cache_if_requred( ) { if( $this->cache_needs_saving ) { icl_cache_set($this->name.'_cache_class', $this->data); $this->cache_needs_saving = false; } } function get($key) { if(ICL_DISABLE_CACHE){ return null; } return isset($this->data[$key]) ? $this->data[$key] : false; } function has_key($key){ if(ICL_DISABLE_CACHE){ return false; } return array_key_exists($key, (array)$this->data); } function set($key, $value) { if(ICL_DISABLE_CACHE){ return; } if ($this->cache_to_option) { $old_value = null; if ( isset ( $this->data[$key] ) ) { $old_value = $this->data[$key]; } if ( $old_value !== $value ) { $this->data[$key] = $value; $this->cache_needs_saving = true; } } else { $this->data[$key] = $value; } } function clear() { $this->data = array(); if ($this->cache_to_option) { icl_cache_clear($this->name.'_cache_class'); } } } function w3tc_translate_cache_key_filter( $key ) { global $sitepress; return $sitepress->get_current_language() . $key; }