class-wcml-jck-wssv.php
24 lines
| 1 | <?php |
| 2 | |
| 3 | class WCML_JCK_WSSV implements \IWPML_Action { |
| 4 | |
| 5 | private $transient_name = 'jck_wssv_term_counts'; |
| 6 | |
| 7 | public function add_hooks() { |
| 8 | add_filter( 'pre_transient_' . $this->transient_name, [ $this, 'get_language_specific_transient' ] ); |
| 9 | add_filter( 'set_transient_' . $this->transient_name, [ $this, 'set_language_specific_transient' ], 10, 2 ); |
| 10 | } |
| 11 | |
| 12 | public function get_language_specific_transient() { |
| 13 | return get_transient( $this->transient_name . '_' . ICL_LANGUAGE_CODE ); |
| 14 | } |
| 15 | |
| 16 | public function set_language_specific_transient( $value, $expiration ) { |
| 17 | |
| 18 | delete_transient( $this->transient_name ); |
| 19 | set_transient( $this->transient_name . '_' . ICL_LANGUAGE_CODE, $value, $expiration ); |
| 20 | |
| 21 | } |
| 22 | |
| 23 | } |
| 24 |