PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/sitepress-multilingual-cms/inc/cache.php

https://bitbucket.org/acipriani/madeinapulia.com
PHP | 679 lines | 119 code | 27 blank | 533 comment | 26 complexity | fa2e90c3aede35b9e19d7a423dd8c7ee MD5 | raw file
Possible License(s): GPL-3.0, MIT, BSD-3-Clause, LGPL-2.1, GPL-2.0, Apache-2.0
  1. <?php
  2. define('ICL_DISABLE_CACHE', false);
  3. if ( !defined( 'ICL_CACHE_TRANSLATIONS' ) ) {
  4. /**
  5. * Constant used for narrowing the cache scope to translations
  6. *
  7. * @name ICL_TRANSIENT_EXPIRATION
  8. * @param string='translations'
  9. */
  10. define( 'ICL_CACHE_TRANSLATIONS', 'translations' );
  11. }
  12. $icl_cache_scopes[ ] = ICL_CACHE_TRANSLATIONS;
  13. if ( !defined( 'ICL_CACHE_LOCALE' ) ) {
  14. /**
  15. * Constant used for narrowing the cache scope to locales
  16. *
  17. * @name ICL_CACHE_LOCALE
  18. * @param string='locale'
  19. */
  20. define( 'ICL_CACHE_LOCALE', 'locale' );
  21. }
  22. $icl_cache_scopes[ ] = ICL_CACHE_LOCALE;
  23. if ( !defined( 'ICL_CACHE_FLAGS' ) ) {
  24. /**
  25. * Constant used for narrowing the cache scope to flags
  26. *
  27. * @name ICL_CACHE_FLAGS
  28. * @param string='flags'
  29. */
  30. define( 'ICL_CACHE_FLAGS', 'flags' );
  31. }
  32. $icl_cache_scopes[ ] = ICL_CACHE_FLAGS;
  33. if ( !defined( 'ICL_CACHE_LANGUAGE_NAME' ) ) {
  34. /**
  35. * Constant used for narrowing the cache scope to language names
  36. *
  37. * @name ICL_CACHE_LANGUAGE_NAME
  38. * @param string='language_name'
  39. */
  40. define( 'ICL_CACHE_LANGUAGE_NAME', 'language_name' );
  41. }
  42. $icl_cache_scopes[ ] = ICL_CACHE_LANGUAGE_NAME;
  43. if ( !defined( 'ICL_CACHE_TERM_TAXONOMY' ) ) {
  44. /**
  45. * Constant used for narrowing the cache scope to term taxonomies
  46. *
  47. * @name ICL_CACHE_TERM_TAXONOMY
  48. * @param string='term_taxonomy'
  49. */
  50. define( 'ICL_CACHE_TERM_TAXONOMY', 'term_taxonomy' );
  51. }
  52. $icl_cache_scopes[ ] = ICL_CACHE_TERM_TAXONOMY;
  53. if ( !defined( 'ICL_CACHE_COMMENT_COUNT' ) ) {
  54. /**
  55. * Constant used for narrowing the cache scope to comments count
  56. *
  57. * @name ICL_CACHE_COMMENT_COUNT
  58. * @param string='comment_count'
  59. */
  60. define( 'ICL_CACHE_COMMENT_COUNT', 'comment_count' );
  61. }
  62. $icl_cache_scopes[ ] = ICL_CACHE_COMMENT_COUNT;
  63. function icl_cache_get($key){
  64. $icl_cache = get_option('_icl_cache');
  65. if(isset($icl_cache[$key])){
  66. return $icl_cache[$key];
  67. }else{
  68. return false;
  69. }
  70. }
  71. function icl_cache_set($key, $value=null){
  72. global $switched;
  73. if(!empty($switched)) return;
  74. $icl_cache = get_option('_icl_cache');
  75. if(false === $icl_cache){
  76. delete_option('_icl_cache');
  77. }
  78. if(!is_null($value)){
  79. $icl_cache[$key] = $value;
  80. }else{
  81. if(isset($icl_cache[$key])){
  82. unset($icl_cache[$key]);
  83. }
  84. }
  85. update_option('_icl_cache', $icl_cache);
  86. }
  87. function icl_cache_clear($key = false, $key_as_prefix = false){
  88. if($key === false){
  89. delete_option('_icl_cache');
  90. }else{
  91. $icl_cache = get_option('_icl_cache');
  92. if(is_array($icl_cache)) {
  93. if(isset($icl_cache[$key])){
  94. unset($icl_cache[$key]);
  95. }
  96. if($key_as_prefix) {
  97. $cache_keys = array_keys($icl_cache);
  98. foreach($cache_keys as $cache_key) {
  99. if(strpos($cache_key, $key)===0) {
  100. unset($icl_cache[$key]);
  101. }
  102. }
  103. }
  104. // special cache of 'per language' - clear different statuses
  105. if(false !== strpos($key, '_per_language')){
  106. foreach($icl_cache as $k => $v){
  107. if(false !== strpos($k, $key . '#')){
  108. unset($icl_cache[$k]);
  109. }
  110. }
  111. }
  112. update_option('_icl_cache', $icl_cache);
  113. }
  114. }
  115. }
  116. //function get_arg_value( $args, $key, $string = false ) {
  117. // if ( is_array( $args[ $key ] ) ) {
  118. // $where = ' AND ' . $key .' ' . $args[ $key ][ 'op' ] . ' ' . ($string ? '%s' : '%d');
  119. // $query_arg = $args[ $key ][ 'value' ];
  120. // } else {
  121. // $where = ' AND ' . $key . ' = ' . ($string ? '%s' : '%d');
  122. // $query_arg = $args[ $key ];
  123. // }
  124. //
  125. // return array( $where, $query_arg );
  126. //}
  127. //
  128. //function handle_element_type($element_type) {
  129. // return in_array($element_type, array('post_post'));
  130. //}
  131. //
  132. //function icl_cache_get_translation() {
  133. // global $wp_query;
  134. // if(!isset($wp_query) || !isset($wp_query->query_vars_hash)) return false;
  135. // $cache_key = $wp_query->query_vars_hash;
  136. // $cache_group = 'wp_query:posts_translations';
  137. // return wp_cache_get( $cache_key, $cache_group );
  138. //}
  139. //
  140. //function icl_cache_set_translation($cached_posts_translations) {
  141. // global $wp_query;
  142. // if(!isset($wp_query) || !isset($wp_query->query_vars_hash)) return false;
  143. // $cache_key = $wp_query->query_vars_hash;
  144. // $cache_group = 'wp_query:posts_translations';
  145. // //Remove duplicates
  146. // $cached_posts_translations = array_map("unserialize", array_unique(array_map("serialize", $cached_posts_translations)));
  147. // wp_cache_set( $cache_key, $cached_posts_translations, $cache_group );
  148. //
  149. // $global_cache_key = 'global';
  150. // $global_cache_group = 'wp_query:posts_translations';
  151. // $global_cached_posts_translations = wp_cache_get( $cache_key, $cache_group );
  152. //
  153. // if(!$global_cached_posts_translations) {
  154. // $global_cached_posts_translations = $cached_posts_translations;
  155. // } else {
  156. // foreach($cached_posts_translations as $cached_posts_translation) {
  157. // $add = true;
  158. // foreach($global_cached_posts_translations as $global_cached_posts_translation) {
  159. // if($global_cached_posts_translation->translation_id == $cached_posts_translation->translation_id) {
  160. // $add = false;
  161. // break;
  162. // }
  163. // }
  164. // if($add) {
  165. // $global_cached_posts_translations[] = $cached_posts_translation;
  166. // }
  167. // }
  168. // }
  169. // //Remove duplicates
  170. // $global_cached_posts_translations = array_map("unserialize", array_unique(array_map("serialize", $global_cached_posts_translations)));
  171. //
  172. // wp_cache_set( $global_cache_key, $global_cached_posts_translations, $global_cache_group );
  173. //}
  174. //
  175. ///**
  176. // * @param int|array $source
  177. // * @param string|bool $post_type
  178. // *
  179. // * @return array
  180. // */
  181. //function icl_cache_adjust_post_id_from_cache($source, $post_type = false) {
  182. // if(!handle_element_type('post_' . $post_type)) return array();
  183. //
  184. // global $sitepress;
  185. // $current_language = $sitepress->get_current_language();
  186. //
  187. // if(!is_array($source)) {
  188. // $source = array($source);
  189. // }
  190. //
  191. // $results = array();
  192. // foreach($source as $id) {
  193. // if(is_numeric($id)) {
  194. // $element_type = $post_type;
  195. // if(!$element_type) {
  196. // $element_type = get_post_type($id);
  197. // }
  198. // $element_type = "post_" . $element_type;
  199. //
  200. // $trid = icl_cache_get_element_trid($id, $element_type);
  201. // if($trid){
  202. // $translations = icl_cache_get_translated_elements_from_cache($trid, $element_type);
  203. // if($translations && isset($translations[$current_language])) {
  204. // $results[$id] = $translations[$current_language]->element_id;
  205. // } else {
  206. // break;
  207. // }
  208. // }
  209. // }
  210. // }
  211. // if(count($results)!=count($source)) {
  212. // $diff = array();
  213. // if(!$results) {
  214. // $diff = $source;
  215. // } else {
  216. // foreach($source as $id) {
  217. // if(!isset($results[$id])) {
  218. // $diff[] = $results[$id];
  219. // }
  220. // }
  221. // }
  222. //
  223. // $cache = icl_cache_get_translation();
  224. // foreach($diff as $id) {
  225. // $t_args = array(
  226. // 'fields' => '*',
  227. // 'trid' => false,
  228. // 'element_id' => $id,
  229. // 'element_type' => 'post_' . $post_type,
  230. // 'language_code' => false,
  231. // 'source_language' => false,
  232. // 'result_type' => 'results',
  233. // 'use_cache' => true,
  234. // );
  235. // $translations = icl_cache_get_translation_element($t_args);
  236. // $trid = false;
  237. // if ( !empty( $translations ) ) {
  238. // foreach($translations as $translation) {
  239. // if($translation->element_id == $id) {
  240. // $trid = $translation->trid;
  241. // break;
  242. // }
  243. // }
  244. // foreach($translations as $translation) {
  245. // if($translation->trid == $trid && $translation->language_code == $current_language) {
  246. // $results[] = $translation->element_id;
  247. // break;
  248. // }
  249. // }
  250. // } else {
  251. // $trid = $sitepress->get_element_trid($id,'post_' . $post_type);
  252. // $translations = $sitepress->get_element_translations($trid,'post_' . $post_type,true);
  253. // foreach($translations as $lang_code => $translation) {
  254. // if($lang_code == $current_language) {
  255. // $results[] = $translation->element_id;
  256. // break;
  257. // }
  258. // }
  259. // }
  260. // $cache = array_merge($cache, $results);
  261. // //Remove duplicates
  262. // $cache = array_map("unserialize", array_unique(array_map("serialize", $cache)));
  263. // }
  264. // }
  265. //
  266. // if(count($results)==count($source)) {
  267. // return array_values($results);
  268. // } else {
  269. // return false;
  270. // }
  271. //}
  272. //
  273. //function icl_cache_get_element_trid($element_id, $element_type) {
  274. // if(!handle_element_type($element_type)) return false;
  275. //
  276. // global $wpdb;
  277. // $t_args = array(
  278. // 'fields' => 'trid',
  279. // 'trid' => false,
  280. // 'element_id' => $element_id,
  281. // 'element_type' => $element_type,
  282. // 'language_code' => false,
  283. // 'source_language' => false,
  284. // 'result_type' => 'var',
  285. // 'use_cache' => true,
  286. // );
  287. // $trid = icl_cache_get_translation_element($t_args);
  288. // if(!$trid && $element_id) {
  289. // $trid = $wpdb->get_var( "SELECT trid FROM {$wpdb->prefix}icl_translations WHERE element_id={$element_id} AND element_type = '{$element_type}'" );
  290. // }
  291. //
  292. // return $trid;
  293. //}
  294. //
  295. //function icl_cache_get_translated_elements_from_post_type($post_type) {
  296. // if(!handle_element_type('post_' . $post_type)) return array();
  297. //
  298. // $t_args = array(
  299. // 'fields' => '*',
  300. // 'trid' => false,
  301. // 'element_id' => false,
  302. // 'element_type' => 'post_' . $post_type,
  303. // 'language_code' => false,
  304. // 'source_language' => false,
  305. // 'result_type' => 'results',
  306. // 'use_cache' => true,
  307. // );
  308. // $results = icl_cache_get_translation_element($t_args);
  309. // if ( !$results ) {
  310. // global $wpdb;
  311. // $prepared_translations_sql = "SELECT * FROM {$wpdb->prefix}icl_translations WHERE element_type = %s";
  312. // $prepared_translations = $wpdb->prepare( $prepared_translations_sql, array( 'post_' . $post_type ) );
  313. // $translations_results = $wpdb->get_results( $prepared_translations );
  314. //
  315. // $t_args['element_type'] = false;
  316. //
  317. // if($translations_results) {
  318. // icl_cache_set_translation($translations_results);
  319. // }
  320. // $results = icl_cache_get_translation_element($t_args);
  321. // }
  322. // return $results;
  323. //}
  324. //
  325. //function icl_cache_get_translated_elements_from_cache($trid, $element_type) {
  326. // if(!handle_element_type($element_type)) return false;
  327. //
  328. // $t_args = array(
  329. // 'fields' => '*',
  330. // 'trid' => $trid,
  331. // 'element_id' => false,
  332. // 'element_type' => $element_type,
  333. // 'language_code' => false,
  334. // 'source_language' => false,
  335. // 'result_type' => 'results',
  336. // 'use_cache' => true,
  337. // );
  338. // $temp_translations = icl_cache_get_translation_element($t_args);
  339. //
  340. // if($temp_translations) {
  341. //
  342. // $translations = array();
  343. // foreach($temp_translations as $temp_translation) {
  344. // $row = new stdClass();
  345. // $row->translation_id = $temp_translation->translation_id;
  346. // $row->language_code = $temp_translation->language_code;
  347. // $row->element_id = $temp_translation->element_id;
  348. // $row->original = ($temp_translation->source_language_code == NULL) ? false : $temp_translation->source_language_code;
  349. // $translations[ $temp_translation->language_code ] = $row;
  350. // }
  351. // return $translations;
  352. // }
  353. // return false;
  354. //}
  355. //
  356. //function icl_cache_get_element_language_code($element_id, $element_type) {
  357. // global $wpdb;
  358. // $t_args = array(
  359. // 'fields' => 'language_code',
  360. // 'trid' => false,
  361. // 'element_id' => $element_id,
  362. // 'element_type' => $element_type,
  363. // 'language_code' => false,
  364. // 'source_language' => false,
  365. // 'result_type' => 'var',
  366. // 'use_cache' => true,
  367. // );
  368. // $this_lang = icl_cache_get_translation_element($t_args);
  369. // if(!$this_lang) {
  370. // $language_code_prepared = $wpdb->prepare( "SELECT language_code FROM {$wpdb->prefix}icl_translations WHERE element_type=%s AND element_id=%d", array('post_' . $element_type, $_GET[ 'p' ]) );
  371. // $this_lang = $wpdb->get_var( $language_code_prepared );
  372. // }
  373. //
  374. // return $this_lang;
  375. //}
  376. //
  377. //function icl_cache_find_by_page_name($page_name) {
  378. // $current_language = $this->get_current_language();
  379. //
  380. // $pid = false;
  381. //
  382. // $t_args = array(
  383. // 'fields' => '*',
  384. // 'trid' => false,
  385. // 'element_id' => false,
  386. // 'element_type' => 'post_page',
  387. // 'language_code' => $current_language,
  388. // 'source_language' => false,
  389. // 'result_type' => 'results',
  390. // 'use_cache' => true,
  391. // );
  392. // $results = icl_cache_get_translation_element($t_args);
  393. //
  394. // if($results) {
  395. // foreach($results as $result) {
  396. // if(isset($result->post)) {
  397. // /** @var $post WP_Post */
  398. // $post = $result->post;
  399. // if($post->post_name == $page_name) {
  400. // return $post->ID;
  401. // }
  402. // }
  403. // }
  404. // }
  405. //
  406. // if($pid) {
  407. // global $wpdb;
  408. // $pid_prepared = $wpdb->prepare( "
  409. // SELECT ID
  410. // FROM $wpdb->posts p
  411. // JOIN {$wpdb->prefix}icl_translations t
  412. // ON p.ID = t.element_id AND element_type='post_page'
  413. // WHERE p.post_name=%s AND t.language_code = %s
  414. // ", $page_name, $current_language );
  415. // $pid = $wpdb->get_var( $pid_prepared );
  416. // }
  417. // return $pid;
  418. //}
  419. //
  420. //function icl_cache_get_post_type( $post_id ) {
  421. // $t_args = array(
  422. // 'fields' => '*',
  423. // 'trid' => false,
  424. // 'element_id' => $post_id,
  425. // 'element_type' => false,
  426. // 'language_code' => false,
  427. // 'source_language' => false,
  428. // 'result_type' => 'row',
  429. // 'use_cache' => true,
  430. // );
  431. // $row = icl_cache_get_translation_element($t_args);
  432. //
  433. // $post_type = false;
  434. // if($row && isset($row->post)) {
  435. // $post_type = $row->post->post_type;
  436. // }
  437. // if(!$post_type) {
  438. // $post_type = get_post_type($post_id);
  439. // }
  440. // return $post_type;
  441. //}
  442. //
  443. ///**
  444. // * Queries the icl_translations table based on give arguments
  445. // * $args: array(
  446. // * 'field' => false|string, //Field name or comma separated value
  447. // * 'trid' => false|int, //Field value, array or false (*)
  448. // * 'element_id' => false|int, //Field value, array or false (*)
  449. // * 'element_type' => false|string, //Field value, array or false (*)
  450. // * 'language_code' => false|string, //Field value, array or false (*)
  451. // * 'source_language' => false|string, //Field value, array or false (*)
  452. // * 'result_type' => 'results'|'col'|'row'|'var', //Result type
  453. // * 'use_cache' => bool, //Return value from data cached for current $wp_query (if available)
  454. // * );
  455. // *
  456. // * (*) if array, use this format:
  457. // * array(
  458. // * 'op' => '=', // or any allowed operation
  459. // * 'value' => '', // a value to filter (or %something% if using 'LIKE' as operator
  460. // * )
  461. // *
  462. // * @param $args
  463. // *
  464. // * @param bool $use_global_cache_fallback
  465. // *
  466. // * @return array|bool|mixed|null|string
  467. // */
  468. //function icl_cache_get_translation_element($args, $use_global_cache_fallback = false ) {
  469. // if ( !$args || count( $args ) == 0 ) {
  470. // return false;
  471. // }
  472. //
  473. // global $wpdb;
  474. //
  475. // $defaults = array(
  476. // 'fields' => false,
  477. // 'trid' => false,
  478. // 'element_id' => false,
  479. // 'element_type' => false,
  480. // 'language_code' => false,
  481. // 'source_language' => false,
  482. // 'result_type' => 'results',
  483. // 'use_cache' => true,
  484. // );
  485. //
  486. // $args = array_merge( $defaults, $args );
  487. //
  488. // if ( !$args[ 'fields' ] ) {
  489. // return false;
  490. // }
  491. //
  492. // $where = "";
  493. // $query_args = array();
  494. // if ( $args[ 'trid' ] ) {
  495. // $key = 'trid';
  496. // $arg_value = get_arg_value( $args, $key );
  497. // $where .= $arg_value[ 0 ];
  498. // $query_args[ $key ] = $arg_value[ 1 ];
  499. // }
  500. // if ( $args[ 'element_id' ] ) {
  501. // $key = 'element_id';
  502. // $arg_value = get_arg_value( $args, $key );
  503. // $where .= $arg_value[ 0 ];
  504. // $query_args[ $key ] = $arg_value[ 1 ];
  505. // }
  506. // if ( $args[ 'element_type' ] ) {
  507. // $key = 'element_type';
  508. // $arg_value = get_arg_value( $args, $key, true );
  509. // $where .= $arg_value[ 0 ];
  510. // $query_args[ $key ] = $arg_value[ 1 ];
  511. // }
  512. // if ( $args[ 'language_code' ] ) {
  513. // $key = 'language_code';
  514. // $arg_value = get_arg_value( $args, $key, true );
  515. // $where .= $arg_value[ 0 ];
  516. // $query_args[ $key ] = $arg_value[ 1 ];
  517. // }
  518. // if ( $args[ 'source_language' ] ) {
  519. // $key = 'source_language';
  520. // $arg_value = get_arg_value( $args, $key, true );
  521. // $where .= $arg_value[ 0 ];
  522. // $query_args[ $key ] = $arg_value[ 1 ];
  523. // }
  524. //
  525. // if ( $where ) {
  526. // /** @var $cached_posts_translations array() */
  527. // $cached_posts_translations = false;
  528. // if ( $args[ 'use_cache' ] ) {
  529. // if($use_global_cache_fallback) {
  530. // $cached_posts_translations = icl_cache_get_translation(true);
  531. // } else {
  532. // $cached_posts_translations = icl_cache_get_translation();
  533. // }
  534. // }
  535. // if ( !$cached_posts_translations ) {
  536. // if(!$use_global_cache_fallback) {
  537. // return icl_cache_get_translation_element($args, true );
  538. // } else {
  539. // $where = 'WHERE 1=1 ' . $where;
  540. // $prepared_query = $wpdb->prepare( "SELECT " . $args[ 'fields' ] . " FROM {$wpdb->prefix}icl_translations " . $where, array_values( $query_args ) );
  541. // switch ( $args[ 'result_type' ] ) {
  542. // case 'results':
  543. // $filtered_results = $wpdb->get_results( $prepared_query );
  544. //
  545. // if(!$filtered_results || count($filtered_results)==0) return false;
  546. //
  547. // $final_filtered_results = array();
  548. // return $final_filtered_results;
  549. // case 'col':
  550. // $filtered_results = $wpdb->get_col( $prepared_query );
  551. // return $filtered_results;
  552. // case 'row':
  553. // $filtered_result = $wpdb->get_row( $prepared_query );
  554. // return $filtered_result;
  555. // case 'var':
  556. // $filtered_results = $wpdb->get_var( $prepared_query );
  557. // return $filtered_results;
  558. // default:
  559. // return false;
  560. // }
  561. // }
  562. // } else {
  563. // $filtered_results = array();
  564. // foreach ( $cached_posts_translations as $cached_posts_translation ) {
  565. // $add = true;
  566. //
  567. // foreach ( $query_args as $field => $value ) {
  568. // if ($value!==false && $cached_posts_translation->$field != $value ) {
  569. // $add = false;
  570. // break;
  571. // }
  572. // }
  573. // if ( $add ) {
  574. // $filtered_results[ ] = $cached_posts_translation;
  575. // }
  576. // }
  577. //
  578. // if(!$filtered_results || count($filtered_results)==0) {
  579. // if(!$use_global_cache_fallback) {
  580. // return icl_cache_get_translation_element($args, true );
  581. // } else {
  582. // return false;
  583. // }
  584. // }
  585. //
  586. // if($args[ 'fields' ]=='*') {
  587. // $filtered_result_item = (array)$filtered_results[ 0 ];
  588. // $filtered_result_keys = array_keys( $filtered_result_item );
  589. // $args[ 'fields' ] = $filtered_result_keys[0];
  590. // }
  591. //
  592. // switch ( $args[ 'result_type' ] ) {
  593. // case 'results':
  594. // return $filtered_results;
  595. // case 'col':
  596. // $cols = array();
  597. // foreach ( $filtered_results as $filtered_result ) {
  598. // $cols[ ] = $filtered_result->$args[ 'fields' ];
  599. // }
  600. //
  601. // return $cols;
  602. // case 'row':
  603. // return $filtered_results[ 0 ];
  604. // case 'var':
  605. // return $filtered_results[ 0 ]->$args[ 'fields' ];
  606. // default:
  607. // return false;
  608. // }
  609. // }
  610. // }
  611. //}
  612. class icl_cache{
  613. private $data;
  614. function __construct($name = "", $cache_to_option = false){
  615. $this->data = array();
  616. $this->name = $name;
  617. $this->cache_to_option = $cache_to_option;
  618. if ($cache_to_option) {
  619. $this->data = icl_cache_get($name.'_cache_class');
  620. if ($this->data == false){
  621. $this->data = array();
  622. }
  623. }
  624. }
  625. function get($key) {
  626. if(ICL_DISABLE_CACHE){
  627. return null;
  628. }
  629. return isset($this->data[$key]) ? $this->data[$key] : false;
  630. }
  631. function has_key($key){
  632. if(ICL_DISABLE_CACHE){
  633. return false;
  634. }
  635. return array_key_exists($key, (array)$this->data);
  636. }
  637. function set($key, $value) {
  638. if(ICL_DISABLE_CACHE){
  639. return;
  640. }
  641. $this->data[$key] = $value;
  642. if ($this->cache_to_option) {
  643. icl_cache_set($this->name.'_cache_class', $this->data);
  644. }
  645. }
  646. function clear() {
  647. $this->data = array();
  648. if ($this->cache_to_option) {
  649. icl_cache_clear($this->name.'_cache_class');
  650. }
  651. }
  652. }