class-wpml-tm-settings-post-process.php
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
class WPML_TM_Settings_Post_Process extends WPML_TM_User {
/**
* Saves TM settings to the database in case they have changed after reading a config file.
*/
public function run() {
$changed = false;
$settings = &$this->tm_instance->settings;
foreach (
array(
WPML_POST_META_READONLY_SETTING_INDEX,
WPML_TERM_META_READONLY_SETTING_INDEX,
WPML_POST_TYPE_READONLY_SETTING_INDEX
) as $index
) {
$prev_index = $this->prev_index( $index );
if ( isset( $settings[ $index ] ) && isset( $settings[ $prev_index ] ) ) {
foreach (
array(
$index => $prev_index,
$prev_index => $index
) as $left_index => $right_index
) {
foreach ( $settings[ $right_index ] as $cf ) {
if ( ! in_array( $cf,
$settings[ $left_index ] )
) {
$changed = true;
break;
}
}
}
}
}
if ( $changed ) {
$this->tm_instance->save_settings();
}
}
private function prev_index( $index ) {
return '__' . $index . '_prev';
}
}